Skip to content

Commit e15e009

Browse files
committed
Carried out further fixes, changing types to auto and adding const
Signed-off-by: Pablo Ariño Muñoz <[email protected]>
1 parent b285184 commit e15e009

16 files changed

+30
-30
lines changed

src/common/syncjournaldb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ Result<void, QString> SyncJournalDb::setFileRecord(const SyncJournalFileRecord &
950950
if (!_etagStorageFilter.isEmpty()) {
951951
// If we are a directory that should not be read from db next time, don't write the etag
952952
QByteArray prefix = record._path + "/";
953-
for (const auto &it : _etagStorageFilter) {
953+
for (const auto &it : std::as_const(_etagStorageFilter)) {
954954
if (it.startsWith(prefix)) {
955955
qCInfo(lcDb) << "Filtered writing the etag of" << prefix << "because it is a prefix of" << it;
956956
record._etag = "_invalid_";

src/gui/folderman.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ Folder *FolderMan::folder(const QString &alias)
660660
void FolderMan::scheduleAllFolders()
661661
{
662662
const auto folderMapValues = _folderMap.values();
663-
for (auto *f : folderMapValues) {
663+
for (const auto f : folderMapValues) {
664664
if (f && f->canSync()) {
665665
scheduleFolder(f);
666666
}
@@ -808,7 +808,7 @@ void FolderMan::slotRunOneEtagJob()
808808
{
809809
if (_currentEtagJob.isNull()) {
810810
Folder *folder = nullptr;
811-
for (auto *f : std::as_const(_folderMap)) {
811+
for (const auto f : std::as_const(_folderMap)) {
812812
if (f->etagJob()) {
813813
// Caveat: always grabs the first folder with a job, but we think this is Ok for now and avoids us having a separate queue.
814814
_currentEtagJob = f->etagJob();
@@ -842,7 +842,7 @@ void FolderMan::slotAccountStateChanged()
842842
qCInfo(lcFolderMan) << "Account" << accountName << "connected, scheduling its folders";
843843

844844
const auto folderMapValues = _folderMap.values();
845-
for (auto *f : folderMapValues) {
845+
for (const auto f : folderMapValues) {
846846
if (f
847847
&& f->canSync()
848848
&& f->accountState() == accountState) {
@@ -854,7 +854,7 @@ void FolderMan::slotAccountStateChanged()
854854
"terminating or descheduling sync folders";
855855

856856
const auto folderValues = _folderMap.values();
857-
for (auto *f : folderValues) {
857+
for (const auto f : folderValues) {
858858
if (f
859859
&& f->isSyncRunning()
860860
&& f->accountState() == accountState) {
@@ -1358,7 +1358,7 @@ QStringList FolderMan::findFileInLocalFolders(const QString &relPath, const Acco
13581358
serverPath.prepend('/');
13591359

13601360
const auto mapValues = map().values();
1361-
for (auto *folder : mapValues) {
1361+
for (const auto folder : mapValues) {
13621362
if (acc && folder->accountState()->account() != acc) {
13631363
continue;
13641364
}
@@ -1706,7 +1706,7 @@ void FolderMan::trayOverallStatus(const QList<Folder *> &folders,
17061706
auto runSeen = false;
17071707
auto various = false;
17081708

1709-
for (const auto *folder : std::as_const(folders)) {
1709+
for (const auto folder : std::as_const(folders)) {
17101710
// We've already seen an error, worst case met.
17111711
// No need to check the remaining folders.
17121712
if (errorsSeen) {
@@ -2009,7 +2009,7 @@ void FolderMan::setIgnoreHiddenFiles(bool ignore)
20092009
{
20102010
// Note that the setting will revert to 'true' if all folders
20112011
// are deleted...
2012-
for (auto *folder : std::as_const(_folderMap)) {
2012+
for (const auto folder : std::as_const(_folderMap)) {
20132013
folder->setIgnoreHiddenFiles(ignore);
20142014
folder->saveToSettings();
20152015
}

src/gui/folderwizard.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ void FolderWizardRemotePath::slotUpdateDirectories(const QStringList &list)
367367
}
368368
QStringList sortedList = list;
369369
Utility::sortFilenames(sortedList);
370-
for ( auto path : sortedList) {
370+
for (auto path : sortedList) {
371371
path.remove(webdavFolder);
372372

373373
// Don't allow to select subfolders of encrypted subfolders

src/gui/ignorelisttablewidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void IgnoreListTableWidget::slotWriteIgnoreFile(const QString & file)
100100
// We need to force a remote discovery after a change of the ignore list.
101101
// Otherwise we would not download the files/directories that are no longer
102102
// ignored (because the remote etag did not change) (issue #3172)
103-
for (auto *folder : std::as_const(folderMan->map())) {
103+
for (const auto folder : std::as_const(folderMan->map())) {
104104
folder->journalDb()->forceRemoteDiscoveryNextSync();
105105
folderMan->scheduleFolder(folder);
106106
}

src/gui/selectivesyncdialog.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
218218
// list of top-level folders as soon as possible.
219219
if (_oldBlackList == QStringList("/")) {
220220
_oldBlackList.clear();
221-
for (QString path : std::as_const(list)) {
221+
for (auto path : std::as_const(list)) {
222222
path.remove(pathToRemove);
223223
if (path.isEmpty()) {
224224
continue;
@@ -249,7 +249,7 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
249249
}
250250

251251
Utility::sortFilenames(list);
252-
for (QString path : std::as_const(list)) {
252+
for (auto path : std::as_const(list)) {
253253
auto size = job ? job->_folderInfos[path].size : 0;
254254
path.remove(pathToRemove);
255255

@@ -425,7 +425,7 @@ QStringList SelectiveSyncWidget::createBlackList(QTreeWidgetItem *root) const
425425
} else {
426426
// We did not load from the server so we reuse the one from the old black list
427427
QString path = root->data(0, Qt::UserRole).toString();
428-
for (const QString &it : _oldBlackList) {
428+
for (const auto &it : _oldBlackList) {
429429
if (it.startsWith(path))
430430
result += it;
431431
}

src/gui/settingsdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void SettingsDialog::customizeStyle()
350350
QString background(palette().base().color().name());
351351
_toolBar->setStyleSheet(TOOLBAR_CSS().arg(background, dark, highlightColor, highlightTextColor));
352352

353-
for (const auto &a : _actionGroup->actions()) {
353+
for (const auto a : _actionGroup->actions()) {
354354
QIcon icon = Theme::createColorAwareIcon(a->property("iconPath").toString(), palette());
355355
a->setIcon(icon);
356356
auto *btn = qobject_cast<QToolButton *>(_toolBar->widgetForAction(a));

src/gui/sharemanager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace OCC {
3434
*/
3535
static void updateFolder(const AccountPtr &account, QStringView path)
3636
{
37-
for (auto *f : std::as_const(FolderMan::instance()->map())) {
37+
for (auto f : std::as_const(FolderMan::instance()->map())) {
3838
if (f->accountState()->account() != account)
3939
continue;
4040
auto folderPath = f->remotePath();
@@ -464,7 +464,7 @@ void ShareManager::createShare(const QString &path,
464464
[=](const QJsonDocument &reply) {
465465
// Find existing share permissions (if this was shared with us)
466466
Share::Permissions existingPermissions = SharePermissionAll;
467-
for (const QJsonValue &element : reply.object()["ocs"].toObject()["data"].toArray()) {
467+
for (const auto &element : reply.object()["ocs"].toObject()["data"].toArray()) {
468468
auto map = element.toObject();
469469
if (map["file_target"] == path)
470470
existingPermissions = Share::Permissions(map["permissions"].toInt());

src/gui/tray/activitydata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ OCC::Activity Activity::fromActivityJson(const QJsonObject &json, const AccountP
174174
}
175175

176176
auto actions = json.value("actions").toArray();
177-
for (const auto action : actions) {
177+
for (const auto &action : actions) {
178178
activity._links.append(ActivityLink::createFomJsonObject(action.toObject()));
179179
}
180180

src/gui/tray/notificationhandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
8989
}
9090
_preFetchEtagHeader = postFetchEtagHeader;
9191

92-
auto notifies = json.object().value("ocs").toObject().value("data").toArray();
92+
const auto notifies = json.object().value("ocs").toObject().value("data").toArray();
9393

9494
auto *ai = qvariant_cast<AccountState *>(sender()->property(propertyAccountStateC));
9595

9696
ActivityList list;
9797
ActivityList callList;
9898

99-
for (const auto element : std::as_const(notifies)) {
99+
for (const auto element : notifies) {
100100
auto json = element.toObject();
101101
auto a = Activity::fromActivityJson(json, ai->account());
102102

src/libsync/account.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ void Account::fetchDirectEditors(const QUrl &directEditingURL, const QString &di
937937
void Account::slotDirectEditingRecieved(const QJsonDocument &json)
938938
{
939939
auto data = json.object().value("ocs").toObject().value("data").toObject();
940-
auto editors = data.value("editors").toObject();
940+
const auto editors = data.value("editors").toObject();
941941

942942
for (const auto &editorKey : editors.keys()) {
943943
auto editor = editors.value(editorKey).toObject();

src/libsync/capabilities.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ void Capabilities::addDirectEditor(DirectEditor* directEditor)
447447

448448
DirectEditor* Capabilities::getDirectEditorForMimetype(const QMimeType &mimeType)
449449
{
450-
for (auto* editor : std::as_const(_directEditors)) {
450+
for (const auto editor : std::as_const(_directEditors)) {
451451
if(editor->hasMimetype(mimeType))
452452
return editor;
453453
}
@@ -457,7 +457,7 @@ DirectEditor* Capabilities::getDirectEditorForMimetype(const QMimeType &mimeType
457457

458458
DirectEditor* Capabilities::getDirectEditorForOptionalMimetype(const QMimeType &mimeType)
459459
{
460-
for (auto* editor : std::as_const(_directEditors)) {
460+
for (const auto editor : std::as_const(_directEditors)) {
461461
if(editor->hasOptionalMimetype(mimeType))
462462
return editor;
463463
}

src/libsync/discovery.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
406406
} else {
407407
char invalid = '\0';
408408
constexpr QByteArrayView invalidChars("\\:?*\"<>|");
409-
for (char x : invalidChars) {
409+
for (const auto x : invalidChars) {
410410
if (item->_file.contains(x)) {
411411
invalid = x;
412412
break;
@@ -2087,7 +2087,7 @@ int ProcessDirectoryJob::processSubJobs(int nbJobs)
20872087
}
20882088

20892089
int started = 0;
2090-
for (auto *rj : std::as_const(_runningJobs)) {
2090+
for (const auto rj : std::as_const(_runningJobs)) {
20912091
started += rj->processSubJobs(nbJobs - started);
20922092
if (started >= nbJobs)
20932093
return started;

src/libsync/owncloudpropagator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ void OwncloudPropagator::start(SyncFileItemVector &&items)
616616
}
617617
}
618618

619-
for (auto *it : std::as_const(directoriesToRemove)) {
619+
for (const auto it : std::as_const(directoriesToRemove)) {
620620
_rootJob->appendDirDeletionJob(it);
621621
}
622622

@@ -641,7 +641,7 @@ void OwncloudPropagator::startDirectoryPropagation(const SyncFileItemPtr &item,
641641
// checkForPermissions() has already run and used the permissions
642642
// of the file we're about to delete to decide whether uploading
643643
// to the new dir is ok...
644-
for (const SyncFileItemPtr &dirItem : items) {
644+
for (const auto &dirItem : items) {
645645
if (dirItem->destination().startsWith(item->destination() + "/")) {
646646
dirItem->_instruction = CSYNC_INSTRUCTION_NONE;
647647
_anotherSyncNeeded = true;
@@ -1347,7 +1347,7 @@ void PropagatorCompositeJob::finalize()
13471347
qint64 PropagatorCompositeJob::committedDiskSpace() const
13481348
{
13491349
qint64 needed = 0;
1350-
for (auto *job : std::as_const(_runningJobs)) {
1350+
for (const auto job : std::as_const(_runningJobs)) {
13511351
needed += job->committedDiskSpace();
13521352
}
13531353
return needed;

src/libsync/owncloudpropagator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class PropagatorCompositeJob : public PropagatorJob
277277
{
278278
if (!_runningJobs.empty()) {
279279
_abortsCount = _runningJobs.size();
280-
for (auto *j : std::as_const(_runningJobs)) {
280+
for (const auto j : std::as_const(_runningJobs)) {
281281
if (abortType == AbortType::Asynchronous) {
282282
connect(j, &PropagatorJob::abortFinished,
283283
this, &PropagatorCompositeJob::slotSubJobAbortFinished);

src/libsync/propagateupload.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ void PropagateUploadFileCommon::abortNetworkJobs(
865865
};
866866

867867
// Abort all running jobs, except for explicitly excluded ones
868-
for (auto *job : std::as_const(_jobs)) {
868+
for (const auto job : std::as_const(_jobs)) {
869869
auto reply = job->reply();
870870
if (!reply || !reply->isRunning())
871871
continue;

src/libsync/syncfilestatustracker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector &items)
235235
ProblemsMap oldProblems;
236236
std::swap(_syncProblems, oldProblems);
237237

238-
for (const SyncFileItemPtr &item : std::as_const(items)) {
238+
for (const auto &item : std::as_const(items)) {
239239
qCInfo(lcStatusTracker) << "Investigating" << item->destination() << item->_status << item->_instruction << item->_direction;
240240
_dirtyPaths.remove(item->destination());
241241

0 commit comments

Comments
 (0)