r23810 by jghali - Add PageItemIterator constructor for iteratoring across items of a whole document

scribus-commit scribus-commit at lists.scribus.net
Sat May 16 15:02:26 UTC 2020


Author: jghali
Date: Sat May 16 15:02:26 2020
New Revision: 23810

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23810
Log:
Add PageItemIterator constructor for iteratoring across items of a whole 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=23810&path=/trunk/Scribus/scribus/pageitemiterator.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitemiterator.cpp	(original)
+++ trunk/Scribus/scribus/pageitemiterator.cpp	Sat May 16 15:02:26 2020
@@ -9,6 +9,8 @@
 #include "pageitem.h"
 #include "pageitem_group.h"
 #include "pageitem_table.h"
+#include "scpattern.h"
+#include "scribusdoc.h"
 
 PageItemIterator::PageItemIterator(int options) :
 	m_options(options)
@@ -25,6 +27,49 @@
 		m_stateStack.push(state);
 		m_current = next();
 	}
+}
+
+PageItemIterator::PageItemIterator(ScribusDoc* doc, int options) :
+	m_options(options)
+{
+	int stackItemCount = doc->docPatterns.count() + 3;
+	m_stateStack.reserve(stackItemCount);
+
+	if (doc->docPatterns.count() > 0)
+	{
+		auto docPatternEnd = doc->docPatterns.constEnd();
+		for (auto it = doc->docPatterns.constBegin(); it != docPatternEnd; ++it)
+		{
+			const ScPattern& pattern = it.value();
+			if (pattern.items.count() > 0)
+			{
+				State state = { pattern.items, 0 };
+				m_stateStack.push(state);
+			}
+		}
+	}
+
+	if (doc->FrameItems.count() > 0)
+	{
+		QList<PageItem*> frameItems = doc->FrameItems.values();
+		State state = { frameItems, 0 };
+		m_stateStack.push(state);
+	}
+
+	if (doc->MasterItems.count() > 0)
+	{
+		State state = { doc->MasterItems, 0 };
+		m_stateStack.push(state);
+	}
+
+	if (doc->DocItems.count() > 0)
+	{
+		State state = { doc->DocItems, 0 };
+		m_stateStack.push(state);
+	}
+
+	if (m_stateStack.count() > 0)
+		m_current = next();
 }
 
 PageItem* PageItemIterator::begin(const QList<PageItem*>& itemList)

Modified: trunk/Scribus/scribus/pageitemiterator.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23810&path=/trunk/Scribus/scribus/pageitemiterator.h
==============================================================================
--- trunk/Scribus/scribus/pageitemiterator.h	(original)
+++ trunk/Scribus/scribus/pageitemiterator.h	Sat May 16 15:02:26 2020
@@ -14,6 +14,7 @@
 #include "scribusapi.h"
 
 class PageItem;
+class ScribusDoc;
 
 class SCRIBUS_API PageItemIterator
 {
@@ -25,6 +26,7 @@
 	};
 	PageItemIterator(int options = IterateInGroups);
 	PageItemIterator(const QList<PageItem*>& itemList, int options = IterateInGroups);
+	PageItemIterator(ScribusDoc* doc, int options = IterateInGroups);
 
 	bool isNull() const { return (m_current == nullptr); }
 	PageItem* current() const { return m_current; }




More information about the scribus-commit mailing list