mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Added more std::as_const and replaced types for auto, as well as other suggestions
Signed-off-by: Pablo Ariño Muñoz <progpabarino@gmail.com>
This commit is contained in:
parent
bf74e15896
commit
71e4de1503
@ -186,7 +186,7 @@ QString SqlDatabase::error() const
|
||||
void SqlDatabase::close()
|
||||
{
|
||||
if (_db) {
|
||||
for (auto q : std::as_const(_queries)) {
|
||||
for (const auto q : std::as_const(_queries)) {
|
||||
q->finish();
|
||||
}
|
||||
SQLITE_DO(sqlite3_close(_db));
|
||||
|
||||
@ -950,7 +950,7 @@ Result<void, QString> SyncJournalDb::setFileRecord(const SyncJournalFileRecord &
|
||||
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 + "/";
|
||||
for (const QByteArray &it : _etagStorageFilter) {
|
||||
for (const auto &it : _etagStorageFilter) {
|
||||
if (it.startsWith(prefix)) {
|
||||
qCInfo(lcDb) << "Filtered writing the etag of" << prefix << "because it is a prefix of" << it;
|
||||
record._etag = "_invalid_";
|
||||
@ -1718,7 +1718,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!
|
||||
for (const QString &entry : entries) {
|
||||
for (const auto &entry : entries) {
|
||||
query.reset_and_clear_bindings();
|
||||
query.bindValue(1, entry);
|
||||
if (!query.exec()) {
|
||||
|
||||
@ -660,7 +660,7 @@ Folder *FolderMan::folder(const QString &alias)
|
||||
void FolderMan::scheduleAllFolders()
|
||||
{
|
||||
const auto folderMapValues = _folderMap.values();
|
||||
for (Folder *f : folderMapValues) {
|
||||
for (auto *f : folderMapValues) {
|
||||
if (f && f->canSync()) {
|
||||
scheduleFolder(f);
|
||||
}
|
||||
@ -808,7 +808,7 @@ void FolderMan::slotRunOneEtagJob()
|
||||
{
|
||||
if (_currentEtagJob.isNull()) {
|
||||
Folder *folder = nullptr;
|
||||
for (Folder *f : std::as_const(_folderMap)) {
|
||||
for (auto *f : std::as_const(_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 separate queue.
|
||||
_currentEtagJob = f->etagJob();
|
||||
@ -842,7 +842,7 @@ void FolderMan::slotAccountStateChanged()
|
||||
qCInfo(lcFolderMan) << "Account" << accountName << "connected, scheduling its folders";
|
||||
|
||||
const auto folderMapValues = _folderMap.values();
|
||||
for (Folder *f : folderMapValues) {
|
||||
for (auto *f : folderMapValues) {
|
||||
if (f
|
||||
&& f->canSync()
|
||||
&& f->accountState() == accountState) {
|
||||
@ -853,8 +853,8 @@ void FolderMan::slotAccountStateChanged()
|
||||
qCInfo(lcFolderMan) << "Account" << accountName << "disconnected or paused, "
|
||||
"terminating or descheduling sync folders";
|
||||
|
||||
auto folderValues = _folderMap.values();
|
||||
for (Folder *f : std::as_const(folderValues)) {
|
||||
const auto folderValues = _folderMap.values();
|
||||
for (auto *f : folderValues) {
|
||||
if (f
|
||||
&& f->isSyncRunning()
|
||||
&& f->accountState() == accountState) {
|
||||
@ -1358,7 +1358,7 @@ QStringList FolderMan::findFileInLocalFolders(const QString &relPath, const Acco
|
||||
serverPath.prepend('/');
|
||||
|
||||
const auto mapValues = map().values();
|
||||
for (Folder *folder : mapValues) {
|
||||
for (auto *folder : mapValues) {
|
||||
if (acc && folder->accountState()->account() != acc) {
|
||||
continue;
|
||||
}
|
||||
@ -1706,7 +1706,7 @@ void FolderMan::trayOverallStatus(const QList<Folder *> &folders,
|
||||
auto runSeen = false;
|
||||
auto various = false;
|
||||
|
||||
for (const Folder *folder : std::as_const(folders)) {
|
||||
for (const auto *folder : std::as_const(folders)) {
|
||||
// We've already seen an error, worst case met.
|
||||
// No need to check the remaining folders.
|
||||
if (errorsSeen) {
|
||||
@ -2009,7 +2009,7 @@ void FolderMan::setIgnoreHiddenFiles(bool ignore)
|
||||
{
|
||||
// Note that the setting will revert to 'true' if all folders
|
||||
// are deleted...
|
||||
for (Folder *folder : std::as_const(_folderMap)) {
|
||||
for (auto *folder : std::as_const(_folderMap)) {
|
||||
folder->setIgnoreHiddenFiles(ignore);
|
||||
folder->saveToSettings();
|
||||
}
|
||||
|
||||
@ -337,7 +337,7 @@ bool FolderWizardRemotePath::selectByPath(QString path)
|
||||
QTreeWidgetItem *it = _ui.folderTreeWidget->topLevelItem(0);
|
||||
if (!path.isEmpty()) {
|
||||
const QStringList pathTrail = path.split(QLatin1Char('/'));
|
||||
for (const QString &path : pathTrail) {
|
||||
for (const auto &path : pathTrail) {
|
||||
if (!it) {
|
||||
return false;
|
||||
}
|
||||
@ -367,7 +367,7 @@ void FolderWizardRemotePath::slotUpdateDirectories(const QStringList &list)
|
||||
}
|
||||
QStringList sortedList = list;
|
||||
Utility::sortFilenames(sortedList);
|
||||
for (QString path : sortedList) {
|
||||
for ( auto path : sortedList) {
|
||||
path.remove(webdavFolder);
|
||||
|
||||
// Don't allow to select subfolders of encrypted subfolders
|
||||
|
||||
@ -100,7 +100,7 @@ void IgnoreListTableWidget::slotWriteIgnoreFile(const QString & file)
|
||||
// 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)
|
||||
for (Folder *folder : std::as_const(folderMan->map())) {
|
||||
for (auto *folder : std::as_const(folderMan->map())) {
|
||||
folder->journalDb()->forceRemoteDiscoveryNextSync();
|
||||
folderMan->scheduleFolder(folder);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ void LockWatcher::checkFiles()
|
||||
{
|
||||
QSet<QString> unlocked;
|
||||
|
||||
for (const QString &path : _watchedPaths) {
|
||||
for (const auto &path : std::as_const(_watchedPaths)) {
|
||||
if (!FileSystem::isFileLocked(path)) {
|
||||
qCInfo(lcLockWatcher) << "Lock of" << path << "was released";
|
||||
emit fileUnlocked(path);
|
||||
|
||||
@ -60,12 +60,10 @@ static QString findDefaultFileManager()
|
||||
return QString();
|
||||
|
||||
QFileInfo fi;
|
||||
QStringList dirs = xdgDataDirs();
|
||||
QStringList subdirs;
|
||||
subdirs << "/applications/"
|
||||
<< "/applications/kde4/";
|
||||
for (const QString &dir : dirs) {
|
||||
for (const QString &subdir : subdirs) {
|
||||
const QStringList dirs = xdgDataDirs();
|
||||
const QStringList subdirs { "/applications/", "/applications/kde4/" };
|
||||
for (const auto &dir : dirs) {
|
||||
for (const auto &subdir : subdirs) {
|
||||
fi.setFile(dir + subdir + fileName);
|
||||
if (fi.exists()) {
|
||||
return fi.absoluteFilePath();
|
||||
|
||||
@ -569,7 +569,7 @@ void ownCloudGui::slotLogin()
|
||||
account->account()->resetRejectedCertificates();
|
||||
account->signIn();
|
||||
} else {
|
||||
auto list = AccountManager::instance()->accounts();
|
||||
const auto list = AccountManager::instance()->accounts();
|
||||
for (const auto &a : list) {
|
||||
a->signIn();
|
||||
}
|
||||
@ -584,7 +584,7 @@ void ownCloudGui::slotLogout()
|
||||
list.append(account);
|
||||
}
|
||||
|
||||
for (const auto &ai : list) {
|
||||
for (const auto &ai : std::as_const(list)) {
|
||||
ai->signOutByUi();
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ void SelectiveSyncWidget::recursiveInsert(QTreeWidgetItem *parent, QStringList p
|
||||
if (parent->checkState(0) == Qt::Checked
|
||||
|| parent->checkState(0) == Qt::PartiallyChecked) {
|
||||
item->setCheckState(0, Qt::Checked);
|
||||
for (const QString &str : _oldBlackList) {
|
||||
for (const auto &str : std::as_const(_oldBlackList)) {
|
||||
if (str == path || str == QLatin1String("/")) {
|
||||
item->setCheckState(0, Qt::Unchecked);
|
||||
break;
|
||||
|
||||
@ -350,7 +350,7 @@ void SettingsDialog::customizeStyle()
|
||||
QString background(palette().base().color().name());
|
||||
_toolBar->setStyleSheet(TOOLBAR_CSS().arg(background, dark, highlightColor, highlightTextColor));
|
||||
|
||||
for (const auto a : _actionGroup->actions()) {
|
||||
for (const auto &a : _actionGroup->actions()) {
|
||||
QIcon icon = Theme::createColorAwareIcon(a->property("iconPath").toString(), palette());
|
||||
a->setIcon(icon);
|
||||
auto *btn = qobject_cast<QToolButton *>(_toolBar->widgetForAction(a));
|
||||
|
||||
@ -34,7 +34,7 @@ namespace OCC {
|
||||
*/
|
||||
static void updateFolder(const AccountPtr &account, QStringView path)
|
||||
{
|
||||
for (Folder *f : std::as_const(FolderMan::instance()->map())) {
|
||||
for (auto *f : std::as_const(FolderMan::instance()->map())) {
|
||||
if (f->accountState()->account() != account)
|
||||
continue;
|
||||
auto folderPath = f->remotePath();
|
||||
|
||||
@ -138,7 +138,7 @@ 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\">");
|
||||
for (const QSslCertificate &cert : _unknownCerts) {
|
||||
for (const auto &cert : _unknownCerts) {
|
||||
msg += QL("<div id=\"ca_error\">");
|
||||
// add the errors for this cert
|
||||
for (const auto &err : errors) {
|
||||
|
||||
@ -174,7 +174,7 @@ OCC::Activity Activity::fromActivityJson(const QJsonObject &json, const AccountP
|
||||
}
|
||||
|
||||
auto actions = json.value("actions").toArray();
|
||||
for (auto action : actions) {
|
||||
for (const auto action : actions) {
|
||||
activity._links.append(ActivityLink::createFomJsonObject(action.toObject()));
|
||||
}
|
||||
|
||||
|
||||
@ -278,7 +278,7 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
|
||||
return displayLocation();
|
||||
case ActionsLinksRole: {
|
||||
QList<QVariant> customList;
|
||||
for (const ActivityLink &activityLink : a._links) {
|
||||
for (const auto &activityLink : std::as_const(a._links)) {
|
||||
customList << QVariant::fromValue(activityLink);
|
||||
}
|
||||
return customList;
|
||||
@ -610,7 +610,7 @@ void ActivityListModel::addIgnoredFileToList(const Activity &newActivity)
|
||||
return;
|
||||
}
|
||||
|
||||
for (const Activity &activity : _listOfIgnoredFiles) {
|
||||
for (const auto &activity : _listOfIgnoredFiles) {
|
||||
if (activity._file == newActivity._file) {
|
||||
duplicate = true;
|
||||
break;
|
||||
|
||||
@ -96,7 +96,7 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
|
||||
ActivityList list;
|
||||
ActivityList callList;
|
||||
|
||||
for (auto element : std::as_const(notifies)) {
|
||||
for (const auto element : std::as_const(notifies)) {
|
||||
auto json = element.toObject();
|
||||
auto a = Activity::fromActivityJson(json, ai->account());
|
||||
|
||||
|
||||
@ -342,7 +342,7 @@ void User::slotReceivedPushActivity(Account *account)
|
||||
void User::slotCheckExpiredActivities()
|
||||
{
|
||||
const auto errorsList = _activityModel->errorsList();
|
||||
for (const Activity &activity : errorsList) {
|
||||
for (const auto &activity : errorsList) {
|
||||
if (activity._expireAtMsecs > 0 && QDateTime::currentDateTime().toMSecsSinceEpoch() >= activity._expireAtMsecs) {
|
||||
_activityModel->removeActivityFromActivityList(activity);
|
||||
}
|
||||
@ -589,7 +589,7 @@ void User::slotProgressInfo(const QString &folder, const ProgressInfo &progress)
|
||||
return;
|
||||
const auto &engine = f->syncEngine();
|
||||
const auto style = engine.lastLocalDiscoveryStyle();
|
||||
for (const Activity &activity : _activityModel->errorsList()) {
|
||||
for (const auto &activity : _activityModel->errorsList()) {
|
||||
if (activity._expireAtMsecs != -1) {
|
||||
// we process expired activities in a different slot
|
||||
continue;
|
||||
@ -638,7 +638,7 @@ void User::slotProgressInfo(const QString &folder, const ProgressInfo &progress)
|
||||
// We keep track very well of pending conflicts.
|
||||
// Inform other components about them.
|
||||
QStringList conflicts;
|
||||
for (const Activity &activity : _activityModel->errorsList()) {
|
||||
for (const auto &activity : _activityModel->errorsList()) {
|
||||
if (activity._folder == folder
|
||||
&& activity._syncFileItemStatus == SyncFileItem::Conflict) {
|
||||
conflicts.append(activity._file);
|
||||
|
||||
@ -210,8 +210,9 @@ bool Capabilities::isClientStatusReportingEnabled() const
|
||||
|
||||
QList<QByteArray> Capabilities::supportedChecksumTypes() const
|
||||
{
|
||||
QList<QByteArray> list;
|
||||
for (const auto &t : _capabilities["checksums"].toMap()["supportedTypes"].toList()) {
|
||||
const auto supportedTypes = _capabilities["checksums"].toMap()["supportedTypes"].toList();
|
||||
QList<QByteArray> list(supportedTypes.count());
|
||||
for (const auto &t : supportedTypes) {
|
||||
list.push_back(t.toByteArray());
|
||||
}
|
||||
return list;
|
||||
@ -372,8 +373,9 @@ bool Capabilities::privateLinkPropertyAvailable() const
|
||||
|
||||
QList<int> Capabilities::httpErrorCodesThatResetFailingChunkedUploads() const
|
||||
{
|
||||
QList<int> list;
|
||||
for (const auto &t : _capabilities["dav"].toMap()["httpErrorCodesThatResetFailingChunkedUploads"].toList()) {
|
||||
const auto httpErrorCodes = _capabilities["dav"].toMap()["httpErrorCodesThatResetFailingChunkedUploads"].toList();
|
||||
QList<int> list(httpErrorCodes.count());
|
||||
for (const auto &t : httpErrorCodes) {
|
||||
list.push_back(t.toInt());
|
||||
}
|
||||
return list;
|
||||
@ -445,7 +447,7 @@ void Capabilities::addDirectEditor(DirectEditor* directEditor)
|
||||
|
||||
DirectEditor* Capabilities::getDirectEditorForMimetype(const QMimeType &mimeType)
|
||||
{
|
||||
for (DirectEditor* editor : std::as_const(_directEditors)) {
|
||||
for (auto* editor : std::as_const(_directEditors)) {
|
||||
if(editor->hasMimetype(mimeType))
|
||||
return editor;
|
||||
}
|
||||
@ -455,7 +457,7 @@ DirectEditor* Capabilities::getDirectEditorForMimetype(const QMimeType &mimeType
|
||||
|
||||
DirectEditor* Capabilities::getDirectEditorForOptionalMimetype(const QMimeType &mimeType)
|
||||
{
|
||||
for (DirectEditor* editor : std::as_const(_directEditors)) {
|
||||
for (auto* editor : std::as_const(_directEditors)) {
|
||||
if(editor->hasOptionalMimetype(mimeType))
|
||||
return editor;
|
||||
}
|
||||
|
||||
@ -141,7 +141,10 @@ bool copy_dir_recursive(QString from_dir, QString to_dir)
|
||||
from_dir += QDir::separator();
|
||||
to_dir += QDir::separator();
|
||||
|
||||
for (const QString ©_file : dir.entryList(QDir::Files)) {
|
||||
const auto fileEntries = dir.entryList(QDir::Files);
|
||||
const auto dirEntries = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
|
||||
for (const auto ©_file : fileEntries) {
|
||||
QString from = from_dir + copy_file;
|
||||
QString to = to_dir + copy_file;
|
||||
|
||||
@ -150,7 +153,7 @@ bool copy_dir_recursive(QString from_dir, QString to_dir)
|
||||
}
|
||||
}
|
||||
|
||||
for (const QString ©_dir : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||
for (const auto ©_dir : dirEntries) {
|
||||
QString from = from_dir + copy_dir;
|
||||
QString to = to_dir + copy_dir;
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ bool CookieJar::restore(const QString &fileName)
|
||||
QList<QNetworkCookie> CookieJar::removeExpired(const QList<QNetworkCookie> &cookies)
|
||||
{
|
||||
QList<QNetworkCookie> updatedList;
|
||||
for (const QNetworkCookie &cookie : cookies) {
|
||||
for (const auto &cookie : cookies) {
|
||||
if (cookie.expirationDate() > QDateTime::currentDateTimeUtc() && !cookie.isSessionCookie()) {
|
||||
updatedList << cookie;
|
||||
}
|
||||
|
||||
@ -405,7 +405,8 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
|
||||
item->_errorString = tr("File names ending with a period are not supported on this file system.");
|
||||
} else {
|
||||
char invalid = '\0';
|
||||
for (char x : QByteArray("\\:?*\"<>|")) {
|
||||
constexpr QByteArrayView invalidChars("\\:?*\"<>|");
|
||||
for (char x : invalidChars) {
|
||||
if (item->_file.contains(x)) {
|
||||
invalid = x;
|
||||
break;
|
||||
|
||||
@ -346,7 +346,7 @@ void LsColJob::start()
|
||||
qCWarning(lcLsColJob) << "Propfind with no properties!";
|
||||
}
|
||||
QByteArray propStr;
|
||||
for (const QByteArray &prop : properties) {
|
||||
for (const auto &prop : properties) {
|
||||
if (prop.contains(':')) {
|
||||
int colIdx = prop.lastIndexOf(":");
|
||||
auto ns = prop.left(colIdx);
|
||||
|
||||
@ -553,7 +553,7 @@ void OwncloudPropagator::start(SyncFileItemVector &&items)
|
||||
QVector<PropagatorJob *> directoriesToRemove;
|
||||
QString removedDirectory;
|
||||
QString maybeConflictDirectory;
|
||||
for (const SyncFileItemPtr &item : items) {
|
||||
for (const SyncFileItemPtr &item : std::as_const(items)) {
|
||||
if (!removedDirectory.isEmpty() && item->_file.startsWith(removedDirectory)) {
|
||||
// this is an item in a directory which is going to be removed.
|
||||
auto *delDirJob = qobject_cast<PropagateDirectory *>(directoriesToRemove.first());
|
||||
@ -616,7 +616,7 @@ void OwncloudPropagator::start(SyncFileItemVector &&items)
|
||||
}
|
||||
}
|
||||
|
||||
for (PropagatorJob *it : std::as_const(directoriesToRemove)) {
|
||||
for (auto *it : std::as_const(directoriesToRemove)) {
|
||||
_rootJob->appendDirDeletionJob(it);
|
||||
}
|
||||
|
||||
@ -1347,7 +1347,7 @@ void PropagatorCompositeJob::finalize()
|
||||
qint64 PropagatorCompositeJob::committedDiskSpace() const
|
||||
{
|
||||
qint64 needed = 0;
|
||||
for (PropagatorJob *job : std::as_const(_runningJobs)) {
|
||||
for (auto *job : std::as_const(_runningJobs)) {
|
||||
needed += job->committedDiskSpace();
|
||||
}
|
||||
return needed;
|
||||
|
||||
@ -277,7 +277,7 @@ public:
|
||||
{
|
||||
if (!_runningJobs.empty()) {
|
||||
_abortsCount = _runningJobs.size();
|
||||
for (PropagatorJob *j : std::as_const(_runningJobs)) {
|
||||
for (auto *j : std::as_const(_runningJobs)) {
|
||||
if (abortType == AbortType::Asynchronous) {
|
||||
connect(j, &PropagatorJob::abortFinished,
|
||||
this, &PropagatorCompositeJob::slotSubJobAbortFinished);
|
||||
|
||||
@ -369,7 +369,7 @@ void ProgressInfo::updateEstimates()
|
||||
void ProgressInfo::recomputeCompletedSize()
|
||||
{
|
||||
qint64 r = _totalSizeOfCompletedJobs;
|
||||
for (const ProgressItem &i : _currentItems) {
|
||||
for (const auto &i : std::as_const(_currentItems)) {
|
||||
if (isSizeDependent(i._item))
|
||||
r += i._progress._completed;
|
||||
}
|
||||
|
||||
@ -865,7 +865,7 @@ void PropagateUploadFileCommon::abortNetworkJobs(
|
||||
};
|
||||
|
||||
// Abort all running jobs, except for explicitly excluded ones
|
||||
for (AbstractNetworkJob *job : std::as_const(_jobs)) {
|
||||
for (auto *job : std::as_const(_jobs)) {
|
||||
auto reply = job->reply();
|
||||
if (!reply || !reply->isRunning())
|
||||
continue;
|
||||
|
||||
@ -235,7 +235,7 @@ void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector &items)
|
||||
ProblemsMap oldProblems;
|
||||
std::swap(_syncProblems, oldProblems);
|
||||
|
||||
for (const SyncFileItemPtr &item : items) {
|
||||
for (const SyncFileItemPtr &item : std::as_const(items)) {
|
||||
qCInfo(lcStatusTracker) << "Investigating" << item->destination() << item->_status << item->_instruction << item->_direction;
|
||||
_dirtyPaths.remove(item->destination());
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user