Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksey Lysenko <lysenkoalexmail@gmail.com>2021-06-16 12:38:18 +0300
committerGitHub <noreply@github.com>2021-06-16 12:38:18 +0300
commit4715f63580f64d7baaba072f6c69632ccaa8a187 (patch)
tree201f42256d996e8aad25a70e929821d85e85011c /src
parent09b538f4887d77685983dcb71d1ef6c1075a1b49 (diff)
Remove possible qt containers detach (#8727)
* Replaced obsolete foreach-loops with for-loops * Added a copy of queries into SqlDatabase::close * Used const reference to avoid unneeded copying * Fixed Qt containers possible detach within for-loop * Removed unneeded copies before for-loops
Diffstat (limited to 'src')
-rw-r--r--src/cmd/cmd.cpp4
-rw-r--r--src/cmd/simplesslerrorhandler.cpp2
-rw-r--r--src/common/ownsql.cpp4
-rw-r--r--src/common/syncjournaldb.cpp6
-rw-r--r--src/csync/csync_exclude.cpp4
-rw-r--r--src/gui/accountmanager.cpp18
-rw-r--r--src/gui/accountsettings.cpp2
-rw-r--r--src/gui/activitywidget.cpp3
-rw-r--r--src/gui/application.cpp8
-rw-r--r--src/gui/folder.cpp4
-rw-r--r--src/gui/folderman.cpp49
-rw-r--r--src/gui/folderstatusdelegate.cpp2
-rw-r--r--src/gui/folderstatusmodel.cpp27
-rw-r--r--src/gui/folderwatcher.cpp2
-rw-r--r--src/gui/folderwizard.cpp4
-rw-r--r--src/gui/generalsettings.cpp2
-rw-r--r--src/gui/ignorelisteditor.cpp4
-rw-r--r--src/gui/lockwatcher.cpp2
-rw-r--r--src/gui/navigationpanehelper.cpp6
-rw-r--r--src/gui/notificationwidget.cpp2
-rw-r--r--src/gui/ocsjob.cpp2
-rw-r--r--src/gui/openfilemanager.cpp10
-rw-r--r--src/gui/owncloudgui.cpp43
-rw-r--r--src/gui/selectivesyncdialog.cpp12
-rw-r--r--src/gui/servernotificationhandler.cpp3
-rw-r--r--src/gui/settingsdialog.cpp5
-rw-r--r--src/gui/sharee.cpp30
-rw-r--r--src/gui/sharelinkwidget.cpp2
-rw-r--r--src/gui/sharemanager.cpp9
-rw-r--r--src/gui/shareusergroupwidget.cpp9
-rw-r--r--src/gui/sslbutton.cpp2
-rw-r--r--src/gui/sslerrordialog.cpp4
-rw-r--r--src/libsync/account.cpp6
-rw-r--r--src/libsync/capabilities.cpp6
-rw-r--r--src/libsync/cookiejar.cpp2
-rw-r--r--src/libsync/discovery.cpp16
-rw-r--r--src/libsync/logger.cpp4
-rw-r--r--src/libsync/owncloudpropagator.cpp8
-rw-r--r--src/libsync/owncloudpropagator.h2
-rw-r--r--src/libsync/progressdispatcher.cpp2
-rw-r--r--src/libsync/propagateupload.cpp2
-rw-r--r--src/libsync/propagateuploadng.cpp9
-rw-r--r--src/libsync/propagateuploadv1.cpp4
-rw-r--r--src/libsync/propagatorjobs.cpp2
-rw-r--r--src/libsync/syncengine.cpp18
-rw-r--r--src/libsync/syncfilestatustracker.cpp2
46 files changed, 188 insertions, 181 deletions
diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp
index 06f8c6b2e..4d322cff1 100644
--- a/src/cmd/cmd.cpp
+++ b/src/cmd/cmd.cpp
@@ -104,8 +104,8 @@ void selectiveSyncFixup(OCC::SyncJournalDb *journal, const QStringList &newList)
auto oldBlackListSet = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok).toSet();
if (ok) {
auto blackListSet = newList.toSet();
- auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet);
- foreach (const auto &it, changes) {
+ const auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet);
+ for (const auto &it : changes) {
journal->schedulePathForRemoteDiscovery(it);
}
diff --git a/src/cmd/simplesslerrorhandler.cpp b/src/cmd/simplesslerrorhandler.cpp
index b25e9958f..48a199773 100644
--- a/src/cmd/simplesslerrorhandler.cpp
+++ b/src/cmd/simplesslerrorhandler.cpp
@@ -27,7 +27,7 @@ bool SimpleSslErrorHandler::handleErrors(QList<QSslError> errors, const QSslConf
return false;
}
- foreach (QSslError error, errors) {
+ for (const auto &error : qAsConst(errors)) {
certs->append(error.certificate());
}
return true;
diff --git a/src/common/ownsql.cpp b/src/common/ownsql.cpp
index ed27ba486..0877b2787 100644
--- a/src/common/ownsql.cpp
+++ b/src/common/ownsql.cpp
@@ -190,7 +190,9 @@ QString SqlDatabase::error() const
void SqlDatabase::close()
{
if (_db) {
- foreach (auto q, _queries) {
+ // we need a copy because query is removed from a set in finish()
+ const auto queries = _queries;
+ for (auto *q : queries) {
q->finish();
}
SQLITE_DO(sqlite3_close(_db));
diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp
index 4320073ba..dffdf44ae 100644
--- a/src/common/syncjournaldb.cpp
+++ b/src/common/syncjournaldb.cpp
@@ -872,7 +872,7 @@ bool SyncJournalDb::setFileRecord(const SyncJournalFileRecord &_record)
if (!_etagStorageFilter.isEmpty()) {
// If we are a directory that should not be read from db next time, don't write the etag
QByteArray prefix = record._path + "/";
- foreach (const QByteArray &it, _etagStorageFilter) {
+ for (const auto &it : qAsConst(_etagStorageFilter)) {
if (it.startsWith(prefix)) {
qCInfo(lcDb) << "Filtered writing the etag of" << prefix << "because it is a prefix of" << it;
record._etag = "_invalid_";
@@ -1314,7 +1314,7 @@ static bool deleteBatch(SqlQuery &query, const QStringList &entries, const QStri
qCDebug(lcDb) << "Removing stale" << name << "entries:" << entries.join(QStringLiteral(", "));
// FIXME: Was ported from execBatch, check if correct!
- foreach (const QString &entry, entries) {
+ for (const auto &entry : entries) {
query.reset_and_clear_bindings();
query.bindValue(1, entry);
if (!query.exec()) {
@@ -1769,7 +1769,7 @@ void SyncJournalDb::setSelectiveSyncList(SyncJournalDb::SelectiveSyncListType ty
}
SqlQuery insQuery("INSERT INTO selectivesync VALUES (?1, ?2)", _db);
- foreach (const auto &path, list) {
+ for (const auto &path : list) {
insQuery.reset_and_clear_bindings();
insQuery.bindValue(1, path);
insQuery.bindValue(2, int(type));
diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp
index 6fbfee3f9..a72306eed 100644
--- a/src/csync/csync_exclude.cpp
+++ b/src/csync/csync_exclude.cpp
@@ -265,7 +265,7 @@ bool ExcludedFiles::reloadExcludeFiles()
{
_allExcludes.clear();
bool success = true;
- foreach (const QString &file, _excludeFiles) {
+ for (const auto &file : qAsConst(_excludeFiles)) {
QFile f(file);
if (!f.open(QIODevice::ReadOnly)) {
success = false;
@@ -610,7 +610,7 @@ void ExcludedFiles::prepare()
pattern.append(appendMe);
};
- for (auto exclude : _allExcludes) {
+ for (auto exclude : qAsConst(_allExcludes)) {
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 ac9e6ce5a..af522f8cd 100644
--- a/src/gui/accountmanager.cpp
+++ b/src/gui/accountmanager.cpp
@@ -84,13 +84,14 @@ bool AccountManager::restore()
}
// If there are no accounts, check the old format.
- if (settings->childGroups().isEmpty()
+ const auto &childGroups = settings->childGroups();
+ if (childGroups.isEmpty()
&& !settings->contains(QLatin1String(versionC))) {
restoreFromLegacySettings();
return true;
}
- foreach (const auto &accountId, settings->childGroups()) {
+ for (const auto &accountId : childGroups) {
settings->beginGroup(accountId);
if (!skipSettingsKeys.contains(settings->group())) {
if (auto acc = loadAccountHelper(*settings)) {
@@ -118,7 +119,8 @@ void AccountManager::backwardMigrationSettingsKeys(QStringList *deleteKeys, QStr
auto settings = ConfigFile::settingsWithGroup(QLatin1String(accountsC));
const int accountsVersion = settings->value(QLatin1String(versionC)).toInt();
if (accountsVersion <= maxAccountsVersion) {
- foreach (const auto &accountId, settings->childGroups()) {
+ const auto &childGroups = settings->childGroups();
+ for (const auto &accountId : childGroups) {
settings->beginGroup(accountId);
const int accountVersion = settings->value(QLatin1String(versionC), 1).toInt();
if (accountVersion > maxAccountVersion) {
@@ -192,7 +194,7 @@ void AccountManager::save(bool saveCredentials)
{
auto settings = ConfigFile::settingsWithGroup(QLatin1String(accountsC));
settings->setValue(QLatin1String(versionC), maxAccountsVersion);
- foreach (const auto &acc, _accounts) {
+ for (const auto &acc : qAsConst(_accounts)) {
settings->beginGroup(acc->account()->id());
saveAccountHelper(acc->account().data(), *settings, saveCredentials);
acc->writeToSettings(*settings);
@@ -339,7 +341,7 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings)
AccountStatePtr AccountManager::account(const QString &name)
{
- for (const auto &acc : _accounts) {
+ for (const auto &acc : qAsConst(_accounts)) {
if (acc->account()->displayName() == name) {
return acc;
}
@@ -395,16 +397,16 @@ AccountPtr AccountManager::createAccount()
void AccountManager::shutdown()
{
- auto accountsCopy = _accounts;
+ const auto accountsCopy = _accounts;
_accounts.clear();
- foreach (const auto &acc, accountsCopy) {
+ for (const auto &acc : accountsCopy) {
emit accountRemoved(acc.data());
}
}
bool AccountManager::isAccountIdAvailable(const QString &id) const
{
- foreach (const auto &acc, _accounts) {
+ for (const auto &acc : _accounts) {
if (acc->account()->id() == id) {
return false;
}
diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index 850719af0..08b0a13b9 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -967,7 +967,7 @@ void AccountSettings::refreshSelectiveSyncStatus()
}
bool ok;
- const auto undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &ok);
+ const auto &undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &ok);
for (const auto &it : undecidedList) {
// FIXME: add the folder alias in a hoover hint.
// folder->alias() + QLatin1String("/")
diff --git a/src/gui/activitywidget.cpp b/src/gui/activitywidget.cpp
index 5e5014407..360de23d1 100644
--- a/src/gui/activitywidget.cpp
+++ b/src/gui/activitywidget.cpp
@@ -583,8 +583,7 @@ void ActivitySettings::slotRefresh(AccountState *ptr)
void ActivitySettings::slotRegularNotificationCheck()
{
- AccountManager *am = AccountManager::instance();
- foreach (AccountStatePtr a, am->accounts()) {
+ for (const auto &a : AccountManager::instance()->accounts()) {
slotRefresh(a.data());
}
}
diff --git a/src/gui/application.cpp b/src/gui/application.cpp
index d779c31ca..4fabe4856 100644
--- a/src/gui/application.cpp
+++ b/src/gui/application.cpp
@@ -122,7 +122,7 @@ bool Application::configVersionMigration()
settings->endGroup();
// Wipe confusing keys from the future, ignore the others
- for (const auto &badKey : deleteKeys)
+ for (const auto &badKey : qAsConst(deleteKeys))
settings->remove(badKey);
}
@@ -302,7 +302,7 @@ Application::Application(int &argc, char **argv)
this, &Application::slotAccountStateAdded);
connect(AccountManager::instance(), &AccountManager::accountRemoved,
this, &Application::slotAccountStateRemoved);
- foreach (auto ai, AccountManager::instance()->accounts()) {
+ for (const auto &ai : AccountManager::instance()->accounts()) {
slotAccountStateAdded(ai.data());
}
@@ -403,8 +403,8 @@ void Application::slotSystemOnlineConfigurationChanged(QNetworkConfiguration cnf
void Application::slotCheckConnection()
{
- auto list = AccountManager::instance()->accounts();
- foreach (const auto &accountState, list) {
+ const auto &list = AccountManager::instance()->accounts();
+ for (const auto &accountState : list) {
AccountState::State state = accountState->state();
// Don't check if we're manually signed out or
diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp
index 63ab748b6..b5f8b5cfe 100644
--- a/src/gui/folder.cpp
+++ b/src/gui/folder.cpp
@@ -504,7 +504,7 @@ int Folder::slotDiscardDownloadProgress()
QSet<QString> keep_nothing;
const QVector<SyncJournalDb::DownloadInfo> deleted_infos =
_journal.getAndDeleteStaleDownloadInfos(keep_nothing);
- foreach (const SyncJournalDb::DownloadInfo &deleted_info, deleted_infos) {
+ for (const auto &deleted_info : deleted_infos) {
const QString tmppath = folderpath.filePath(deleted_info._tmpfile);
qCInfo(lcFolder) << "Deleting temporary file: " << tmppath;
FileSystem::remove(tmppath);
@@ -673,7 +673,7 @@ void Folder::saveToSettings() const
// True if the folder path appears in only one account
bool oneAccountOnly = true;
- foreach (Folder *other, FolderMan::instance()->map()) {
+ for (auto *other : FolderMan::instance()->map()) {
if (other != this && other->cleanPath() == this->cleanPath()) {
oneAccountOnly = false;
break;
diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp
index 386034637..a76b58850 100644
--- a/src/gui/folderman.cpp
+++ b/src/gui/folderman.cpp
@@ -176,7 +176,7 @@ int FolderMan::setupFolders()
skipSettingsKeys += deleteSettingsKeys;
auto settings = ConfigFile::settingsWithGroup(QLatin1String("Accounts"));
- const auto accountsWithSettings = settings->childGroups();
+ const auto &accountsWithSettings = settings->childGroups();
if (accountsWithSettings.isEmpty()) {
int r = setupFoldersMigration();
if (r > 0) {
@@ -187,7 +187,7 @@ int FolderMan::setupFolders()
qCInfo(lcFolderMan) << "Setup folders from settings file";
- foreach (const auto &account, AccountManager::instance()->accounts()) {
+ for (const auto &account : AccountManager::instance()->accounts()) {
const auto id = account->account()->id();
if (!accountsWithSettings.contains(id)) {
continue;
@@ -223,7 +223,8 @@ int FolderMan::setupFolders()
void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account, const QStringList &ignoreKeys, bool backwardsCompatible, bool foldersWithPlaceholders)
{
- foreach (const auto &folderAlias, settings.childGroups()) {
+ const auto &childGroups = settings.childGroups();
+ for (const auto &folderAlias : childGroups) {
// Skip folders with too-new version
settings.beginGroup(folderAlias);
if (ignoreKeys.contains(settings.group())) {
@@ -299,11 +300,11 @@ int FolderMan::setupFoldersMigration()
QDir dir(_folderConfigPath);
//We need to include hidden files just in case the alias starts with '.'
dir.setFilter(QDir::Files | QDir::Hidden);
- QStringList list = dir.entryList();
+ const auto &list = dir.entryList();
// Normally there should be only one account when migrating.
AccountState *accountState = AccountManager::instance()->accounts().value(0).data();
- foreach (const QString &alias, list) {
+ for (const auto &alias : list) {
Folder *f = setupFolderFromOldConfigFile(alias, accountState);
if (f) {
scheduleFolder(f);
@@ -325,7 +326,8 @@ void FolderMan::backwardMigrationSettingsKeys(QStringList *deleteKeys, QStringLi
settings->beginGroup(name);
const int foldersVersion = settings->value(QLatin1String(versionC), 1).toInt();
if (foldersVersion <= maxFoldersVersion) {
- foreach (const auto &folderAlias, settings->childGroups()) {
+ const auto &childGroups = settings->childGroups();
+ for (const auto &folderAlias : childGroups) {
settings->beginGroup(folderAlias);
const int folderVersion = settings->value(QLatin1String(versionC), 1).toInt();
if (folderVersion > FolderDefinition::maxSettingsVersion()) {
@@ -339,7 +341,8 @@ void FolderMan::backwardMigrationSettingsKeys(QStringList *deleteKeys, QStringLi
settings->endGroup();
};
- for (const auto &accountId : settings->childGroups()) {
+ const auto &childGroups = settings->childGroups();
+ for (const auto &accountId : childGroups) {
settings->beginGroup(accountId);
processSubgroup("Folders");
processSubgroup("Multifolders");
@@ -543,7 +546,7 @@ Folder *FolderMan::folder(const QString &alias)
void FolderMan::scheduleAllFolders()
{
- foreach (Folder *f, _folderMap) {
+ for (auto *f : _folderMap.values()) {
if (f && f->canSync()) {
scheduleFolder(f);
}
@@ -630,7 +633,7 @@ void FolderMan::slotRunOneEtagJob()
{
if (_currentEtagJob.isNull()) {
Folder *folder = nullptr;
- foreach (Folder *f, _folderMap) {
+ for (auto *f : qAsConst(_folderMap)) {
if (f->etagJob()) {
// Caveat: always grabs the first folder with a job, but we think this is Ok for now and avoids us having a seperate queue.
_currentEtagJob = f->etagJob();
@@ -663,7 +666,7 @@ void FolderMan::slotAccountStateChanged()
if (accountState->isConnected()) {
qCInfo(lcFolderMan) << "Account" << accountName << "connected, scheduling its folders";
- foreach (Folder *f, _folderMap) {
+ for (auto *f : _folderMap.values()) {
if (f
&& f->canSync()
&& f->accountState() == accountState) {
@@ -674,7 +677,7 @@ void FolderMan::slotAccountStateChanged()
qCInfo(lcFolderMan) << "Account" << accountName << "disconnected or paused, "
"terminating or descheduling sync folders";
- foreach (Folder *f, _folderMap) {
+ for (auto *f : _folderMap.values()) {
if (f
&& f->isSyncRunning()
&& f->accountState() == accountState) {
@@ -753,7 +756,7 @@ void FolderMan::startScheduledSyncSoon()
void FolderMan::slotStartScheduledFolderSync()
{
if (isAnySyncRunning()) {
- for (auto f : _folderMap) {
+ for (auto *f : qAsConst(_folderMap)) {
if (f->isSyncRunning())
qCInfo(lcFolderMan) << "Currently folder " << f->remoteUrl().toString() << " is running, wait for finish!";
}
@@ -799,7 +802,7 @@ void FolderMan::slotEtagPollTimerTimeout()
ConfigFile cfg;
auto polltime = cfg.remotePollInterval();
- foreach (Folder *f, _folderMap) {
+ for (auto *f : qAsConst(_folderMap)) {
if (!f) {
continue;
}
@@ -834,7 +837,7 @@ void FolderMan::slotRemoveFoldersForAccount(AccountState *accountState)
}
}
- foreach (const auto &f, foldersToRemove) {
+ for (const auto &f : foldersToRemove) {
removeFolder(f);
}
}
@@ -853,7 +856,7 @@ void FolderMan::slotServerVersionChanged(Account *account)
qCWarning(lcFolderMan) << "The server version is unsupported:" << account->serverVersion()
<< "pausing all folders on the account";
- foreach (auto &f, _folderMap) {
+ for (auto &f : qAsConst(_folderMap)) {
if (f->accountState()->account().data() == account) {
f->setSyncPaused(true);
}
@@ -871,7 +874,7 @@ void FolderMan::slotWatchedFileUnlocked(const QString &path)
void FolderMan::slotScheduleFolderByTime()
{
- foreach (auto &f, _folderMap) {
+ for (const auto &f : qAsConst(_folderMap)) {
// Never schedule if syncing is disabled or when we're currently
// querying the server for etags
if (!f->canSync() || f->etagJob()) {
@@ -990,7 +993,7 @@ Folder *FolderMan::addFolder(AccountState *accountState, const FolderDefinition
// Migration: The first account that's configured for a local folder shall
// be saved in a backwards-compatible way.
bool oneAccountOnly = true;
- foreach (Folder *other, FolderMan::instance()->map()) {
+ for (auto *other : map()) {
if (other != folder && other->cleanPath() == folder->cleanPath()) {
oneAccountOnly = false;
break;
@@ -1052,7 +1055,7 @@ Folder *FolderMan::folderForPath(const QString &path, QString *relativePath)
{
QString absolutePath = QDir::cleanPath(path) + QLatin1Char('/');
- foreach (Folder *folder, this->map()) {
+ for (auto *folder : map()) {
const QString folderPath = folder->cleanPath() + QLatin1Char('/');
if (absolutePath.startsWith(folderPath, (Utility::isWindows() || Utility::isMac()) ? Qt::CaseInsensitive : Qt::CaseSensitive)) {
@@ -1078,7 +1081,7 @@ QStringList FolderMan::findFileInLocalFolders(const QString &relPath, const Acco
if (!serverPath.startsWith('/'))
serverPath.prepend('/');
- foreach (Folder *folder, this->map()) {
+ for (auto *folder : map()) {
if (acc != nullptr && folder->accountState()->account() != acc) {
continue;
}
@@ -1211,7 +1214,7 @@ bool FolderMan::startFromScratch(const QString &localFolder)
void FolderMan::setDirtyProxy()
{
- foreach (Folder *f, _folderMap) {
+ for (auto *f : _folderMap.values()) {
if (f) {
if (f->accountState() && f->accountState()->account()
&& f->accountState()->account()->networkAccessManager()) {
@@ -1225,7 +1228,7 @@ void FolderMan::setDirtyProxy()
void FolderMan::setDirtyNetworkLimits()
{
- foreach (Folder *f, _folderMap) {
+ for (auto *f : _folderMap.values()) {
// set only in busy folders. Otherwise they read the config anyway.
if (f && f->isBusy()) {
f->setDirtyNetworkLimits();
@@ -1285,7 +1288,7 @@ TrayOverallStatusResult FolderMan::trayOverallStatus(const QList<Folder *> &fold
int runSeen = 0;
int various = 0;
- foreach (Folder *folder, folders) {
+ for (auto *folder : folders) {
SyncResult folderResult = folder->syncResult();
if (folder->syncPaused()) {
abortOrPausedSeen++;
@@ -1525,7 +1528,7 @@ void FolderMan::setIgnoreHiddenFiles(bool ignore)
{
// Note that the setting will revert to 'true' if all folders
// are deleted...
- foreach (Folder *folder, _folderMap) {
+ for (auto *folder : qAsConst(_folderMap)) {
folder->setIgnoreHiddenFiles(ignore);
folder->saveToSettings();
}
diff --git a/src/gui/folderstatusdelegate.cpp b/src/gui/folderstatusdelegate.cpp
index 2b652adf1..b8fdad152 100644
--- a/src/gui/folderstatusdelegate.cpp
+++ b/src/gui/folderstatusdelegate.cpp
@@ -277,7 +277,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
rect.width() - 2 * margin,
subFm.height());
- foreach (QString eText, texts) {
+ for (const auto &eText : texts) {
painter->drawText(QStyle::visualRect(option.direction, option.rect, textRect), textAlign,
subFm.elidedText(eText, Qt::ElideLeft, textRect.width()));
textRect.translate(0, textRect.height());
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp
index d0dffdb0d..4df47f6de 100644
--- a/src/gui/folderstatusmodel.cpp
+++ b/src/gui/folderstatusmodel.cpp
@@ -72,8 +72,7 @@ void FolderStatusModel::setAccountState(const AccountState *accountState)
connect(FolderMan::instance(), &FolderMan::scheduleQueueChanged,
this, &FolderStatusModel::slotFolderScheduleQueueChanged, Qt::UniqueConnection);
- auto folders = FolderMan::instance()->map();
- foreach (auto f, folders) {
+ for (const auto &f : FolderMan::instance()->map()) {
if (!accountState)
break;
if (f->accountState() != accountState)
@@ -299,7 +298,7 @@ bool FolderStatusModel::setData(const QModelIndex &index, const QVariant &value,
auto parentInfo = infoForIndex(parent);
if (parentInfo && parentInfo->_checked != Qt::Checked) {
bool hasUnchecked = false;
- foreach (const auto &sub, parentInfo->_subs) {
+ for (const auto &sub : qAsConst(parentInfo->_subs)) {
if (sub._checked != Qt::Checked) {
hasUnchecked = true;
break;
@@ -659,7 +658,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
}
std::set<QString> selectiveSyncUndecidedSet; // not QSet because it's not sorted
- foreach (const QString &str, selectiveSyncUndecidedList) {
+ for (const auto &str : qAsConst(selectiveSyncUndecidedList)) {
if (str.startsWith(parentInfo->_path) || parentInfo->_path == QLatin1String("/")) {
selectiveSyncUndecidedSet.insert(str);
}
@@ -675,7 +674,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
QVector<SubFolderInfo> newSubs;
newSubs.reserve(sortedSubfolders.size());
- foreach (const QString &path, sortedSubfolders) {
+ for (const auto &path : qAsConst(sortedSubfolders)) {
auto relativePath = path.mid(pathToRemove.size());
if (parentInfo->_folder->isFileExcludedRelative(relativePath)) {
continue;
@@ -698,7 +697,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
} else if (parentInfo->_checked == Qt::Checked) {
newInfo._checked = Qt::Checked;
} else {
- foreach (const QString &str, selectiveSyncBlackList) {
+ for (const auto &str : qAsConst(selectiveSyncBlackList)) {
if (str == relativePath || str == QLatin1String("/")) {
newInfo._checked = Qt::Unchecked;
break;
@@ -793,7 +792,7 @@ QStringList FolderStatusModel::createBlackList(const FolderStatusModel::SubFolde
} else {
// We did not load from the server so we re-use the one from the old black list
const QString path = root._path;
- foreach (const QString &it, oldBlackList) {
+ for (const auto &it : oldBlackList) {
if (it.startsWith(path))
result += it;
}
@@ -848,14 +847,14 @@ void FolderStatusModel::slotApplySelectiveSync()
folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, QStringList());
// do the sync if there were changes
- auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet);
+ const auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet);
if (!changes.isEmpty()) {
if (folder->isBusy()) {
folder->slotTerminateSync();
}
//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)
- foreach (const auto &it, changes) {
+ for (const auto &it : changes) {
folder->journalDb()->schedulePathForRemoteDiscovery(it);
folder->schedulePathForLocalDiscovery(it);
}
@@ -931,7 +930,7 @@ void FolderStatusModel::slotSetProgress(const ProgressInfo &progress)
quint64 estimatedUpBw = 0;
quint64 estimatedDownBw = 0;
QString allFilenames;
- foreach (const ProgressInfo::ProgressItem &citm, progress._currentItems) {
+ for (const auto &citm : progress._currentItems) {
if (curItemProgress == -1 || (ProgressInfo::isSizeDependent(citm._item)
&& biggerItemSize < citm._item._size)) {
curItemProgress = citm._progress.completed();
@@ -1108,7 +1107,7 @@ void FolderStatusModel::slotFolderSyncStateChange(Folder *f)
void FolderStatusModel::slotFolderScheduleQueueChanged()
{
// Update messages on waiting folders.
- foreach (Folder *f, FolderMan::instance()->map()) {
+ for (auto *f : FolderMan::instance()->map()) {
slotFolderSyncStateChange(f);
}
}
@@ -1128,7 +1127,7 @@ void FolderStatusModel::slotSyncAllPendingBigFolders()
auto folder = _folders.at(i)._folder;
bool ok;
- auto undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &ok);
+ const auto &undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &ok);
if (!ok) {
qCWarning(lcFolderStatus) << "Could not read selective sync list from db.";
return;
@@ -1145,7 +1144,7 @@ void FolderStatusModel::slotSyncAllPendingBigFolders()
qCWarning(lcFolderStatus) << "Could not read selective sync list from db.";
return;
}
- foreach (const auto &undecidedFolder, undecidedList) {
+ for (const auto &undecidedFolder : undecidedList) {
blackList.removeAll(undecidedFolder);
}
folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blackList);
@@ -1168,7 +1167,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)
- foreach (const auto &it, undecidedList) {
+ for (const auto &it : undecidedList) {
folder->journalDb()->schedulePathForRemoteDiscovery(it);
folder->schedulePathForLocalDiscovery(it);
}
diff --git a/src/gui/folderwatcher.cpp b/src/gui/folderwatcher.cpp
index 277a04c27..a307cca20 100644
--- a/src/gui/folderwatcher.cpp
+++ b/src/gui/folderwatcher.cpp
@@ -166,7 +166,7 @@ void FolderWatcher::changeDetected(const QStringList &paths)
}
qCInfo(lcFolderWatcher) << "Detected changes in paths:" << changedPaths;
- foreach (const QString &path, changedPaths) {
+ for (const auto &path : qAsConst(changedPaths)) {
emit pathChanged(path);
}
}
diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp
index 3d5c2658e..13e89c9f6 100644
--- a/src/gui/folderwizard.cpp
+++ b/src/gui/folderwizard.cpp
@@ -298,7 +298,7 @@ bool FolderWizardRemotePath::selectByPath(QString path)
QTreeWidgetItem *it = _ui.folderTreeWidget->topLevelItem(0);
if (!path.isEmpty()) {
const QStringList pathTrail = path.split(QLatin1Char('/'));
- foreach (const QString &path, pathTrail) {
+ for (const auto &path : pathTrail) {
if (!it) {
return false;
}
@@ -328,7 +328,7 @@ void FolderWizardRemotePath::slotUpdateDirectories(const QStringList &list)
}
QStringList sortedList = list;
Utility::sortFilenames(sortedList);
- foreach (QString path, sortedList) {
+ for (auto path : qAsConst(sortedList)) {
path.remove(webdavFolder);
QStringList paths = path.split('/');
if (paths.last().isEmpty())
diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp
index 44ebb36c1..1eabd6a5b 100644
--- a/src/gui/generalsettings.cpp
+++ b/src/gui/generalsettings.cpp
@@ -365,7 +365,7 @@ void GeneralSettings::loadLanguageNamesIntoDropdown()
QStringList availableTranslations(localesToLanguageNamesMap.values());
availableTranslations.sort(Qt::CaseInsensitive);
- for (const auto &i : availableTranslations) {
+ for (const auto &i : qAsConst(availableTranslations)) {
_ui->languageDropdown->addItem(i);
}
}
diff --git a/src/gui/ignorelisteditor.cpp b/src/gui/ignorelisteditor.cpp
index 0e1eee22c..0b11543cb 100644
--- a/src/gui/ignorelisteditor.cpp
+++ b/src/gui/ignorelisteditor.cpp
@@ -96,7 +96,7 @@ void IgnoreListEditor::slotUpdateLocalIgnoreList()
if (patternItem->data(isGlobalRole).toBool())
continue;
- QStringList skippedLines = patternItem->data(skippedLinesRole).toStringList();
+ const auto &skippedLines = patternItem->data(skippedLinesRole).toStringList();
for (const auto &line : skippedLines)
ignores.write(line.toUtf8() + '\n');
@@ -119,7 +119,7 @@ void IgnoreListEditor::slotUpdateLocalIgnoreList()
// We need to force a remote discovery after a change of the ignore list.
// Otherwise we would not download the files/directories that are no longer
// ignored (because the remote etag did not change) (issue #3172)
- foreach (Folder *folder, folderMan->map()) {
+ for (auto *folder : folderMan->map()) {
folder->journalDb()->forceRemoteDiscoveryNextSync();
folder->slotNextSyncFullLocalDiscovery();
folderMan->scheduleFolder(folder);
diff --git a/src/gui/lockwatcher.cpp b/src/gui/lockwatcher.cpp
index 8e26cf2ce..e04133f1a 100644
--- a/src/gui/lockwatcher.cpp
+++ b/src/gui/lockwatcher.cpp
@@ -52,7 +52,7 @@ void LockWatcher::checkFiles()
{
QSet<QString> unlocked;
- foreach (const QString &path, _watchedPaths) {
+ for (const auto &path : qAsConst(_watchedPaths)) {
if (!FileSystem::isFileLocked(path)) {
qCInfo(lcLockWatcher) << "Lock of" << path << "was released";
emit fileUnlocked(path);
diff --git a/src/gui/navigationpanehelper.cpp b/src/gui/navigationpanehelper.cpp
index 4cf4eb609..57fff692d 100644
--- a/src/gui/navigationpanehelper.cpp
+++ b/src/gui/navigationpanehelper.cpp
@@ -42,7 +42,7 @@ void NavigationPaneHelper::setShowInExplorerNavigationPane(bool show)
_showInExplorerNavigationPane = show;
// Re-generate a new CLSID when enabling, possibly throwing away the old one.
// updateCloudStorageRegistry will take care of removing any unknown CLSID our application owns from the registry.
- foreach (Folder *folder, _folderMan->map())
+ for (auto *folder : _folderMan->map())
folder->setNavigationPaneClsid(show ? QUuid::createUuid() : QUuid());
scheduleUpdateCloudStorageRegistry();
@@ -75,7 +75,7 @@ void NavigationPaneHelper::updateCloudStorageRegistry()
// Then re-save every folder that has a valid navigationPaneClsid to the registry.
// We currently don't distinguish between new and existing CLSIDs, if it's there we just
// save over it. We at least need to update the tile in case we are suddently using multiple accounts.
- foreach (Folder *folder, _folderMan->map()) {
+ for (auto *folder : _folderMan->map()) {
if (folder->vfs().mode() == Vfs::WindowsCfApi)
{
continue;
@@ -141,7 +141,7 @@ void NavigationPaneHelper::updateCloudStorageRegistry()
}
// Then remove anything that isn't in our folder list anymore.
- foreach (auto &clsid, entriesToRemove) {
+ for (const auto &clsid : qAsConst(entriesToRemove)) {
QString clsidStr = clsid.toString();
QString clsidPath = QString() % "Software\\Classes\\CLSID\\" % clsidStr;
QString clsidPathWow64 = QString() % "Software\\Classes\\Wow6432Node\\CLSID\\" % clsidStr;
diff --git a/src/gui/notificationwidget.cpp b/src/gui/notificationwidget.cpp
index 51f1efe66..266d013c1 100644
--- a/src/gui/notificationwidget.cpp
+++ b/src/gui/notificationwidget.cpp
@@ -112,7 +112,7 @@ void NotificationWidget::slotNotificationRequestFinished(int statusCode)
// the ocs API returns stat code 100 or 200 inside the xml if it succeeded.
if (statusCode != OCS_SUCCESS_STATUS_CODE && statusCode != OCS_SUCCESS_STATUS_CODE_V2) {
qCWarning(lcNotifications) << "Notification Request to Server failed, leave button visible.";
- for (auto button : _buttons) {
+ for (auto *button : qAsConst(_buttons)) {
button->setEnabled(true);
}
//: The second parameter is a time, such as 'failed at 09:58pm'
diff --git a/src/gui/ocsjob.cpp b/src/gui/ocsjob.cpp
index 66cca9f0d..42bd48d78 100644
--- a/src/gui/ocsjob.cpp
+++ b/src/gui/ocsjob.cpp
@@ -58,7 +58,7 @@ static QUrlQuery percentEncodeQueryItems(
QUrlQuery result;
// Note: QUrlQuery::setQueryItems() does not fully percent encode
// the query items, see #5042
- foreach (const auto &item, items) {
+ for (const auto &item : items) {
result.addQueryItem(
QUrl::toPercentEncoding(item.first),
QUrl::toPercentEncoding(item.second));
diff --git a/src/gui/openfilemanager.cpp b/src/gui/openfilemanager.cpp
index c8cdabbd1..d665a46b8 100644
--- a/src/gui/openfilemanager.cpp
+++ b/src/gui/openfilemanager.cpp
@@ -61,12 +61,10 @@ static QString findDefaultFileManager()
return QString();
QFileInfo fi;
- QStringList dirs = xdgDataDirs();
- QStringList subdirs;
- subdirs << "/applications/"
- << "/applications/kde4/";
- foreach (QString dir, dirs) {
- foreach (QString subdir, subdirs) {
+ const auto &dirs = xdgDataDirs();
+ for (const auto &dir : dirs) {
+ const QStringList subdirs { QStringLiteral("/applications/"), QStringLiteral("/applications/kde4/") };
+ for (const auto &subdir : subdirs) {
fi.setFile(dir + subdir + fileName);
if (fi.exists()) {
return fi.absoluteFilePath();
diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp
index edecdd194..6b8e37a3f 100644
--- a/src/gui/owncloudgui.cpp
+++ b/src/gui/owncloudgui.cpp
@@ -200,7 +200,7 @@ void ownCloudGui::slotComputeOverallSyncStatus()
_actionStatus->setText(text);
};
- foreach (auto a, AccountManager::instance()->accounts()) {
+ for (const auto &a : AccountManager::instance()->accounts()) {
if (!a->isSignedOut()) {
allSignedOut = false;
}
@@ -210,7 +210,9 @@ void ownCloudGui::slotComputeOverallSyncStatus()
allDisconnected = false;
}
}
- foreach (Folder *f, FolderMan::instance()->map()) {
+
+ const auto &map = FolderMan::instance()->map();
+ for (auto *f : map) {
if (!f->syncPaused()) {
allPaused = false;
}
@@ -226,14 +228,14 @@ void ownCloudGui::slotComputeOverallSyncStatus()
#ifdef Q_OS_WIN
// Windows has a 128-char tray tooltip length limit.
QStringList accountNames;
- foreach (AccountStatePtr a, problemAccounts) {
+ for (const auto &a : qAsConst(problemAccounts)) {
accountNames.append(a->account()->displayName());
}
_tray->setToolTip(tr("Disconnected from %1").arg(accountNames.join(QLatin1String(", "))));
#else
QStringList messages;
messages.append(tr("Disconnected from accounts:"));
- foreach (AccountStatePtr a, problemAccounts) {
+ for (const auto &a : qAsConst(problemAccounts)) {
QString message = tr("Account %1: %2").arg(a->account()->displayName(), a->stateString(a->state()));
if (!a->connectionErrors().empty()) {
message += QLatin1String("\n");
@@ -260,8 +262,6 @@ void ownCloudGui::slotComputeOverallSyncStatus()
// display the info of the least successful sync (eg. do not just display the result of the latest sync)
QString trayMessage;
- FolderMan *folderMan = FolderMan::instance();
- Folder::Map map = folderMan->map();
auto trayOverallStatusResult = FolderMan::trayOverallStatus(map.values());
@@ -284,10 +284,10 @@ void ownCloudGui::slotComputeOverallSyncStatus()
if (map.count() > 0) {
#ifdef Q_OS_WIN
// Windows has a 128-char tray tooltip length limit.
- trayMessage = folderMan->trayTooltipStatusString(trayOverallStatusResult.overallStatus, trayOverallStatusResult.hasUnresolvedConflicts, false);
+ trayMessage = FolderMan::instance()->trayTooltipStatusString(trayOverallStatusResult.overallStatus, trayOverallStatusResult.hasUnresolvedConflicts, false);
#else
QStringList allStatusStrings;
- foreach (Folder *folder, map) {
+ for (auto *folder : map.values()) {
QString folderMessage = FolderMan::trayTooltipStatusString(
folder->syncResult().status(),
folder->syncResult().hasUnresolvedConflicts(),
@@ -338,10 +338,11 @@ void ownCloudGui::addAccountContextMenu(AccountStatePtr accountState, QMenu *men
FolderMan *folderMan = FolderMan::instance();
bool firstFolder = true;
- bool singleSyncFolder = folderMan->map().size() == 1 && Theme::instance()->singleSyncFolder();
+ const auto &map = folderMan->map();
+ bool singleSyncFolder = map.size() == 1 && Theme::instance()->singleSyncFolder();
bool onePaused = false;
bool allPaused = true;
- foreach (Folder *folder, folderMan->map()) {
+ for (auto *folder : map) {
if (folder->accountState() != accountState.data()) {
continue;
}
@@ -599,13 +600,13 @@ void ownCloudGui::updateContextMenu()
slotRebuildRecentMenus();
// We must call deleteLater because we might be called from the press in one of the actions.
- foreach (auto menu, _accountMenus) {
+ for (auto *menu : qAsConst(_accountMenus)) {
menu->deleteLater();
}
_accountMenus.clear();
- auto accountList = AccountManager::instance()->accounts();
+ const auto &accountList = AccountManager::instance()->accounts();
bool isConfigured = (!accountList.isEmpty());
bool atLeastOneConnected = false;
@@ -613,7 +614,7 @@ void ownCloudGui::updateContextMenu()
bool atLeastOneSignedIn = false;
bool atLeastOnePaused = false;
bool atLeastOneNotPaused = false;
- foreach (auto a, accountList) {
+ for (const auto &a : accountList) {
if (a->isConnected()) {
atLeastOneConnected = true;
}
@@ -623,7 +624,8 @@ void ownCloudGui::updateContextMenu()
atLeastOneSignedIn = true;
}
}
- foreach (auto f, FolderMan::instance()->map()) {
+
+ for (auto *f : FolderMan::instance()->map()) {
if (f->syncPaused()) {
atLeastOnePaused = true;
} else {
@@ -632,7 +634,7 @@ void ownCloudGui::updateContextMenu()
}
if (accountList.count() > 1) {
- foreach (AccountStatePtr account, accountList) {
+ for (const auto &account : accountList) {
QMenu *accountMenu = new QMenu(account->account()->displayName(), _contextMenu.data());
_accountMenus.append(accountMenu);
_contextMenu->addMenu(accountMenu);
@@ -818,7 +820,7 @@ void ownCloudGui::slotRebuildRecentMenus()
{
_recentActionsMenu->clear();
if (!_recentItemsActions.isEmpty()) {
- foreach (QAction *a, _recentItemsActions) {
+ for (auto *a : qAsConst(_recentItemsActions)) {
_recentActionsMenu->addAction(a);
}
_recentActionsMenu->addSeparator();
@@ -927,8 +929,7 @@ void ownCloudGui::slotLogin()
account->account()->resetRejectedCertificates();
account->signIn();
} else {
- auto list = AccountManager::instance()->accounts();
- foreach (const auto &a, list) {
+ for (const auto &a : AccountManager::instance()->accounts()) {
a->signIn();
}
}
@@ -942,7 +943,7 @@ void ownCloudGui::slotLogout()
list.insert(account->account()->uuid(), account);
}
- foreach (const auto &ai, list) {
+ for (const auto &ai : qAsConst(list)) {
ai->signOutByUi();
}
}
@@ -975,11 +976,11 @@ void ownCloudGui::setPauseOnAllFoldersHelper(bool pause)
if (auto account = qvariant_cast<AccountStatePtr>(sender()->property(propertyAccountC))) {
accounts.append(account.data());
} else {
- foreach (auto a, AccountManager::instance()->accounts()) {
+ for (const auto &a : AccountManager::instance()->accounts()) {
accounts.append(a.data());
}
}
- foreach (Folder *f, FolderMan::instance()->map()) {
+ for (auto *f : FolderMan::instance()->map()) {
if (accounts.contains(f->accountState())) {
f->setSyncPaused(pause);
if (pause) {
diff --git a/src/gui/selectivesyncdialog.cpp b/src/gui/selectivesyncdialog.cpp
index 1a2920f19..c9e60b33b 100644
--- a/src/gui/selectivesyncdialog.cpp
+++ b/src/gui/selectivesyncdialog.cpp
@@ -155,7 +155,7 @@ void SelectiveSyncWidget::recursiveInsert(QTreeWidgetItem *parent, QStringList p
if (parent->checkState(0) == Qt::Checked
|| parent->checkState(0) == Qt::PartiallyChecked) {
item->setCheckState(0, Qt::Checked);
- foreach (const QString &str, _oldBlackList) {
+ for (const auto &str : qAsConst(_oldBlackList)) {
if (str == path || str == QLatin1String("/")) {
item->setCheckState(0, Qt::Unchecked);
break;
@@ -200,7 +200,7 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
// list of top-level folders as soon as possible.
if (_oldBlackList == QStringList("/")) {
_oldBlackList.clear();
- foreach (QString path, list) {
+ for (auto path : qAsConst(list)) {
path.remove(pathToRemove);
if (path.isEmpty()) {
continue;
@@ -231,7 +231,7 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
}
Utility::sortFilenames(list);
- foreach (QString path, list) {
+ for (auto path : qAsConst(list)) {
auto size = job ? job->sizes().value(path) : 0;
path.remove(pathToRemove);
QStringList paths = path.split('/');
@@ -363,7 +363,7 @@ QStringList SelectiveSyncWidget::createBlackList(QTreeWidgetItem *root) const
} else {
// We did not load from the server so we re-use the one from the old black list
QString path = root->data(0, Qt::UserRole).toString();
- foreach (const QString &it, _oldBlackList) {
+ for (const auto &it : _oldBlackList) {
if (it.startsWith(path))
result += it;
}
@@ -470,8 +470,8 @@ 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 = blackList.toSet();
- auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet);
- foreach (const auto &it, changes) {
+ const auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet);
+ for (const auto &it : changes) {
_folder->journalDb()->schedulePathForRemoteDiscovery(it);
_folder->schedulePathForLocalDiscovery(it);
}
diff --git a/src/gui/servernotificationhandler.cpp b/src/gui/servernotificationhandler.cpp
index bd59f7483..e1c331871 100644
--- a/src/gui/servernotificationhandler.cpp
+++ b/src/gui/servernotificationhandler.cpp
@@ -65,8 +65,7 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
return;
}
- auto notifies = json.object().value("ocs").toObject().value("data").toArray();
-
+ const auto &notifies = json.object().value(QLatin1String("ocs")).toObject().value(QLatin1String("data")).toArray();
AccountState *ai = qvariant_cast<AccountState *>(sender()->property("AccountStatePtr"));
ActivityList list;
diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp
index 4402d9576..d09790c97 100644
--- a/src/gui/settingsdialog.cpp
+++ b/src/gui/settingsdialog.cpp
@@ -227,7 +227,7 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
this, &SettingsDialog::accountAdded);
connect(AccountManager::instance(), &AccountManager::accountRemoved,
this, &SettingsDialog::accountRemoved);
- foreach (auto ai, AccountManager::instance()->accounts()) {
+ for (const auto &ai : AccountManager::instance()->accounts()) {
accountAdded(ai.data());
}
@@ -441,7 +441,8 @@ void SettingsDialog::customizeStyle()
QString background(palette().base().color().name());
_ui->toolBar->setStyleSheet(TOOLBAR_CSS().arg(background, dark, highlightColor, highlightTextColor));
- for (auto a : findChildren<ToolButtonAction *>()) {
+ const auto &toolButtonActions = findChildren<ToolButtonAction *>();
+ for (auto *a : toolButtonActions) {
a->updateIcon();
}
}
diff --git a/src/gui/sharee.cpp b/src/gui/sharee.cpp
index bb77527ca..9c6db60d1 100644
--- a/src/gui/sharee.cpp
+++ b/src/gui/sharee.cpp
@@ -88,44 +88,44 @@ void ShareeModel::shareesFetched(const QJsonDocument &reply)
*/
auto exact = data.value("exact").toObject();
{
- auto users = exact.value("users").toArray();
- foreach (auto user, users) {
+ const auto &users = exact.value("users").toArray();
+ for (const auto &user : users) {
newSharees.append(parseSharee(user.toObject()));
}
- auto groups = exact.value("groups").toArray();
- foreach (auto group, groups) {
+ const auto &groups = exact.value("groups").toArray();
+ for (const auto &group : groups) {
newSharees.append(parseSharee(group.toObject()));
}
- auto remotes = exact.value("remotes").toArray();
- foreach (auto remote, remotes) {
+ const auto &remotes = exact.value("remotes").toArray();
+ for (const auto &remote : remotes) {
newSharees.append(parseSharee(remote.toObject()));
}
}
{
- auto users = data.value("users").toArray();
- foreach (auto user, users) {
+ const auto &users = data.value("users").toArray();
+ for (const auto &user : users) {
newSharees.append(parseSharee(user.toObject()));
}
}
{
- auto groups = data.value("groups").toArray();
- foreach (auto group, groups) {
+ const auto &groups = data.value("groups").toArray();
+ for (const auto &group : groups) {
newSharees.append(parseSharee(group.toObject()));
}
}
{
- auto remotes = data.value("remotes").toArray();
- foreach (auto remote, remotes) {
+ const auto &remotes = data.value("remotes").toArray();
+ for (const auto &remote : remotes) {
newSharees.append(parseSharee(remote.toObject()));
}
}
// Filter sharees that we have already shared with
QVector<QSharedPointer<Sharee>> filteredSharees;
- foreach (const auto &sharee, newSharees) {
+ for (const auto &sharee : qAsConst(newSharees)) {
bool found = false;
- foreach (const auto &blacklistSharee, _shareeBlacklist) {
+ for (const auto &blacklistSharee : qAsConst(_shareeBlacklist)) {
if (sharee->type() == blacklistSharee->type() && sharee->shareWith() == blacklistSharee->shareWith()) {
found = true;
break;
@@ -188,7 +188,7 @@ void ShareeModel::setNewSharees(const QVector<QSharedPointer<Sharee>> &newSharee
QModelIndexList newPersistant;
newPersistant.reserve(persistent.size());
- foreach (const QSharedPointer<Sharee> &sharee, oldPersistantSharee) {
+ for (const auto &sharee : qAsConst(oldPersistantSharee)) {
FindShareeHelper helper = { sharee };
auto it = std::find_if(_sharees.constBegin(), _sharees.constEnd(), helper);
if (it == _sharees.constEnd()) {
diff --git a/src/gui/sharelinkwidget.cpp b/src/gui/sharelinkwidget.cpp
index 5ec8c236f..7960a6dd1 100644
--- a/src/gui/sharelinkwidget.cpp
+++ b/src/gui/sharelinkwidget.cpp
@@ -230,7 +230,7 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar
auto deleteIcon = QIcon::fromTheme(QStringLiteral("user-trash"),
Utility::getCoreIcon(QStringLiteral("delete")));
- foreach (auto share, shares) {
+ for (const auto &share : shares) {
if (share->getShareType() != Share::TypeLink) {
continue;
}
diff --git a/src/gui/sharemanager.cpp b/src/gui/sharemanager.cpp
index 0901f3fec..126bec9f9 100644
--- a/src/gui/sharemanager.cpp
+++ b/src/gui/sharemanager.cpp
@@ -30,7 +30,7 @@ namespace OCC {
*/
static void updateFolder(const AccountPtr &account, const QString &path)
{
- foreach (Folder *f, FolderMan::instance()->map()) {
+ for (auto *f : FolderMan::instance()->map()) {
if (f->accountState()->account() != account)
continue;
auto folderPath = f->remotePath();
@@ -302,7 +302,8 @@ void ShareManager::createShare(const QString &path,
// Find existing share permissions (if this was shared with us)
Share::Permissions existingPermissions = SharePermissionDefault;
- foreach (const QJsonValue &element, reply.object()["ocs"].toObject()["data"].toArray()) {
+ const auto &array = reply.object()[QLatin1String("ocs")].toObject()[QLatin1String("data")].toArray();
+ for (const auto &element : array) {
auto map = element.toObject();
if (map["file_target"] == path)
existingPermissions = Share::Permissions(map["permissions"].toInt());
@@ -348,13 +349,13 @@ void ShareManager::fetchShares(const QString &path)
void ShareManager::slotSharesFetched(const QJsonDocument &reply)
{
- auto tmpShares = reply.object().value("ocs").toObject().value("data").toArray();
+ const auto &tmpShares = reply.object().value(QLatin1String("ocs")).toObject().value(QLatin1String("data")).toArray();
const QString versionString = _account->serverVersion();
qCDebug(lcSharing) << versionString << "Fetched" << tmpShares.count() << "shares";
QList<QSharedPointer<Share>> shares;
- foreach (const auto &share, tmpShares) {
+ for (const auto &share : tmpShares) {
auto data = share.toObject();
auto shareType = data.value("share_type").toInt();
diff --git a/src/gui/shareusergroupwidget.cpp b/src/gui/shareusergroupwidget.cpp
index 4bbb7bdfd..b3d9e25b8 100644
--- a/src/gui/shareusergroupwidget.cpp
+++ b/src/gui/shareusergroupwidget.cpp
@@ -164,7 +164,8 @@ void ShareUserGroupWidget::searchForSharees()
QSharedPointer<Sharee> currentUser(new Sharee(_account->credentials()->user(), "", Sharee::Type::User));
blacklist << currentUser;
- foreach (auto sw, _ui->scrollArea->findChildren<ShareUserLine *>()) {
+ const auto &shareUserLines = _ui->scrollArea->findChildren<ShareUserLine *>();
+ for (auto *sw : shareUserLines) {
blacklist << sw->share()->getShareWith();
}
_ui->errorLabel->hide();
@@ -188,7 +189,7 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
QSize minimumSize = newViewPort->sizeHint();
int x = 0;
- foreach (const auto &share, shares) {
+ for (const auto &share : shares) {
// We don't handle link shares
if (share->getShareType() == Share::TypeLink) {
continue;
@@ -320,9 +321,7 @@ void ShareUserGroupWidget::displayError(int code, const QString &message)
_pi_sharee.stopAnimation();
// Also remove the spinner in the widget list, if any
- foreach (auto pi, _ui->scrollArea->findChildren<QProgressIndicator *>()) {
- delete pi;
- }
+ qDeleteAll(_ui->scrollArea->findChildren<QProgressIndicator *>());
qCWarning(lcSharing) << "Sharing error from server" << code << message;
_ui->errorLabel->setText(message);
diff --git a/src/gui/sslbutton.cpp b/src/gui/sslbutton.cpp
index 286eeebc2..8dfd43835 100644
--- a/src/gui/sslbutton.cpp
+++ b/src/gui/sslbutton.cpp
@@ -218,7 +218,7 @@ void SslButton::slotUpdateMenu()
const auto systemCerts = QSslConfiguration::systemCaCertificates();
QList<QSslCertificate> tmpChain;
- foreach (QSslCertificate cert, chain) {
+ for (const auto &cert : qAsConst(chain)) {
tmpChain << cert;
if (systemCerts.contains(cert))
break;
diff --git a/src/gui/sslerrordialog.cpp b/src/gui/sslerrordialog.cpp
index 194139d6b..28162c9b4 100644
--- a/src/gui/sslerrordialog.cpp
+++ b/src/gui/sslerrordialog.cpp
@@ -132,10 +132,10 @@ bool SslErrorDialog::checkFailingCertsKnown(const QList<QSslError> &errors)
msg += QL("<h3>") + tr("Cannot connect securely to <i>%1</i>:").arg(host) + QL("</h3>");
// loop over the unknown certs and line up their errors.
msg += QL("<div id=\"ca_errors\">");
- foreach (const QSslCertificate &cert, _unknownCerts) {
+ for (const auto &cert : qAsConst(_unknownCerts)) {
msg += QL("<div id=\"ca_error\">");
// add the errors for this cert
- foreach (QSslError err, errors) {
+ for (const auto &err : errors) {
if (err.certificate() == cert) {
msg += QL("<p>") + err.errorString() + QL("</p>");
}
diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp
index 188087c18..76c38f6c7 100644
--- a/src/libsync/account.cpp
+++ b/src/libsync/account.cpp
@@ -354,14 +354,14 @@ void Account::slotHandleSslErrors(QNetworkReply *reply, QList<QSslError> errors)
NetworkJobTimeoutPauser pauser(reply);
QString out;
QDebug(&out) << "SSL-Errors happened for url " << reply->url().toString();
- foreach (const QSslError &error, errors) {
+ for (const auto &error : qAsConst(errors)) {
QDebug(&out) << "\tError in " << error.certificate() << ":"
<< error.errorString() << "(" << error.error() << ")"
<< "\n";
}
bool allPreviouslyRejected = true;
- foreach (const QSslError &error, errors) {
+ for (const auto &error : qAsConst(errors)) {
if (!_rejectedCertificates.contains(error.certificate())) {
allPreviouslyRejected = false;
}
@@ -408,7 +408,7 @@ void Account::slotHandleSslErrors(QNetworkReply *reply, QList<QSslError> errors)
return;
// Mark all involved certificates as rejected, so we don't ask the user again.
- foreach (const QSslError &error, errors) {
+ for (const auto &error : qAsConst(errors)) {
if (!_rejectedCertificates.contains(error.certificate())) {
_rejectedCertificates.append(error.certificate());
}
diff --git a/src/libsync/capabilities.cpp b/src/libsync/capabilities.cpp
index 5af8a1022..a01e936d5 100644
--- a/src/libsync/capabilities.cpp
+++ b/src/libsync/capabilities.cpp
@@ -117,7 +117,8 @@ bool Capabilities::isValid() const
QList<QByteArray> Capabilities::supportedChecksumTypes() const
{
QList<QByteArray> list;
- foreach (const auto &t, _capabilities.value(QStringLiteral("checksums")).toMap().value(QStringLiteral("supportedTypes")).toList()) {
+ const auto &supportedTypes = _capabilities.value(QStringLiteral("checksums")).toMap().value(QStringLiteral("supportedTypes")).toList();
+ for (const auto &t : supportedTypes) {
list.push_back(t.toByteArray());
}
return list;
@@ -189,7 +190,8 @@ bool Capabilities::privateLinkDetailsParamAvailable() const
QList<int> Capabilities::httpErrorCodesThatResetFailingChunkedUploads() const
{
QList<int> list;
- foreach (const auto &t, _capabilities.value(QStringLiteral("dav")).toMap().value(QStringLiteral("httpErrorCodesThatResetFailingChunkedUploads")).toList()) {
+ const auto &errorCodes = _capabilities.value(QStringLiteral("dav")).toMap().value(QStringLiteral("httpErrorCodesThatResetFailingChunkedUploads")).toList();
+ for (const auto &t : errorCodes) {
list.push_back(t.toInt());
}
return list;
diff --git a/src/libsync/cookiejar.cpp b/src/libsync/cookiejar.cpp
index deb2b5aa4..75535d876 100644
--- a/src/libsync/cookiejar.cpp
+++ b/src/libsync/cookiejar.cpp
@@ -142,7 +142,7 @@ bool CookieJar::restore(const QString &fileName)
QList<QNetworkCookie> CookieJar::removeExpired(const QList<QNetworkCookie> &cookies)
{
QList<QNetworkCookie> updatedList;
- foreach (const QNetworkCookie &cookie, cookies) {
+ for (const auto &cookie : cookies) {
if (cookie.expirationDate() > QDateTime::currentDateTimeUtc() && !cookie.isSessionCookie()) {
updatedList << cookie;
}
diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp
index 5ab897dc3..787e0b26e 100644
--- a/src/libsync/discovery.cpp
+++ b/src/libsync/discovery.cpp
@@ -242,17 +242,15 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const QString &loc
if (item->_file.endsWith(QLatin1Char('.'))) {
item->_errorString = tr("File names ending with a period are not supported on this file system.");
} else {
- char invalid = '\0';
- for (const char x : QByteArrayLiteral("\\:?*\"<>|")) {
- if (item->_file.contains(QLatin1Char(x))) {
- invalid = x;
+ const auto unsupportedCharacters = QStringLiteral("\\:?*\"<>|");
+ for (const auto &x : unsupportedCharacters) {
+ if (item->_file.contains(x)) {
+ item->_errorString = tr("File names containing the character '%1' are not supported on this file system.")
+ .arg(x);
break;
}
}
- if (invalid) {
- item->_errorString = tr("File names containing the character '%1' are not supported on this file system.")
- .arg(QLatin1Char(invalid));
- }
+
if (isInvalidPattern) {
item->_errorString = tr("File name contains at least one invalid character");
} else {
@@ -1339,7 +1337,7 @@ int ProcessDirectoryJob::processSubJobs(int nbJobs)
}
int started = 0;
- foreach (auto *rj, _runningJobs) {
+ for (auto *rj : qAsConst(_runningJobs)) {
started += rj->processSubJobs(nbJobs - started);
if (started >= nbJobs)
return started;
diff --git a/src/libsync/logger.cpp b/src/libsync/logger.cpp
index 212db9357..124e33042 100644
--- a/src/libsync/logger.cpp
+++ b/src/libsync/logger.cpp
@@ -275,11 +275,11 @@ void Logger::enterNextLogFile()
QString newLogName = now.toString(QStringLiteral("yyyyMMdd_HHmm")) + QStringLiteral("_owncloud.log");
// Expire old log files and deal with conflicts
- QStringList files = dir.entryList(QStringList(QStringLiteral("*owncloud.log.*")),
+ const auto &files = dir.entryList(QStringList(QStringLiteral("*owncloud.log.*")),
QDir::Files, QDir::Name);
QRegExp rx(QStringLiteral(R"(.*owncloud\.log\.(\d+).*)"));
int maxNumber = -1;
- foreach (const QString &s, files) {
+ for (const auto &s : files) {
if (_logExpire.count() > 0) {
std::chrono::seconds expireSeconds(_logExpire);
QFileInfo fileInfo(dir.absoluteFilePath(s));
diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp
index 9f3fec822..6c86b2459 100644
--- a/src/libsync/owncloudpropagator.cpp
+++ b/src/libsync/owncloudpropagator.cpp
@@ -384,7 +384,7 @@ void OwncloudPropagator::start(SyncFileItemVector &&items)
QVector<PropagatorJob *> directoriesToRemove;
QString removedDirectory;
QString maybeConflictDirectory;
- foreach (const SyncFileItemPtr &item, items) {
+ for (const auto &item : qAsConst(items)) {
if (!removedDirectory.isEmpty() && item->_file.startsWith(removedDirectory)) {
// this is an item in a directory which is going to be removed.
PropagateDirectory *delDirJob = qobject_cast<PropagateDirectory *>(directoriesToRemove.first());
@@ -445,7 +445,7 @@ void OwncloudPropagator::start(SyncFileItemVector &&items)
// checkForPermissions() has already run and used the permissions
// of the file we're about to delete to decide whether uploading
// to the new dir is ok...
- foreach (const SyncFileItemPtr &item2, items) {
+ for (const auto &item2 : qAsConst(items)) {
if (item2->destination().startsWith(item->destination() + QLatin1Char('/'))) {
item2->_instruction = CSYNC_INSTRUCTION_NONE;
_anotherSyncNeeded = true;
@@ -489,7 +489,7 @@ void OwncloudPropagator::start(SyncFileItemVector &&items)
}
}
- foreach (PropagatorJob *it, directoriesToRemove) {
+ for (auto *it : qAsConst(directoriesToRemove)) {
_rootJob->_dirDeletionJobs.appendJob(it);
}
@@ -904,7 +904,7 @@ void PropagatorCompositeJob::finalize()
qint64 PropagatorCompositeJob::committedDiskSpace() const
{
qint64 needed = 0;
- foreach (PropagatorJob *job, _runningJobs) {
+ for (auto *job : _runningJobs) {
needed += job->committedDiskSpace();
}
return needed;
diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h
index 01ecda3a9..fd8ed4900 100644
--- a/src/libsync/owncloudpropagator.h
+++ b/src/libsync/owncloudpropagator.h
@@ -249,7 +249,7 @@ public:
{
if (!_runningJobs.empty()) {
_abortsCount = _runningJobs.size();
- foreach (PropagatorJob *j, _runningJobs) {
+ for (auto *j : qAsConst(_runningJobs)) {
if (abortType == AbortType::Asynchronous) {
connect(j, &PropagatorJob::abortFinished,
this, &PropagatorCompositeJob::slotSubJobAbortFinished);
diff --git a/src/libsync/progressdispatcher.cpp b/src/libsync/progressdispatcher.cpp
index b4cbf2d66..c08938966 100644
--- a/src/libsync/progressdispatcher.cpp
+++ b/src/libsync/progressdispatcher.cpp
@@ -364,7 +364,7 @@ void ProgressInfo::updateEstimates()
void ProgressInfo::recomputeCompletedSize()
{
qint64 r = _totalSizeOfCompletedJobs;
- foreach (const ProgressItem &i, _currentItems) {
+ for (const auto &i : qAsConst(_currentItems)) {
if (isSizeDependent(i._item))
r += i._progress._completed;
}
diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp
index 225d54d70..274807037 100644
--- a/src/libsync/propagateupload.cpp
+++ b/src/libsync/propagateupload.cpp
@@ -604,7 +604,7 @@ void PropagateUploadFileCommon::abortNetworkJobs(
};
// Abort all running jobs, except for explicitly excluded ones
- foreach (AbstractNetworkJob *job, _jobs) {
+ for (auto *job : qAsConst(_jobs)) {
auto reply = job->reply();
if (!reply || !reply->isRunning())
continue;
diff --git a/src/libsync/propagateuploadng.cpp b/src/libsync/propagateuploadng.cpp
index bcc544d9c..b82f99757 100644
--- a/src/libsync/propagateuploadng.cpp
+++ b/src/libsync/propagateuploadng.cpp
@@ -166,8 +166,11 @@ void PropagateUploadFileNG::slotPropfindFinished()
_currentChunkOffset = 0;
_sent = 0;
- for (auto chunkOffset : _serverChunks.keys()) {
- auto chunkSize = _serverChunks[chunkOffset].size;
+ // here is a copy because we might need to remove item(s) during iteration
+ const auto serverChunks = _serverChunks;
+ for (auto it = serverChunks.cbegin(); it != serverChunks.cend(); ++it) {
+ const auto &chunkOffset = it.key();
+ const auto &chunkSize = it.value().size;
if (markRangeAsDone(chunkOffset, chunkSize)) {
qCDebug(lcPropagateUploadNG) << "Reusing existing data:" << chunkOffset << chunkSize;
_sent += chunkSize;
@@ -255,7 +258,7 @@ void PropagateUploadFileNG::slotDeleteJobFinished()
// If no more Delete jobs are running, we can continue
bool runningDeleteJobs = false;
- for (auto otherJob : _jobs) {
+ for (auto *otherJob : qAsConst(_jobs)) {
if (qobject_cast<DeleteJob *>(otherJob))
runningDeleteJobs = true;
}
diff --git a/src/libsync/propagateuploadv1.cpp b/src/libsync/propagateuploadv1.cpp
index 0ba211441..f1de989b0 100644
--- a/src/libsync/propagateuploadv1.cpp
+++ b/src/libsync/propagateuploadv1.cpp
@@ -275,7 +275,7 @@ void PropagateUploadFileV1::slotPutFinished()
SyncJournalDb::UploadInfo pi;
pi._valid = true;
auto currentChunk = job->_chunk;
- foreach (auto *job, _jobs) {
+ for (auto *job : qAsConst(_jobs)) {
// Take the minimum finished one
if (auto putJob = qobject_cast<PUTFileJob *>(job)) {
currentChunk = qMin(currentChunk, putJob->_chunk - 1);
@@ -339,7 +339,7 @@ void PropagateUploadFileV1::slotUploadProgress(qint64 sent, qint64 total)
sender()->setProperty("byteWritten", sent);
if (_jobs.count() > 1) {
amount -= (_jobs.count() - 1) * chunkSize();
- foreach (QObject *j, _jobs) {
+ for (auto *j : qAsConst(_jobs)) {
amount += j->property("byteWritten").toULongLong();
}
} else {
diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp
index 53c873395..12181a873 100644
--- a/src/libsync/propagatorjobs.cpp
+++ b/src/libsync/propagatorjobs.cpp
@@ -69,7 +69,7 @@ bool PropagateLocalRemove::removeRecursively(const QString &path)
// We need to delete the entries from the database now from the deleted vector.
// Do it while avoiding redundant delete calls to the journal.
QString deletedDir;
- foreach (const auto &it, deleted) {
+ for (const auto &it : qAsConst(deleted)) {
if (!it.first.startsWith(propagator()->localPath()))
continue;
if (!deletedDir.isEmpty() && it.first.startsWith(deletedDir))
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index f2596c806..2af3520ee 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -202,7 +202,7 @@ void SyncEngine::deleteStaleDownloadInfos(const SyncFileItemVector &syncItems)
{
// Find all downloadinfo paths that we want to preserve.
QSet<QString> download_file_paths;
- foreach (const SyncFileItemPtr &it, syncItems) {
+ for (const auto &it : syncItems) {
if (it->_direction == SyncFileItem::Down
&& it->_type == ItemTypeFile
&& isFileTransferInstruction(it->_instruction)) {
@@ -213,7 +213,7 @@ void SyncEngine::deleteStaleDownloadInfos(const SyncFileItemVector &syncItems)
// Delete from journal and from filesystem.
const QVector<SyncJournalDb::DownloadInfo> deleted_infos =
_journal->getAndDeleteStaleDownloadInfos(download_file_paths);
- foreach (const SyncJournalDb::DownloadInfo &deleted_info, deleted_infos) {
+ for (const auto &deleted_info : deleted_infos) {
const QString tmppath = _propagator->fullLocalPath(deleted_info._tmpfile);
qCInfo(lcEngine) << "Deleting stale temporary file: " << tmppath;
FileSystem::remove(tmppath);
@@ -224,7 +224,7 @@ void SyncEngine::deleteStaleUploadInfos(const SyncFileItemVector &syncItems)
{
// Find all blacklisted paths that we want to preserve.
QSet<QString> upload_file_paths;
- foreach (const SyncFileItemPtr &it, syncItems) {
+ for (const auto &it : syncItems) {
if (it->_direction == SyncFileItem::Up
&& it->_type == ItemTypeFile
&& isFileTransferInstruction(it->_instruction)) {
@@ -233,11 +233,11 @@ void SyncEngine::deleteStaleUploadInfos(const SyncFileItemVector &syncItems)
}
// Delete from journal.
- auto ids = _journal->deleteStaleUploadInfos(upload_file_paths);
+ const auto &ids = _journal->deleteStaleUploadInfos(upload_file_paths);
// Delete the stales chunk on the server.
if (account()->capabilities().chunkingNg()) {
- foreach (uint transferId, ids) {
+ for (auto transferId : ids) {
if (!transferId)
continue; // Was not a chunked upload
QUrl url = Utility::concatUrlPath(account()->url(), QLatin1String("remote.php/dav/uploads/") + account()->davUser() + QLatin1Char('/') + QString::number(transferId));
@@ -250,7 +250,7 @@ void SyncEngine::deleteStaleErrorBlacklistEntries(const SyncFileItemVector &sync
{
// Find all blacklisted paths that we want to preserve.
QSet<QString> blacklist_file_paths;
- foreach (const SyncFileItemPtr &it, syncItems) {
+ for (const auto &it : syncItems) {
if (it->_hasBlacklistEntry)
blacklist_file_paths.insert(it->_file);
}
@@ -264,7 +264,7 @@ void SyncEngine::conflictRecordMaintenance()
// Remove stale conflict entries from the database
// by checking which files still exist and removing the
// missing ones.
- auto conflictRecordPaths = _journal->conflictRecordPaths();
+ const auto &conflictRecordPaths = _journal->conflictRecordPaths();
for (const auto &path : conflictRecordPaths) {
auto fsPath = _propagator->fullLocalPath(QString::fromUtf8(path));
if (!QFileInfo::exists(fsPath)) {
@@ -277,7 +277,7 @@ void SyncEngine::conflictRecordMaintenance()
//
// This happens when the conflicts table is new or when conflict files
// are downlaoded but the server doesn't send conflict headers.
- for (const auto &path : _seenConflictFiles) {
+ for (const auto &path : qAsConst(_seenConflictFiles)) {
OC_ASSERT(Utility::isConflictFile(path));
auto bapath = path.toUtf8();
@@ -728,7 +728,7 @@ void SyncEngine::slotDiscoveryFinished()
if (!_hasNoneFiles && _hasRemoveFile) {
qCInfo(lcEngine) << "All the files are going to be changed, asking the user";
int side = 0; // > 0 means more deleted on the server. < 0 means more deleted on the client
- foreach (const auto &it, _syncItems) {
+ for (const auto &it : qAsConst(_syncItems)) {
if (it->_instruction == CSYNC_INSTRUCTION_REMOVE) {
side += it->_direction == SyncFileItem::Down ? 1 : -1;
}
diff --git a/src/libsync/syncfilestatustracker.cpp b/src/libsync/syncfilestatustracker.cpp
index 119f7880a..84071f284 100644
--- a/src/libsync/syncfilestatustracker.cpp
+++ b/src/libsync/syncfilestatustracker.cpp
@@ -211,7 +211,7 @@ void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector &items)
ProblemsMap oldProblems;
std::swap(_syncProblems, oldProblems);
- foreach (const SyncFileItemPtr &item, items) {
+ for (const auto &item : qAsConst(items)) {
qCDebug(lcStatusTracker) << "Investigating" << item->destination() << item->_status << item->_instruction;
_dirtyPaths.remove(item->destination());