r23808 by jghali - Enable PageItemIterator to be used in for loops

scribus-commit scribus-commit at lists.scribus.net
Wed May 13 23:47:43 UTC 2020


Author: jghali
Date: Wed May 13 23:47:43 2020
New Revision: 23808

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23808
Log:
Enable PageItemIterator to be used in for loops

Modified:
    trunk/Scribus/scribus/pageitemiterator.cpp
    trunk/Scribus/scribus/pageitemiterator.h
    trunk/Scribus/scribus/tocgenerator.cpp

Modified: trunk/Scribus/scribus/pageitemiterator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23808&path=/trunk/Scribus/scribus/pageitemiterator.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitemiterator.cpp	(original)
+++ trunk/Scribus/scribus/pageitemiterator.cpp	Wed May 13 23:47:43 2020
@@ -19,6 +19,7 @@
 	{
 		State state = { itemList, 0 };
 		m_stateStack.push(state);
+		m_current = next();
 	}
 }
 
@@ -69,6 +70,7 @@
 					State tableState = { cellItems, 0 };
 					m_stateStack.push(tableState);
 				}
+				break;
 			}
 		}
 

Modified: trunk/Scribus/scribus/pageitemiterator.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23808&path=/trunk/Scribus/scribus/pageitemiterator.h
==============================================================================
--- trunk/Scribus/scribus/pageitemiterator.h	(original)
+++ trunk/Scribus/scribus/pageitemiterator.h	Wed May 13 23:47:43 2020
@@ -25,7 +25,7 @@
 	};
 	PageItemIterator(const QList<PageItem*>& itemList, int options = IterateInGroups);
 
-	bool hasCurrent() const { return (m_current != 0); }
+	bool isNull() const { return (m_current == nullptr); }
 	PageItem* current() const { return m_current; }
 	PageItem* next();
 

Modified: trunk/Scribus/scribus/tocgenerator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23808&path=/trunk/Scribus/scribus/tocgenerator.cpp
==============================================================================
--- trunk/Scribus/scribus/tocgenerator.cpp	(original)
+++ trunk/Scribus/scribus/tocgenerator.cpp	Wed May 13 23:47:43 2020
@@ -85,8 +85,7 @@
 		for (int i = 0; i < m_doc->DocPages.count(); ++i)
 			pageCounter[i] = 0;
 
-		PageItemIterator itemIter(m_doc->DocItems);
-		while (itemIter.next())
+		for (PageItemIterator itemIter(m_doc->DocItems); *itemIter; ++itemIter)
 		{
 			currentDocItem = itemIter.current();
 			if (currentDocItem == nullptr)




More information about the scribus-commit mailing list