diff --git a/autotests/unit/file/pendingfilequeuetest.cpp b/autotests/unit/file/pendingfilequeuetest.cpp --- a/autotests/unit/file/pendingfilequeuetest.cpp +++ b/autotests/unit/file/pendingfilequeuetest.cpp @@ -61,7 +61,7 @@ // The signal should be emitted immediately QVERIFY(spy.wait()); QCOMPARE(spy.count(), 1); - QCOMPARE(spy.takeFirst().first().toString(), myUrl); + QCOMPARE(spy.takeFirst().constFirst().toString(), myUrl); // Enqueue the url again. This time it should wait for should wait for the // minimumTimeout @@ -72,7 +72,7 @@ QVERIFY(spy.wait(2000)); QCOMPARE(spy.count(), 1); - QCOMPARE(spy.takeFirst().first().toString(), myUrl); + QCOMPARE(spy.takeFirst().constFirst().toString(), myUrl); } void PendingFileQueueTest::testRequeue() @@ -93,7 +93,7 @@ // The signal should be emitted immediately QTest::qWait(20); QCOMPARE(spy.count(), 1); - QCOMPARE(spy.takeFirst().first().toString(), myUrl); + QCOMPARE(spy.takeFirst().constFirst().toString(), myUrl); // Send many events queue.enqueue(file); @@ -108,7 +108,7 @@ QVERIFY(spy.wait(2500)); QCOMPARE(spy.count(), 1); - QCOMPARE(spy.takeFirst().first().toString(), myUrl); + QCOMPARE(spy.takeFirst().constFirst().toString(), myUrl); } QTEST_GUILESS_MAIN(PendingFileQueueTest) diff --git a/src/engine/transaction.cpp b/src/engine/transaction.cpp --- a/src/engine/transaction.cpp +++ b/src/engine/transaction.cpp @@ -314,15 +314,17 @@ vec.reserve(query.subQueries().size()); if (query.op() == EngineQuery::Phrase) { - for (const EngineQuery& q : query.subQueries()) { + const auto subQueries = query.subQueries(); + for (const EngineQuery& q : subQueries) { Q_ASSERT_X(q.leaf(), "Transaction::toPostingIterator", "Phrase queries must contain leaf queries"); vec << positionDb.iter(q.term()); } return new PhraseAndIterator(vec); } - for (const EngineQuery& q : query.subQueries()) { + const auto subQueries = query.subQueries(); + for (const EngineQuery& q : subQueries) { vec << postingIterator(q); } @@ -472,7 +474,7 @@ out << "Total Document IDs: " << allIds.size() << endl; int count = 0; - for (quint64 id: allIds) { + for (quint64 id: qAsConst(allIds)) { QByteArray url = docUrlDb.get(id); if (url.isEmpty()) { auto terms = documentTermsDB.get(id); @@ -491,7 +493,7 @@ out << "Missing filePath for " << id << endl; out << "\tPostingDB Terms: "; - for (const QByteArray& term : newTerms) { + for (const QByteArray& term : qAsConst(newTerms)) { out << term << " "; } out << endl; @@ -545,12 +547,12 @@ QTextStream out(stdout); out << "PostingDB check .." << endl; - for (quint64 id : allIds) { + for (quint64 id : qAsConst(allIds)) { QVector terms = documentTermsDB.get(id); terms += documentXattrTermsDB.get(id); terms += documentFileNameTermsDB.get(id); - for (const QByteArray& term : terms) { + for (const QByteArray& term : qAsConst(terms)) { PostingList plist = postingDb.get(term); if (!plist.contains(id)) { out << id << " is missing term " << term << endl; diff --git a/src/file/fileindexerconfig.cpp b/src/file/fileindexerconfig.cpp --- a/src/file/fileindexerconfig.cpp +++ b/src/file/fileindexerconfig.cpp @@ -323,7 +323,8 @@ // Add all removable media and network shares as ignored unless they have // been explicitly added in the include list - for (const auto& device: m_devices->allMedia()) { + const auto allMedia = m_devices->allMedia(); + for (const auto& device: allMedia) { const QString mountPath = device.mountPath(); if (!device.isUsable() && !mountPath.isEmpty()) { if (!includeFoldersPlain.contains(mountPath)) { diff --git a/src/file/fileindexscheduler.cpp b/src/file/fileindexscheduler.cpp --- a/src/file/fileindexscheduler.cpp +++ b/src/file/fileindexscheduler.cpp @@ -172,7 +172,7 @@ m_contentIndexer->quit(); //TODO: Maybe we can add a special state for suspended due to being on battery. m_indexerState = Idle; - stateChanged(m_indexerState); + Q_EMIT stateChanged(m_indexerState); } else if (!isOnBattery) { scheduleIndexing(); } diff --git a/src/file/firstrunindexer.cpp b/src/file/firstrunindexer.cpp --- a/src/file/firstrunindexer.cpp +++ b/src/file/firstrunindexer.cpp @@ -49,7 +49,7 @@ QMimeDatabase mimeDb; - for (const QString& folder : m_folders) { + for (const QString& folder : qAsConst(m_folders)) { Transaction tr(m_db, Transaction::ReadWrite); FilteredDirIterator it(m_config, folder); diff --git a/src/file/indexcleaner.cpp b/src/file/indexcleaner.cpp --- a/src/file/indexcleaner.cpp +++ b/src/file/indexcleaner.cpp @@ -71,7 +71,8 @@ return false; }; - for (const QString& folder : m_config->includeFolders()) { + const auto includeFolders = m_config->includeFolders(); + for (const QString& folder : includeFolders) { quint64 id = filePathToId(QFile::encodeName(folder)); tr.removeRecursively(id, shouldDelete); } diff --git a/src/file/modifiedfileindexer.cpp b/src/file/modifiedfileindexer.cpp --- a/src/file/modifiedfileindexer.cpp +++ b/src/file/modifiedfileindexer.cpp @@ -48,7 +48,7 @@ Transaction tr(m_db, Transaction::ReadWrite); - for (const QString& filePath : m_files) { + for (const QString& filePath : qAsConst(m_files)) { Q_ASSERT(!filePath.endsWith('/')); QString fileName = filePath.mid(filePath.lastIndexOf('/') + 1); diff --git a/src/file/newfileindexer.cpp b/src/file/newfileindexer.cpp --- a/src/file/newfileindexer.cpp +++ b/src/file/newfileindexer.cpp @@ -44,7 +44,7 @@ Transaction tr(m_db, Transaction::ReadWrite); - for (const QString& filePath : m_files) { + for (const QString& filePath : qAsConst(m_files)) { Q_ASSERT(!filePath.endsWith('/')); QString fileName = filePath.mid(filePath.lastIndexOf('/') + 1); diff --git a/src/file/xattrindexer.cpp b/src/file/xattrindexer.cpp --- a/src/file/xattrindexer.cpp +++ b/src/file/xattrindexer.cpp @@ -44,7 +44,7 @@ Transaction tr(m_db, Transaction::ReadWrite); - for (const QString& filePath : m_files) { + for (const QString& filePath : qAsConst(m_files)) { Q_ASSERT(!filePath.endsWith('/')); QString fileName = filePath.mid(filePath.lastIndexOf('/') + 1); diff --git a/src/kioslaves/kded/baloosearchmodule.cpp b/src/kioslaves/kded/baloosearchmodule.cpp --- a/src/kioslaves/kded/baloosearchmodule.cpp +++ b/src/kioslaves/kded/baloosearchmodule.cpp @@ -86,7 +86,7 @@ void SearchModule::slotBalooFileDbChanged() { qDebug() << m_searchUrls; - for (const QUrl& dirUrl : m_searchUrls) { + for (const QUrl& dirUrl : qAsConst(m_searchUrls)) { org::kde::KDirNotify::emitFilesAdded(dirUrl); } } diff --git a/src/lib/query.cpp b/src/lib/query.cpp --- a/src/lib/query.cpp +++ b/src/lib/query.cpp @@ -185,7 +185,7 @@ { Term term(d->m_term); if (!d->m_types.isEmpty()) { - for (const QString& type : d->m_types) { + for (const QString& type : qAsConst(d->m_types)) { term = term && Term(QStringLiteral("type"), type); } } diff --git a/src/lib/searchstore.cpp b/src/lib/searchstore.cpp --- a/src/lib/searchstore.cpp +++ b/src/lib/searchstore.cpp @@ -160,11 +160,11 @@ Q_ASSERT(tr); if (term.operation() == Term::And || term.operation() == Term::Or) { - QList subTerms = term.subTerms(); + const QList subTerms = term.subTerms(); QVector vec; vec.reserve(subTerms.size()); - for (const Term& t : term.subTerms()) { + for (const Term& t : subTerms) { vec << constructQuery(tr, t); } diff --git a/src/lib/taglistjob.cpp b/src/lib/taglistjob.cpp --- a/src/lib/taglistjob.cpp +++ b/src/lib/taglistjob.cpp @@ -59,7 +59,7 @@ tagList = tr.fetchTermsStartingWith("TAG-"); } d->tags.reserve(tagList.size()); - for (const QByteArray& ba : tagList) { + for (const QByteArray& ba : qAsConst(tagList)) { d->tags << QString::fromUtf8(ba.mid(4)); } diff --git a/src/lib/term.cpp b/src/lib/term.cpp --- a/src/lib/term.cpp +++ b/src/lib/term.cpp @@ -459,7 +459,8 @@ } else { d << "[" << operationToString(t.operation()).toUtf8().constData(); - for (const Term& term : t.subTerms()) { + const auto subTerms = t.subTerms(); + for (const Term& term : subTerms) { d << term; } d << "]";