foreach -> for

A future ECM update is going to force that on us, so do it now anyway
remotes/origin/work/aacid/moreecm585defines
Albert Astals Cid 4 years ago
parent 6747e7fe8b
commit 2d007f27d3
  1. 2
      autotests/generatorstest.cpp
  2. 54
      core/document.cpp
  3. 3
      part/annotationwidgets.cpp

@ -40,7 +40,7 @@ void GeneratorsTest::testLoadsCorrectly()
} }
int failures = 0; int failures = 0;
int successful = 0; int successful = 0;
foreach (const QString &lib, generatorLibs) { for (const QString &lib : qAsConst(generatorLibs)) {
KPluginLoader loader(lib); KPluginLoader loader(lib);
QVERIFY2(!loader.fileName().isEmpty(), qPrintable(lib)); QVERIFY2(!loader.fileName().isEmpty(), qPrintable(lib));
qDebug() << loader.fileName(); qDebug() << loader.fileName();

@ -1171,12 +1171,13 @@ void DocumentPrivate::recalculateForms()
{ {
const QVariant fco = m_parent->metaData(QStringLiteral("FormCalculateOrder")); const QVariant fco = m_parent->metaData(QStringLiteral("FormCalculateOrder"));
const QVector<int> formCalculateOrder = fco.value<QVector<int>>(); const QVector<int> formCalculateOrder = fco.value<QVector<int>>();
foreach (int formId, formCalculateOrder) { for (int formId : formCalculateOrder) {
for (uint pageIdx = 0; pageIdx < m_parent->pages(); pageIdx++) { for (uint pageIdx = 0; pageIdx < m_parent->pages(); pageIdx++) {
const Page *p = m_parent->page(pageIdx); const Page *p = m_parent->page(pageIdx);
if (p) { if (p) {
bool pageNeedsRefresh = false; bool pageNeedsRefresh = false;
foreach (FormField *form, p->formFields()) { const QLinkedList<Okular::FormField *> forms = p->formFields();
for (FormField *form : forms) {
if (form->id() == formId) { if (form->id() == formId) {
Action *action = form->additionalAction(FormField::CalculateField); Action *action = form->additionalAction(FormField::CalculateField);
if (action) { if (action) {
@ -1516,8 +1517,9 @@ void DocumentPrivate::rotationFinished(int page, Okular::Page *okularPage)
return; return;
} }
foreach (DocumentObserver *o, m_observers) for (DocumentObserver *o : qAsConst(m_observers)) {
o->notifyPageChanged(page, DocumentObserver::Pixmap | DocumentObserver::Annotations); o->notifyPageChanged(page, DocumentObserver::Pixmap | DocumentObserver::Annotations);
}
} }
void DocumentPrivate::slotFontReadingProgress(int page) void DocumentPrivate::slotFontReadingProgress(int page)
@ -1752,9 +1754,11 @@ void DocumentPrivate::doProcessSearchMatch(RegularAreaRect *match, RunningSearch
} }
// notify observers about highlights changes // notify observers about highlights changes
foreach (int pageNumber, *pagesToNotify) for (int pageNumber : qAsConst(*pagesToNotify)) {
foreach (DocumentObserver *observer, m_observers) for (DocumentObserver *observer : qAsConst(m_observers)) {
observer->notifyPageChanged(pageNumber, DocumentObserver::Highlights); observer->notifyPageChanged(pageNumber, DocumentObserver::Highlights);
}
}
if (foundAMatch) { if (foundAMatch) {
Q_EMIT m_parent->searchFinished(searchID, Document::MatchFound); Q_EMIT m_parent->searchFinished(searchID, Document::MatchFound);
@ -1781,8 +1785,9 @@ void DocumentPrivate::doContinueAllDocumentSearch(void *pagesToNotifySet, void *
} }
Q_EMIT m_parent->searchFinished(searchID, Document::SearchCancelled); Q_EMIT m_parent->searchFinished(searchID, Document::SearchCancelled);
foreach (const MatchesVector &mv, *pageMatches) for (const MatchesVector &mv : qAsConst(*pageMatches)) {
qDeleteAll(mv); qDeleteAll(mv);
}
delete pageMatches; delete pageMatches;
delete pagesToNotify; delete pagesToNotify;
return; return;
@ -1827,7 +1832,7 @@ void DocumentPrivate::doContinueAllDocumentSearch(void *pagesToNotifySet, void *
it = pageMatches->constBegin(); it = pageMatches->constBegin();
itEnd = pageMatches->constEnd(); itEnd = pageMatches->constEnd();
for (; it != itEnd; ++it) { for (; it != itEnd; ++it) {
foreach (RegularAreaRect *match, it.value()) { for (RegularAreaRect *match : it.value()) {
it.key()->d->setHighlight(searchID, match, search->cachedColor); it.key()->d->setHighlight(searchID, match, search->cachedColor);
delete match; delete match;
} }
@ -1835,13 +1840,16 @@ void DocumentPrivate::doContinueAllDocumentSearch(void *pagesToNotifySet, void *
pagesToNotify->insert(it.key()->number()); pagesToNotify->insert(it.key()->number());
} }
foreach (DocumentObserver *observer, m_observers) for (DocumentObserver *observer : qAsConst(m_observers)) {
observer->notifySetup(m_pagesVector, 0); observer->notifySetup(m_pagesVector, 0);
}
// notify observers about highlights changes // notify observers about highlights changes
foreach (int pageNumber, *pagesToNotify) for (int pageNumber : qAsConst(*pagesToNotify)) {
foreach (DocumentObserver *observer, m_observers) for (DocumentObserver *observer : qAsConst(m_observers)) {
observer->notifyPageChanged(pageNumber, DocumentObserver::Highlights); observer->notifyPageChanged(pageNumber, DocumentObserver::Highlights);
}
}
if (foundAMatch) { if (foundAMatch) {
Q_EMIT m_parent->searchFinished(searchID, Document::MatchFound); Q_EMIT m_parent->searchFinished(searchID, Document::MatchFound);
@ -1872,9 +1880,10 @@ void DocumentPrivate::doContinueGooglesDocumentSearch(void *pagesToNotifySet, vo
Q_EMIT m_parent->searchFinished(searchID, Document::SearchCancelled); Q_EMIT m_parent->searchFinished(searchID, Document::SearchCancelled);
foreach (const MatchesVector &mv, *pageMatches) { for (const MatchesVector &mv : qAsConst(*pageMatches)) {
foreach (const MatchColor &mc, mv) for (const MatchColor &mc : mv) {
delete mc.first; delete mc.first;
}
} }
delete pageMatches; delete pageMatches;
delete pagesToNotify; delete pagesToNotify;
@ -1930,9 +1939,10 @@ void DocumentPrivate::doContinueGooglesDocumentSearch(void *pagesToNotifySet, vo
// if not all words are present in page, remove partial highlights // if not all words are present in page, remove partial highlights
const bool matchAll = search->cachedType == Document::GoogleAll; const bool matchAll = search->cachedType == Document::GoogleAll;
if (!allMatched && matchAll) { if (!allMatched && matchAll) {
QVector<MatchColor> &matches = (*pageMatches)[page]; const QVector<MatchColor> &matches = (*pageMatches)[page];
foreach (const MatchColor &mc, matches) for (const MatchColor &mc : matches) {
delete mc.first; delete mc.first;
}
pageMatches->remove(page); pageMatches->remove(page);
} }
@ -1947,7 +1957,7 @@ void DocumentPrivate::doContinueGooglesDocumentSearch(void *pagesToNotifySet, vo
it = pageMatches->constBegin(); it = pageMatches->constBegin();
itEnd = pageMatches->constEnd(); itEnd = pageMatches->constEnd();
for (; it != itEnd; ++it) { for (; it != itEnd; ++it) {
foreach (const MatchColor &mc, it.value()) { for (const MatchColor &mc : it.value()) {
it.key()->d->setHighlight(searchID, mc.first, mc.second); it.key()->d->setHighlight(searchID, mc.first, mc.second);
delete mc.first; delete mc.first;
} }
@ -1956,13 +1966,16 @@ void DocumentPrivate::doContinueGooglesDocumentSearch(void *pagesToNotifySet, vo
} }
// send page lists to update observers (since some filter on bookmarks) // send page lists to update observers (since some filter on bookmarks)
foreach (DocumentObserver *observer, m_observers) for (DocumentObserver *observer : qAsConst(m_observers)) {
observer->notifySetup(m_pagesVector, 0); observer->notifySetup(m_pagesVector, 0);
}
// notify observers about highlights changes // notify observers about highlights changes
foreach (int pageNumber, *pagesToNotify) for (int pageNumber : qAsConst(*pagesToNotify)) {
foreach (DocumentObserver *observer, m_observers) for (DocumentObserver *observer : qAsConst(m_observers)) {
observer->notifyPageChanged(pageNumber, DocumentObserver::Highlights); observer->notifyPageChanged(pageNumber, DocumentObserver::Highlights);
}
}
if (foundAMatch) { if (foundAMatch) {
Q_EMIT m_parent->searchFinished(searchID, Document::MatchFound); Q_EMIT m_parent->searchFinished(searchID, Document::MatchFound);
@ -3008,10 +3021,11 @@ void Document::setVisiblePageRects(const QVector<VisiblePageRect *> &visiblePage
} }
d->m_pageRects = visiblePageRects; d->m_pageRects = visiblePageRects;
// notify change to all other (different from id) observers // notify change to all other (different from id) observers
foreach (DocumentObserver *o, d->m_observers) for (DocumentObserver *o : qAsConst(d->m_observers)) {
if (o != excludeObserver) { if (o != excludeObserver) {
o->notifyVisibleRectsChanged(); o->notifyVisibleRectsChanged();
} }
}
} }
uint Document::currentPage() const uint Document::currentPage() const
@ -3582,7 +3596,7 @@ void Document::removePageAnnotation(int page, Annotation *annotation)
void Document::removePageAnnotations(int page, const QList<Annotation *> &annotations) void Document::removePageAnnotations(int page, const QList<Annotation *> &annotations)
{ {
d->m_undoStack->beginMacro(i18nc("remove a collection of annotations from the page", "remove annotations")); d->m_undoStack->beginMacro(i18nc("remove a collection of annotations from the page", "remove annotations"));
foreach (Annotation *annotation, annotations) { for (Annotation *annotation : annotations) {
QUndoCommand *uc = new RemoveAnnotationCommand(this->d, annotation, page); QUndoCommand *uc = new RemoveAnnotationCommand(this->d, annotation, page);
d->m_undoStack->push(uc); d->m_undoStack->push(uc);
} }

@ -469,8 +469,7 @@ void StampAnnotationWidget::createStyleWidget(QFormLayout *formlayout)
formlayout->addRow(i18n("Stamp symbol:"), m_pixmapSelector); formlayout->addRow(i18n("Stamp symbol:"), m_pixmapSelector);
m_pixmapSelector->setEditable(true); m_pixmapSelector->setEditable(true);
QPair<QString, QString> pair; for (const QPair<QString, QString> &pair : defaultStamps()) {
foreach (pair, defaultStamps()) {
m_pixmapSelector->addItem(pair.first, pair.second); m_pixmapSelector->addItem(pair.first, pair.second);
} }

Loading…
Cancel
Save