diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp index 0855b028d6..fa3c97c487 100644 --- a/src/csync/csync_exclude.cpp +++ b/src/csync/csync_exclude.cpp @@ -733,7 +733,8 @@ void ExcludedFiles::prepare(const BasePathString & basePath) pattern.append(appendMe); }; - for (auto exclude : _allExcludes.value(basePath)) { + const auto &allValues = _allExcludes.value(basePath); + for (auto exclude : allValues) { if (exclude[0] == QLatin1Char('\n')) continue; // empty line if (exclude[0] == QLatin1Char('\r')) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 80bd36c6dd..8923eefe08 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -217,7 +217,7 @@ bool AccountManager::restoreFromLegacySettings() legacyLocations.append({legacyCfgFileParentFolder + unbrandedCfgFileNamePath, legacyCfgFileGrandParentFolder + unbrandedCfgFileRelativePath}); } - for (const auto &configFile : legacyLocations) { + for (const auto &configFile : std::as_const(legacyLocations)) { auto oCSettings = std::make_unique(configFile, QSettings::IniFormat); if (oCSettings->status() != QSettings::Status::NoError) { qCInfo(lcAccountManager) << "Error reading legacy configuration file" << oCSettings->status(); @@ -699,7 +699,7 @@ void AccountManager::deleteAccount(OCC::AccountState *account) void AccountManager::updateServerHasValidSubscriptionConfig() { auto serverHasValidSubscription = false; - for (const auto &account : _accounts) { + for (const auto &account : std::as_const(_accounts)) { if (!account->account()->serverHasValidSubscription()) { continue; } diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 1e1d3b8c82..f246a70264 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -1143,7 +1143,8 @@ void AccountSettings::forgetEncryptionOnDeviceForAccount(const AccountPtr &accou void AccountSettings::migrateCertificateForAccount(const AccountPtr &account) { - for (const auto action : _ui->encryptionMessage->actions()) { + const auto &allActions = _ui->encryptionMessage->actions(); + for (const auto action : allActions) { _ui->encryptionMessage->removeAction(action); } @@ -1703,7 +1704,8 @@ void AccountSettings::setupE2eEncryption() void AccountSettings::forgetE2eEncryption() { - for (const auto action : _ui->encryptionMessage->actions()) { + const auto &allActions = _ui->encryptionMessage->actions(); + for (const auto action : allActions) { _ui->encryptionMessage->removeAction(action); } _ui->encryptionMessage->setText({}); diff --git a/src/gui/application.cpp b/src/gui/application.cpp index d2951a1f1d..f2f6a0503e 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -293,7 +293,8 @@ Application::Application(int &argc, char **argv) if (_theme->doNotUseProxy()) { ConfigFile().setProxyType(QNetworkProxy::NoProxy); - for (const auto &accountState : AccountManager::instance()->accounts()) { + const auto &allAccounts = AccountManager::instance()->accounts(); + for (const auto &accountState : allAccounts) { if (accountState && accountState->account()) { accountState->account()->setProxyType(QNetworkProxy::NoProxy); } @@ -401,7 +402,8 @@ Application::Application(int &argc, char **argv) if (_theme->doNotUseProxy()) { ConfigFile().setProxyType(QNetworkProxy::NoProxy); - for (const auto &accountState : AccountManager::instance()->accounts()) { + const auto &allAccounts = AccountManager::instance()->accounts(); + for (const auto &accountState : allAccounts) { if (accountState && accountState->account()) { accountState->account()->setProxyType(QNetworkProxy::NoProxy); } diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 3ea2641721..17d693bf71 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -385,7 +385,8 @@ void FolderMan::backwardMigrationSettingsKeys(QStringList *deleteKeys, QStringLi const auto foldersVersion = settings->value(QLatin1String(settingsVersionC), 1).toInt(); qCInfo(lcFolderMan) << "FolderDefinition::maxSettingsVersion:" << FolderDefinition::maxSettingsVersion(); if (foldersVersion <= maxFoldersVersion) { - for (const auto &folderAlias : settings->childGroups()) { + const auto &childGroups = settings->childGroups(); + for (const auto &folderAlias : childGroups) { settings->beginGroup(folderAlias); const auto folderVersion = settings->value(QLatin1String(settingsVersionC), 1).toInt(); if (folderVersion > FolderDefinition::maxSettingsVersion()) { @@ -591,7 +592,7 @@ void FolderMan::setupLegacyFolder(const QString &fileNamePath, AccountState *acc legacyBlacklist << settings.value(QLatin1String("blackList")).toStringList(); if (!legacyBlacklist.isEmpty()) { qCInfo(lcFolderMan) << "Legacy selective sync list found:" << legacyBlacklist; - for (const auto &legacyFolder : legacyBlacklist) { + for (const auto &legacyFolder : std::as_const(legacyBlacklist)) { folder->migrateBlackListPath(legacyFolder); } settings.remove(QLatin1String("blackList")); diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 352e1d56fe..f6e341a58d 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -333,7 +333,7 @@ bool FolderStatusModel::setData(const QModelIndex &index, const QVariant &value, const auto parentInfo = infoForIndex(parent); if (parentInfo && parentInfo->_checked != Qt::Checked) { auto hasUnchecked = false; - for (const auto &sub : parentInfo->_subs) { + for (const auto &sub : std::as_const(parentInfo->_subs)) { if (sub._checked != Qt::Checked) { hasUnchecked = true; break; @@ -714,7 +714,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list) } std::set selectiveSyncUndecidedSet; // not QSet because it's not sorted - for (const auto &str : selectiveSyncUndecidedList) { + for (const auto &str : std::as_const(selectiveSyncUndecidedList)) { if (str.startsWith(parentInfo->_path) || parentInfo->_path == QLatin1String("/")) { selectiveSyncUndecidedSet.insert(str); } @@ -732,7 +732,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list) QVector newSubs; newSubs.reserve(sortedSubfolders.size()); - for (const auto &path : sortedSubfolders) { + for (const auto &path : std::as_const(sortedSubfolders)) { auto relativePath = path.mid(pathToRemove.size()); if (parentInfo->_folder->isFileExcludedRelative(relativePath)) { continue; @@ -781,7 +781,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list) } else if (parentInfo->_checked == Qt::Checked) { newInfo._checked = Qt::Checked; } else { - for (const auto &str : selectiveSyncBlackList) { + for (const auto &str : std::as_const(selectiveSyncBlackList)) { if (str == relativePath || str == QLatin1String("/")) { newInfo._checked = Qt::Unchecked; break; @@ -940,7 +940,7 @@ void FolderStatusModel::slotApplySelectiveSync() } //The part that changed should not be read from the DB on next sync because there might be new folders // (the ones that are no longer in the blacklist) - for (const auto &it : changes) { + for (const auto &it : std::as_const(changes)) { folder->journalDb()->schedulePathForRemoteDiscovery(it); folder->schedulePathForLocalDiscovery(it); } @@ -1227,7 +1227,7 @@ void FolderStatusModel::slotSyncAllPendingBigFolders() qCWarning(lcFolderStatus) << "Could not read selective sync list from db."; return; } - for (const auto &undecidedFolder : undecidedList) { + for (const auto &undecidedFolder : std::as_const(undecidedList)) { blackList.removeAll(undecidedFolder); } folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blackList); @@ -1250,7 +1250,7 @@ void FolderStatusModel::slotSyncAllPendingBigFolders() } // The part that changed should not be read from the DB on next sync because there might be new folders // (the ones that are no longer in the blacklist) - for (const auto &it : undecidedList) { + for (const auto &it : std::as_const(undecidedList)) { folder->journalDb()->schedulePathForRemoteDiscovery(it); folder->schedulePathForLocalDiscovery(it); } diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index 29301107a1..3dc10ad198 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -360,7 +360,7 @@ void FolderWizardRemotePath::slotUpdateDirectories(const QStringList &list) } QStringList sortedList = list; Utility::sortFilenames(sortedList); - for (auto path : sortedList) { + for (auto path : std::as_const(sortedList)) { path.remove(webdavFolder); // Don't allow to select subfolders of encrypted subfolders diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 177f1c6ffc..eb12c92d8f 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -287,7 +287,8 @@ void ownCloudGui::slotComputeOverallSyncStatus() bool allPaused = true; QVector problemAccounts; - for (const auto &account : AccountManager::instance()->accounts()) { + const auto &allAccounts = AccountManager::instance()->accounts(); + for (const auto &account : allAccounts) { if (!account->isSignedOut()) { allSignedOut = false; } @@ -308,7 +309,8 @@ void ownCloudGui::slotComputeOverallSyncStatus() QList idleFileProviderAccounts; if (Mac::FileProvider::fileProviderAvailable()) { - for (const auto &accountState : AccountManager::instance()->accounts()) { + const auto &allAccounts = AccountManager::instance()->accounts(); + for (const auto &accountState : allAccounts) { const auto account = accountState->account(); const auto userIdAtHostWithPort = account->userIdAtHostWithPort(); if (!Mac::FileProviderSettingsController::instance()->vfsEnabledForAccount(userIdAtHostWithPort)) { diff --git a/src/gui/selectivesyncdialog.cpp b/src/gui/selectivesyncdialog.cpp index 94869c4724..e9effaf461 100644 --- a/src/gui/selectivesyncdialog.cpp +++ b/src/gui/selectivesyncdialog.cpp @@ -525,7 +525,7 @@ void SelectiveSyncDialog::accept() //The part that changed should not be read from the DB on next sync because there might be new folders // (the ones that are no longer in the blacklist) auto blackListSet = QSet{blackList.begin(), blackList.end()}; - auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet); + const auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet); for (const auto &it : changes) { _folder->journalDb()->schedulePathForRemoteDiscovery(it); _folder->schedulePathForLocalDiscovery(it); diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index d940702117..e48ccf75a9 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -335,7 +335,8 @@ void SettingsDialog::customizeStyle() QString background(palette().base().color().name()); _toolBar->setStyleSheet(TOOLBAR_CSS().arg(background, dark, highlightColor, highlightTextColor)); - for (const auto a : _actionGroup->actions()) { + const auto &allActions = _actionGroup->actions(); + for (const auto a : allActions) { QIcon icon = Theme::createColorAwareIcon(a->property("iconPath").toString(), palette()); a->setIcon(icon); auto *btn = qobject_cast(_toolBar->widgetForAction(a)); diff --git a/src/gui/sharemanager.cpp b/src/gui/sharemanager.cpp index fdacac691c..3caee2fc56 100644 --- a/src/gui/sharemanager.cpp +++ b/src/gui/sharemanager.cpp @@ -465,7 +465,10 @@ void ShareManager::createShare(const QString &path, [=, this](const QJsonDocument &reply) { // Find existing share permissions (if this was shared with us) Share::Permissions existingPermissions = SharePermissionAll; - for (const auto &element : reply.object()["ocs"].toObject()["data"].toArray()) { + const auto &replyObject = reply.object(); + const auto &ocsObject = replyObject["ocs"].toObject(); + const auto &dataArray = ocsObject["data"].toArray(); + for (const auto &element : dataArray) { auto map = element.toObject(); if (map["file_target"] == path) existingPermissions = Share::Permissions(map["permissions"].toInt()); @@ -554,7 +557,7 @@ void ShareManager::fetchSharedWithMe(const QString &path) const QList ShareManager::parseShares(const QJsonDocument &reply) const { qDebug() << reply; - auto tmpShares = reply.object().value("ocs").toObject().value("data").toArray(); + const auto tmpShares = reply.object().value("ocs").toObject().value("data").toArray(); const QString versionString = _account->serverVersion(); qCDebug(lcSharing) << versionString << "Fetched" << tmpShares.count() << "shares"; diff --git a/src/gui/sslerrordialog.cpp b/src/gui/sslerrordialog.cpp index 9b85245aee..cc0397f295 100644 --- a/src/gui/sslerrordialog.cpp +++ b/src/gui/sslerrordialog.cpp @@ -44,7 +44,7 @@ bool SslDialogErrorHandler::handleErrors(QList errors, const QSslConf // Check if this host has an active HSTS policy auto hstsPolicies = qnam->strictTransportSecurityHosts(); - for (const auto &policy : hstsPolicies) { + for (const auto &policy : std::as_const(hstsPolicies)) { if (policy.host() == host && !policy.isExpired()) { // HSTS is active for this host, don't show the dialog qCInfo(lcSslErrorDialog) << "SSL certificate error, but HSTS is active. Rejecting connection."; @@ -152,7 +152,7 @@ bool SslErrorDialog::checkFailingCertsKnown(const QList &errors) msg += QL("

") + tr("Cannot connect securely to %1:").arg(host) + QL("

"); // loop over the unknown certs and line up their errors. msg += QL("
"); - for (const auto &cert : _unknownCerts) { + for (const auto &cert : std::as_const(_unknownCerts)) { msg += QL("
"); // add the errors for this cert for (const auto &err : errors) { diff --git a/src/gui/tray/activitydata.cpp b/src/gui/tray/activitydata.cpp index 72475b6dc4..e4dc423264 100644 --- a/src/gui/tray/activitydata.cpp +++ b/src/gui/tray/activitydata.cpp @@ -165,7 +165,7 @@ OCC::Activity Activity::fromActivityJson(const QJsonObject &json, const AccountP } auto actions = json.value("actions").toArray(); - for (const auto &action : actions) { + for (const auto &action : std::as_const(actions)) { activity._links.append(ActivityLink::createFomJsonObject(action.toObject())); } diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index 66ff5e8093..cd6f58b837 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -664,7 +664,7 @@ void ActivityListModel::removeActivityFromActivityList(const Activity &activity) void ActivityListModel::removeOutdatedNotifications(const OCC::ActivityList &receivedNotifications) { ActivityList activitiesToRemove; - for (const auto &activity : _finalList) { + for (const auto &activity : std::as_const(_finalList)) { if (activity._type != Activity::NotificationType || receivedNotifications.contains(activity)) { continue; } diff --git a/src/gui/tray/activitylistmodel.h b/src/gui/tray/activitylistmodel.h index d04c90a4df..d200baa6ed 100644 --- a/src/gui/tray/activitylistmodel.h +++ b/src/gui/tray/activitylistmodel.h @@ -93,8 +93,8 @@ public: [[nodiscard]] bool canFetchMore(const QModelIndex &) const override; - ActivityList activityList() { return _finalList; } - ActivityList errorsList() { return _notificationErrorsLists; } + [[nodiscard]] const ActivityList& activityList() const { return _finalList; } + [[nodiscard]] const ActivityList& errorsList() const { return _notificationErrorsLists; } [[nodiscard]] AccountState *accountState() const; diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 549cb2797c..db883e7ed7 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -1288,7 +1288,7 @@ void User::slotGroupFoldersFetched(QNetworkReply *reply) const auto obj = json.object().toVariantMap(); const auto groupFolders = obj["ocs"].toMap()["data"].toMap(); - for (const auto &groupFolder : groupFolders.values()) { + for (const auto &groupFolder : groupFolders) { const auto groupFolderInfo = groupFolder.toMap(); const auto mountPoint = groupFolderInfo.value(QStringLiteral("mount_point"), {}).toString(); parseNewGroupFolderPath(mountPoint); @@ -1836,7 +1836,8 @@ void UserAppsModel::buildAppList() if (UserModel::instance()->appList().count() > 0) { const auto talkApp = UserModel::instance()->currentUser()->talkApp(); - for (const auto &app : UserModel::instance()->appList()) { + const auto &allApps = UserModel::instance()->appList(); + for (const auto &app : allApps) { // Filter out Talk because we have a dedicated button for it if (talkApp && app->id() == talkApp->id() && !UserModel::instance()->currentUser()->isNcAssistantEnabled()) { continue; diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 993c55a770..e7bde80a84 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -666,7 +666,7 @@ void Account::slotHandleSslErrors(QNetworkReply *reply, QList errors) return; // Mark all involved certificates as rejected, so we don't ask the user again. - for (const auto &error : errors) { + for (const auto &error : std::as_const(errors)) { if (!_rejectedCertificates.contains(error.certificate())) { _rejectedCertificates.append(error.certificate()); } @@ -986,7 +986,8 @@ void Account::slotDirectEditingRecieved(const QJsonDocument &json) auto data = json.object().value("ocs").toObject().value("data").toObject(); const auto editors = data.value("editors").toObject(); - for (const auto &editorKey : editors.keys()) { + const auto &allKeys = editors.keys(); + for (const auto &editorKey : allKeys) { auto editor = editors.value(editorKey).toObject(); const QString id = editor.value("id").toString(); @@ -998,11 +999,11 @@ void Account::slotDirectEditingRecieved(const QJsonDocument &json) auto *directEditor = new DirectEditor(id, name); - for (const auto &mimeType : mimeTypes) { + for (const auto &mimeType : std::as_const(mimeTypes)) { directEditor->addMimetype(mimeType.toString().toLatin1()); } - for (const auto &optionalMimeType : optionalMimeTypes) { + for (const auto &optionalMimeType : std::as_const(optionalMimeTypes)) { directEditor->addOptionalMimetype(optionalMimeType.toString().toLatin1()); } diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp index 2e32527f68..9ce1b567fa 100644 --- a/src/libsync/clientsideencryption.cpp +++ b/src/libsync/clientsideencryption.cpp @@ -3095,7 +3095,8 @@ QList CertificateInformation::verify() const auto result = QSslCertificate::verify({_certificate}); auto hasNeededExtendedKeyUsageExtension = false; - for (const auto &oneExtension : _certificate.extensions()) { + const auto &allExtensions = _certificate.extensions(); + for (const auto &oneExtension : allExtensions) { if (oneExtension.oid() == QStringLiteral("2.5.29.37")) { const auto extendedKeyUsageList = oneExtension.value().toList(); for (const auto &oneExtendedKeyUsageValue : extendedKeyUsageList) { diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp index 2076133625..4863eb13db 100644 --- a/src/libsync/discoveryphase.cpp +++ b/src/libsync/discoveryphase.cpp @@ -224,7 +224,7 @@ void DiscoveryPhase::markPermanentDeletionRequests() { // since we don't know in advance which files/directories need to be permanently deleted, // we have to look through all of them at the end of the run - for (const auto &originalPath : _permanentDeletionRequests) { + for (const auto &originalPath : std::as_const(_permanentDeletionRequests)) { const auto it = _deletedItem.find(originalPath); if (it == _deletedItem.end()) { qCWarning(lcDiscovery) << "didn't find an item for" << originalPath << "(yet)"; @@ -591,7 +591,7 @@ void DiscoverySingleDirectoryJob::metadataReceived(const QJsonDocument &json, in // hence, we need to find its path and pass to any subfolder's metadata, so it will fetch the top level metadata when needed // see https://github.com/nextcloud/end_to_end_encryption_rfc/blob/v2.1/RFC.md auto topLevelFolderPath = QStringLiteral("/"); - for (const QString &topLevelPath : _topLevelE2eeFolderPaths) { + for (const QString &topLevelPath : std::as_const(_topLevelE2eeFolderPaths)) { if (_subPath == topLevelPath) { topLevelFolderPath = QStringLiteral("/"); break; diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index c526e7d700..036789880c 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -749,7 +749,7 @@ void OwncloudPropagator::processE2eeMetadataMigration(const SyncFileItemPtr &ite if (foundDirectory.second) { topLevelitem = foundDirectory.second->_item; if (!foundDirectory.second->_subJobs._jobsToDo.isEmpty()) { - for (const auto jobToDo : foundDirectory.second->_subJobs._jobsToDo) { + for (const auto jobToDo : std::as_const(foundDirectory.second->_subJobs._jobsToDo)) { if (const auto foundExistingUpdateMigratedE2eeMetadataJob = qobject_cast(jobToDo)) { existingUpdateJob = foundExistingUpdateMigratedE2eeMetadataJob; break; diff --git a/test/syncenginetestutils.cpp b/test/syncenginetestutils.cpp index 589e190bb0..f6cac33740 100644 --- a/test/syncenginetestutils.cpp +++ b/test/syncenginetestutils.cpp @@ -404,7 +404,8 @@ FakePropfindReply::FakePropfindReply(FileInfo &remoteRootFileInfo, QNetworkAcces xml.writeEndElement(); // resourcetype auto totalSize = 0; - for (const auto &child : fileInfo.children.values()) { + const auto &allValues = fileInfo.children.values(); + for (const auto &child : allValues) { totalSize += child.size; } xml.writeTextElement(ocUri, QStringLiteral("size"), QString::number(totalSize)); @@ -573,13 +574,13 @@ QVector FakePutMultiFileReply::performMultiPart(FileInfo &remoteRoot const QString boundaryValue = QStringLiteral("--") + contentType.mid(boundaryPosition, contentType.length() - boundaryPosition - 1) + QStringLiteral("\r\n"); auto stringPutPayloadRef = QString{stringPutPayload}.left(stringPutPayload.size() - 2 - boundaryValue.size()); auto allParts = stringPutPayloadRef.split(boundaryValue, Qt::SkipEmptyParts); - for (const auto &onePart : allParts) { + for (const auto &onePart : std::as_const(allParts)) { auto headerEndPosition = onePart.indexOf(QStringLiteral("\r\n\r\n")); auto onePartHeaderPart = onePart.left(headerEndPosition); auto onePartBody = onePart.mid(headerEndPosition + 4, onePart.size() - headerEndPosition - 6); auto onePartHeaders = onePartHeaderPart.split(QStringLiteral("\r\n")); QMap allHeaders; - for(const auto &oneHeader : onePartHeaders) { + for(const auto &oneHeader : std::as_const(onePartHeaders)) { auto headerParts = oneHeader.split(QStringLiteral(": ")); allHeaders[headerParts.at(0).toLower()] = headerParts.at(1); } @@ -1438,7 +1439,8 @@ void FakeFolder::toDisk(QDir &dir, const FileInfo &templateFi) void FakeFolder::fromDisk(QDir &dir, FileInfo &templateFi) { - for(const auto &diskChild : dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot)) { + const auto &allEntries = dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot); + for(const auto &diskChild : allEntries) { if (diskChild.isDir()) { QDir subDir = dir; subDir.cd(diskChild.fileName()); diff --git a/test/testfolderwatcher.cpp b/test/testfolderwatcher.cpp index d3d567a837..f14c91a6c0 100644 --- a/test/testfolderwatcher.cpp +++ b/test/testfolderwatcher.cpp @@ -287,7 +287,7 @@ private slots: // verify that office files for locking got detected by the watcher QScopedPointer locksImposedSpy(new QSignalSpy(_watcher.data(), &FolderWatcher::filesLockImposed)); - for (const auto &officeFile : listOfOfficeFiles) { + for (const auto &officeFile : std::as_const(listOfOfficeFiles)) { touch(officeFile); QVERIFY(waitForPathChanged(officeFile)); } @@ -328,7 +328,7 @@ private slots: for (const auto &officeLockFile : listOfOfficeLockFiles) { rm(officeLockFile); } - for (const auto &officeFile : listOfOfficeFiles) { + for (const auto &officeFile : std::as_const(listOfOfficeFiles)) { rm(officeFile); } } @@ -343,7 +343,7 @@ private slots: const QStringList listOfOfficeLockFiles = {QString(_rootPath + "/.~lock.document.docx#"), QString(_rootPath + "/.~lock.document.odt#")}; - for (const auto &officeFile : listOfOfficeFiles) { + for (const auto &officeFile : std::as_const(listOfOfficeFiles)) { touch(officeFile); } for (const auto &officeLockFile : listOfOfficeLockFiles) { @@ -386,7 +386,7 @@ private slots: } // cleanup - for (const auto &officeFile : listOfOfficeFiles) { + for (const auto &officeFile : std::as_const(listOfOfficeFiles)) { rm(officeFile); } for (const auto &officeLockFile : listOfOfficeLockFiles) { diff --git a/test/testsecurefiledrop.cpp b/test/testsecurefiledrop.cpp index 4b796c963c..016f5aadb2 100644 --- a/test/testsecurefiledrop.cpp +++ b/test/testsecurefiledrop.cpp @@ -93,7 +93,7 @@ private slots: QJsonObject fakeFileDropPart; QJsonArray fileDropUsers; - for (const auto &folderUser : metadata->_folderUsers) { + for (const auto &folderUser : std::as_const(metadata->_folderUsers)) { QJsonObject fileDropUser; fileDropUser.insert("userId", folderUser.userId); fileDropUser.insert("encryptedFiledropKey", QString::fromUtf8(folderUser.encryptedMetadataKey.toBase64())); diff --git a/test/testsyncconflict.cpp b/test/testsyncconflict.cpp index 75e7478ed9..5b97641a81 100644 --- a/test/testsyncconflict.cpp +++ b/test/testsyncconflict.cpp @@ -309,7 +309,7 @@ private slots: auto conflicts = findConflicts(fakeFolder.currentLocalState().children["A"]); QByteArray a1conflict; QByteArray a2conflict; - for (const auto & conflict : conflicts) { + for (const auto & conflict : std::as_const(conflicts)) { if (conflict.contains("a1")) a1conflict = conflict.toUtf8(); if (conflict.contains("a2")) @@ -564,7 +564,7 @@ private slots: QVERIFY(conflicts.size() == 2); QVERIFY(conflicts[0].contains("A (conflicted copy")); QVERIFY(conflicts[1].contains("B (conflicted copy")); - for (const auto& conflict : conflicts) + for (const auto& conflict : std::as_const(conflicts)) QDir(fakeFolder.localPath() + conflict).removeRecursively(); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); @@ -602,7 +602,7 @@ private slots: auto conflicts = findConflicts(fakeFolder.currentLocalState()); QVERIFY(conflicts.size() == 1); QVERIFY(conflicts[0].contains("A (conflicted copy")); - for (const auto& conflict : conflicts) + for (const auto& conflict : std::as_const(conflicts)) QDir(fakeFolder.localPath() + conflict).removeRecursively(); QVERIFY(fakeFolder.syncEngine().isAnotherSyncNeeded() == ImmediateFollowUp); diff --git a/test/testsyncmove.cpp b/test/testsyncmove.cpp index e16bc52fac..62d6217d81 100644 --- a/test/testsyncmove.cpp +++ b/test/testsyncmove.cpp @@ -666,7 +666,7 @@ private slots: auto currentLocal = fakeFolder.currentLocalState(); auto conflicts = findConflicts(currentLocal.children["A4"]); QCOMPARE(conflicts.size(), 1); - for (const auto& c : conflicts) { + for (const auto& c : std::as_const(conflicts)) { QCOMPARE(currentLocal.find(c)->contentChar, 'L'); local.remove(c); }