r23454 by jghali - Replace a few Qt's foreach by C++11 range for
scribus-commit
scribus-commit at lists.scribus.net
Thu Jan 30 21:59:35 UTC 2020
Author: jghali
Date: Thu Jan 30 21:59:34 2020
New Revision: 23454
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23454
Log:
Replace a few Qt's foreach by C++11 range for
Modified:
trunk/Scribus/scribus/scribusdoc.cpp
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23454&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Thu Jan 30 21:59:34 2020
@@ -16845,8 +16845,10 @@
if (updateNumerations)
//after styles change reset all numerations settings
setupNumerations();
+
//reset ALL counters
- foreach (NumStruct * numS, numerations.values())
+ QList<NumStruct*> numerationValues = numerations.values();
+ for (NumStruct * numS : numerationValues)
for (int l = 0; l < numS->m_nums.count(); ++l)
numS->m_counters[l] = numS->m_nums[l].start -1;
@@ -16855,7 +16857,7 @@
for (int sec = 0; sec < sections().count(); ++sec)
{
//reset section range counters
- foreach (NumStruct * numS, numerations.values())
+ for (NumStruct * numS : numerationValues)
for (int l = 0; l < numS->m_nums.count(); ++l)
if (numS->m_nums[l].range == NSRsection)
numS->m_counters[l] = numS->m_nums[l].start -1;
@@ -16865,11 +16867,12 @@
for (int page = start; page <= stop; ++page)
{
//reset page range counters
- foreach (NumStruct * numS, numerations.values())
+ for (NumStruct * numS : numerationValues)
for (int l = 0; l < numS->m_nums.count(); ++l)
if (numS->m_nums[l].range == NSRpage)
numS->m_counters[l] = numS->m_nums[l].start -1;
- for (int i=0; i < DocItems.count(); ++i)
+
+ for (int i = 0; i < DocItems.count(); ++i)
{
PageItem* item = DocItems.at(i);
if (item->OwnPage != page)
@@ -16880,17 +16883,18 @@
continue;
//reset items and stories range counters
- foreach (NumStruct * numS, numerations.values())
+ for (NumStruct * numS : numerationValues)
for (int l = 0; l < numS->m_nums.count(); ++l)
if ((numS->m_nums[l].range == NSRframe) || ((numS->m_nums[l].range == NSRstory) && (item->prevInChain() == nullptr)))
numS->m_counters[l] = numS->m_nums[l].start -1;
int pos = item->firstInFrame();
int last = item->lastInFrame();
- if (pos > last) continue;
-
- if ((pos != 0) && (item->itemText.text(pos-1) != SpecialChars::PARSEP))
- pos = item->itemText.nextParagraph(pos)+1;
+ if (pos > last)
+ continue;
+
+ if ((pos != 0) && (item->itemText.text(pos - 1) != SpecialChars::PARSEP))
+ pos = item->itemText.nextParagraph(pos) + 1;
int len = item->itemText.length();
while (pos <= last)
{
@@ -16955,19 +16959,19 @@
}
//update local numbering
- foreach (PageItem* item, DocItems)
- {
- if (item->itemText.length() > 0)
- {
- PageItem* itemFirst = item->firstInChain();
- if (updateLocalNums(itemFirst->itemText))
- {
- if (itemFirst->isTextFrame())
- itemFirst->asTextFrame()->invalidateLayout(true);
- else
- itemFirst->invalidateLayout();
- }
- }
+ for (PageItem* item : DocItems)
+ {
+ if (item->itemText.length() <= 0)
+ continue;
+
+ PageItem* itemFirst = item->firstInChain();
+ if (!updateLocalNums(itemFirst->itemText))
+ continue;
+
+ if (itemFirst->isTextFrame())
+ itemFirst->asTextFrame()->invalidateLayout(true);
+ else
+ itemFirst->invalidateLayout();
}
}
@@ -16975,9 +16979,9 @@
QStringList ScribusDoc::marksLabelsList(MarkType type)
{
QStringList nameList;
- for (int a=0; a < m_docMarksList.count(); ++a)
- {
- Mark* m = m_docMarksList.at(a);
+ for (int i = 0; i < m_docMarksList.count(); ++i)
+ {
+ Mark* m = m_docMarksList.at(i);
if (m == nullptr)
continue;
if ((m != nullptr) && m->isType(type))
More information about the scribus-commit
mailing list