Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 24693 → Rev 24694

/trunk/Scribus/scribus/pageitemiterator.cpp
15,7 → 15,7
PageItemIterator::PageItemIterator(int options) :
m_options(options)
{
 
m_stateStack.reserve(16);
}
 
PageItemIterator::PageItemIterator(const QList<PageItem*>& itemList, int options) :
24,7 → 24,8
if (itemList.count() > 0)
{
State state = { itemList, 0 };
m_stateStack.push(state);
m_stateStack.reserve(16);
m_stateStack.push_back(state);
m_current = next();
}
}
42,33 → 43,20
{
const ScPattern& pattern = it.value();
if (pattern.items.count() > 0)
{
State state = { pattern.items, 0 };
m_stateStack.push(state);
}
m_stateStack.emplace_back(pattern.items, 0);
}
}
 
if ((m_options & IterateInFrameItems) && (doc->FrameItems.count() > 0))
{
QList<PageItem*> frameItems = doc->FrameItems.values();
State state = { frameItems, 0 };
m_stateStack.push(state);
}
m_stateStack.emplace_back(doc->FrameItems.values(), 0);
 
if ((m_options & IterateInMasterItems) && (doc->MasterItems.count() > 0))
{
State state = { doc->MasterItems, 0 };
m_stateStack.push(state);
}
m_stateStack.emplace_back(doc->MasterItems, 0);
 
if ((m_options & IterateInDocItems) && (doc->DocItems.count() > 0))
{
State state = { doc->DocItems, 0 };
m_stateStack.push(state);
}
m_stateStack.emplace_back(doc->DocItems, 0);
 
if (m_stateStack.count() > 0)
if (m_stateStack.size() > 0)
m_current = next();
}
 
89,33 → 77,20
{
const ScPattern& pattern = it.value();
if (pattern.items.count() > 0)
{
State state = { pattern.items, 0 };
m_stateStack.push(state);
}
m_stateStack.emplace_back(pattern.items, 0);
}
}
 
if ((m_options & IterateInFrameItems) && (doc->FrameItems.count() > 0))
{
QList<PageItem*> frameItems = doc->FrameItems.values();
State state = { frameItems, 0 };
m_stateStack.push(state);
}
m_stateStack.emplace_back(doc->FrameItems.values(), 0);
 
if ((m_options & IterateInMasterItems) && (doc->MasterItems.count() > 0))
{
State state = { doc->MasterItems, 0 };
m_stateStack.push(state);
}
m_stateStack.emplace_back(doc->MasterItems, 0);
 
if ((m_options & IterateInDocItems) && (doc->DocItems.count() > 0))
{
State state = { doc->DocItems, 0 };
m_stateStack.push(state);
}
m_stateStack.emplace_back(doc->DocItems, 0);
 
if (m_stateStack.count() > 0)
if (m_stateStack.size() > 0)
m_current = next();
return m_current;
}
127,8 → 102,7
 
if (itemList.count() > 0)
{
State state = { itemList, 0 };
m_stateStack.push(state);
m_stateStack.emplace_back(itemList, 0);
m_current = next();
}
 
137,12 → 111,12
 
PageItem* PageItemIterator::next()
{
while (m_stateStack.count() > 0)
while (m_stateStack.size() > 0)
{
State& currentState = m_stateStack.top();
State& currentState = m_stateStack.back();
if (currentState.currentIndex >= currentState.itemList.count())
{
m_stateStack.pop();
m_stateStack.pop_back();
continue;
}
 
161,10 → 135,7
m_current = groupItem;
currentState.currentIndex++;
if (groupItem->groupItemList.count() > 0)
{
State groupState = { groupItem->groupItemList, 0 };
m_stateStack.push(groupState);
}
m_stateStack.emplace_back(groupItem->groupItemList, 0);
break;
}
}
178,10 → 149,7
currentState.currentIndex++;
QList<PageItem*> cellItems = tableItem->getChildren();
if (cellItems.count() > 0)
{
State tableState = { cellItems, 0 };
m_stateStack.push(tableState);
}
m_stateStack.emplace_back(cellItems, 0);
break;
}
}
191,7 → 159,7
break;
}
 
if (m_stateStack.isEmpty())
if (m_stateStack.empty())
m_current = nullptr;
return m_current;
}
/trunk/Scribus/scribus/pageitemiterator.h
8,8 → 8,8
#ifndef PAGEITEMITERATOR_H
#define PAGEITEMITERATOR_H
 
#include <vector>
#include <QList>
#include <QStack>
 
#include "scribusapi.h"
 
52,13 → 52,19
protected:
struct State
{
State() {}
State(const QList<PageItem*> items, int startIndex)
{
itemList = items;
currentIndex = startIndex;
}
QList<PageItem*> itemList;
int currentIndex;
int currentIndex { 0 };
};
 
int m_options { 0 };
PageItem* m_current { nullptr };
QStack<State> m_stateStack;
std::vector<State> m_stateStack;
};
 
#endif // PAGEITEMITERATOR_H