r23814 by jghali - PageItemIterator: more flexible options for selecting which items are iterated in a document

scribus-commit scribus-commit at lists.scribus.net
Sat May 16 16:43:08 UTC 2020


Author: jghali
Date: Sat May 16 16:43:08 2020
New Revision: 23814

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23814
Log:
PageItemIterator: more flexible options for selecting which items are iterated in a document

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

Modified: trunk/Scribus/scribus/pageitemiterator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23814&path=/trunk/Scribus/scribus/pageitemiterator.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitemiterator.cpp	(original)
+++ trunk/Scribus/scribus/pageitemiterator.cpp	Sat May 16 16:43:08 2020
@@ -35,7 +35,7 @@
 	int stackItemCount = doc->docPatterns.count() + 3;
 	m_stateStack.reserve(stackItemCount);
 
-	if (doc->docPatterns.count() > 0)
+	if ((m_options & IterateInDocPatterns) && (doc->docPatterns.count() > 0))
 	{
 		auto docPatternEnd = doc->docPatterns.constEnd();
 		for (auto it = doc->docPatterns.constBegin(); it != docPatternEnd; ++it)
@@ -49,20 +49,20 @@
 		}
 	}
 
-	if (doc->FrameItems.count() > 0)
+	if ((m_options & IterateInFrameItems) && (doc->FrameItems.count() > 0))
 	{
 		QList<PageItem*> frameItems = doc->FrameItems.values();
 		State state = { frameItems, 0 };
 		m_stateStack.push(state);
 	}
 
-	if (doc->MasterItems.count() > 0)
+	if ((m_options & IterateInMasterItems) && (doc->MasterItems.count() > 0))
 	{
 		State state = { doc->MasterItems, 0 };
 		m_stateStack.push(state);
 	}
 
-	if (doc->DocItems.count() > 0)
+	if ((m_options & IterateInDocItems) && (doc->DocItems.count() > 0))
 	{
 		State state = { doc->DocItems, 0 };
 		m_stateStack.push(state);
@@ -72,16 +72,17 @@
 		m_current = next();
 }
 
-PageItem* PageItemIterator::begin(ScribusDoc* doc)
+PageItem* PageItemIterator::begin(ScribusDoc* doc, int options)
 {
 	m_current = nullptr;
+	m_options = options;
 	m_stateStack.resize(0); // Not clear in order to keep the already allocated memory available
 
 	int stackItemCount = doc->docPatterns.count() + 3;
 	if (m_stateStack.capacity() < stackItemCount)
 		m_stateStack.reserve(stackItemCount);
 
-	if (doc->docPatterns.count() > 0)
+	if ((m_options & IterateInDocPatterns) && (doc->docPatterns.count() > 0))
 	{
 		auto docPatternEnd = doc->docPatterns.constEnd();
 		for (auto it = doc->docPatterns.constBegin(); it != docPatternEnd; ++it)
@@ -95,20 +96,20 @@
 		}
 	}
 
-	if (doc->FrameItems.count() > 0)
+	if ((m_options & IterateInFrameItems) && (doc->FrameItems.count() > 0))
 	{
 		QList<PageItem*> frameItems = doc->FrameItems.values();
 		State state = { frameItems, 0 };
 		m_stateStack.push(state);
 	}
 
-	if (doc->MasterItems.count() > 0)
+	if ((m_options & IterateInMasterItems) && (doc->MasterItems.count() > 0))
 	{
 		State state = { doc->MasterItems, 0 };
 		m_stateStack.push(state);
 	}
 
-	if (doc->DocItems.count() > 0)
+	if ((m_options & IterateInDocItems) && (doc->DocItems.count() > 0))
 	{
 		State state = { doc->DocItems, 0 };
 		m_stateStack.push(state);

Modified: trunk/Scribus/scribus/pageitemiterator.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23814&path=/trunk/Scribus/scribus/pageitemiterator.h
==============================================================================
--- trunk/Scribus/scribus/pageitemiterator.h	(original)
+++ trunk/Scribus/scribus/pageitemiterator.h	Sat May 16 16:43:08 2020
@@ -22,16 +22,21 @@
 	enum Options
 	{
 		IterateInGroups = 1,
-		IterateInTables = 2
+		IterateInTables = 2,
+		IterateInDocItems = 4,
+		IterateInMasterItems = 8,
+		IterateInFrameItems = 16,
+		IterateInDocPatterns = 32,
+		IterateInDocDefaults = IterateInGroups + IterateInDocItems + IterateInMasterItems + IterateInFrameItems + IterateInDocPatterns
 	};
 	PageItemIterator(int options = IterateInGroups);
 	PageItemIterator(const QList<PageItem*>& itemList, int options = IterateInGroups);
-	PageItemIterator(ScribusDoc* doc, int options = IterateInGroups);
+	PageItemIterator(ScribusDoc* doc, int options = IterateInDocDefaults);
 
 	bool isNull() const { return (m_current == nullptr); }
 	PageItem* current() const { return m_current; }
 	
-	PageItem* begin(ScribusDoc* doc);
+	PageItem* begin(ScribusDoc* doc, int options = IterateInDocDefaults);
 	PageItem* begin(const QList<PageItem*>& itemList);
 	PageItem* next();
 




More information about the scribus-commit mailing list