Commit a17fafe8 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to for(...:...)

parent 56127687
......@@ -71,9 +71,12 @@ add_definitions(
-DQT_NO_CAST_FROM_ASCII
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_CAST_FROM_BYTEARRAY
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
)
add_definitions(-DQT_NO_FOREACH)
add_definitions(-DQT_NO_KEYWORDS)
add_subdirectory( plugins )
add_subdirectory( searchhandlers )
if(BUILD_TESTING)
......
......@@ -172,7 +172,8 @@ DocEntry *DocMetaInfo::scanMetaInfoDir( const QString &dirName,
QDir dir( dirName );
if ( !dir.exists() ) return nullptr;
foreach( const QFileInfo &fi, dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot) )
const auto entryInfoList = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
for ( const QFileInfo &fi : entryInfoList )
{
DocEntry *entry = nullptr;
if ( fi.isDir() )
......
......@@ -108,7 +108,7 @@ QString GrantleeFormatter::formatGlossaryEntry( const GlossaryEntry& entry )
const GlossaryEntryXRef::List entrySeeAlso = entry.seeAlso();
QStringList seeAlso;
seeAlso.reserve( entrySeeAlso.count() );
foreach ( const GlossaryEntryXRef &xref, entrySeeAlso )
for ( const GlossaryEntryXRef &xref : entrySeeAlso )
{
seeAlso += QStringLiteral( "<a href=\"glossentry:%1\">%2</a>" ).arg( xref.id(), xref.term() );
}
......@@ -131,7 +131,7 @@ QString GrantleeFormatter::formatSearchResults( const QString& words, const QLis
typedef QPair<DocEntry *, QString> Iter;
QVariantList list;
list.reserve( results.count() );
foreach ( const Iter& it, results )
for ( const Iter& it : results )
{
QVariantHash h;
h.insert( QStringLiteral("title"), it.first->name() );
......
......@@ -167,7 +167,7 @@ void InfoTree::parseInfoDirFile( const QString &infoDirFileName )
}
infoDirFile.close();
foreach ( InfoCategoryItem *item, alphabSections ) {
for ( InfoCategoryItem *item : qAsConst(alphabSections) ) {
item->sortChildren( 0, Qt::AscendingOrder );
}
m_alphabItem->sortChildren( 0, Qt::AscendingOrder );
......
......@@ -157,8 +157,10 @@ MainWindow::MainWindow()
setupActions();
foreach (QAction *act, mDoc->actionCollection()->actions())
const auto actions = mDoc->actionCollection()->actions();
for (QAction *act : actions) {
actionCollection()->addAction(act->objectName(), act);
}
setupBookmarks();
......
......@@ -599,7 +599,7 @@ void Navigator::slotDelayedIndexingStart()
mIndexingQueue.clear();
const DocEntry::List &entries = DocMetaInfo::self()->docEntries();
foreach ( DocEntry *entry, entries ) {
for ( DocEntry *entry : entries ) {
if ( mSearchEngine->needsIndex( entry ) ) {
mIndexingQueue.append( entry );
}
......
......@@ -210,11 +210,12 @@ bool SearchEngine::initSearchHandlers()
{
const QStringList resourceDirs = QStandardPaths::locateAll(QStandardPaths::DataLocation, QStringLiteral("searchhandlers/"), QStandardPaths::LocateDirectory );
QStringList resources;
foreach(const QString& dir, resourceDirs) {
for(const QString& dir : resourceDirs) {
QDir d(dir);
foreach ( const QString& entry, d.entryList( QStringList( QStringLiteral("*.desktop") ), QDir::Files ) ) {
resources += dir + entry;
}
const auto entryList = d.entryList( QStringList( QStringLiteral("*.desktop") ), QDir::Files );
for ( const QString& entry : entryList ) {
resources += dir + entry;
}
}
QStringList::ConstIterator it;
......
......@@ -128,7 +128,7 @@ QByteArray CacheReader::document( const QString& id ) const
std::reverse( docRanges.begin(), docRanges.end() );
QTextStream stream( &doc );
stream.setCodec( "UTF-8" );
Q_FOREACH ( const Range &range, docRanges ) {
for ( const Range &range : qAsConst(docRanges) ) {
stream << mText.mid( range.first, range.second - range.first + 1 );
}
}
......
......@@ -114,7 +114,7 @@ static void analyzeFile( const QFileInfo& cacheFile, const QString& relPath, con
qCDebug(LOG) << " docs to add:" << docsToAdd;
qCDebug(LOG) << " docs to update:" << docsToUpdate.keys();
Q_FOREACH ( Xapian::docid id, docsToRemove ) {
for ( Xapian::docid id : qAsConst(docsToRemove) ) {
db.delete_document( id );
}
......@@ -126,7 +126,7 @@ static void analyzeFile( const QFileInfo& cacheFile, const QString& relPath, con
db.replace_document( dtuIt.value(), doc );
}
Q_FOREACH ( const QString& name, docsToAdd ) {
for ( const QString& name : qAsConst(docsToAdd) ) {
const Xapian::Document doc = createDocument( xgen, uid, lang, std_modTime, name, cr.document( name ) );
const Xapian::docid id = db.add_document( doc );
handledDocuments->insert( id );
......@@ -235,7 +235,7 @@ int main( int argc, char *argv[] )
}
}
qCDebug(LOG) << "documentation directories:" << localDoc;
Q_FOREACH ( const QString &path, localDoc ) {
for ( const QString &path : qAsConst(localDoc) ) {
walkFiles( path, std_lang, db, xgen, &handledDocuments );
}
......
......@@ -39,7 +39,7 @@ Xapian::Query queryFromWordlist( const QString& words, Xapian::Query::op op )
QVector<std::string> wordlist;
const QStringList splitlist = words.split( QLatin1Char( '+' ) );
wordlist.reserve( splitlist.size() );
Q_FOREACH ( const QString& word, splitlist ) {
for ( const QString& word : splitlist ) {
wordlist.append( word.toStdString() );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment