Skip to content

Commit

Permalink
Carried out further fixes, changing types to auto and adding const
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Ariño Muñoz <[email protected]>
  • Loading branch information
Pabarino committed Feb 23, 2025
1 parent b285184 commit e15e009
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/common/syncjournaldb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 auto &it : _etagStorageFilter) {
for (const auto &it : std::as_const(_etagStorageFilter)) {
if (it.startsWith(prefix)) {
qCInfo(lcDb) << "Filtered writing the etag of" << prefix << "because it is a prefix of" << it;
record._etag = "_invalid_";
Expand Down
14 changes: 7 additions & 7 deletions src/gui/folderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ Folder *FolderMan::folder(const QString &alias)
void FolderMan::scheduleAllFolders()
{
const auto folderMapValues = _folderMap.values();
for (auto *f : folderMapValues) {
for (const auto f : folderMapValues) {
if (f && f->canSync()) {
scheduleFolder(f);
}
Expand Down Expand Up @@ -808,7 +808,7 @@ void FolderMan::slotRunOneEtagJob()
{
if (_currentEtagJob.isNull()) {
Folder *folder = nullptr;
for (auto *f : std::as_const(_folderMap)) {
for (const 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();
Expand Down Expand Up @@ -842,7 +842,7 @@ void FolderMan::slotAccountStateChanged()
qCInfo(lcFolderMan) << "Account" << accountName << "connected, scheduling its folders";

const auto folderMapValues = _folderMap.values();
for (auto *f : folderMapValues) {
for (const auto f : folderMapValues) {
if (f
&& f->canSync()
&& f->accountState() == accountState) {
Expand All @@ -854,7 +854,7 @@ void FolderMan::slotAccountStateChanged()
"terminating or descheduling sync folders";

const auto folderValues = _folderMap.values();
for (auto *f : folderValues) {
for (const auto f : folderValues) {
if (f
&& f->isSyncRunning()
&& f->accountState() == accountState) {
Expand Down Expand Up @@ -1358,7 +1358,7 @@ QStringList FolderMan::findFileInLocalFolders(const QString &relPath, const Acco
serverPath.prepend('/');

const auto mapValues = map().values();
for (auto *folder : mapValues) {
for (const auto folder : mapValues) {
if (acc && folder->accountState()->account() != acc) {
continue;
}
Expand Down Expand Up @@ -1706,7 +1706,7 @@ void FolderMan::trayOverallStatus(const QList<Folder *> &folders,
auto runSeen = false;
auto various = false;

for (const auto *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) {
Expand Down Expand Up @@ -2009,7 +2009,7 @@ void FolderMan::setIgnoreHiddenFiles(bool ignore)
{
// Note that the setting will revert to 'true' if all folders
// are deleted...
for (auto *folder : std::as_const(_folderMap)) {
for (const auto folder : std::as_const(_folderMap)) {
folder->setIgnoreHiddenFiles(ignore);
folder->saveToSettings();
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ void FolderWizardRemotePath::slotUpdateDirectories(const QStringList &list)
}
QStringList sortedList = list;
Utility::sortFilenames(sortedList);
for ( auto path : sortedList) {
for (auto path : sortedList) {
path.remove(webdavFolder);

// Don't allow to select subfolders of encrypted subfolders
Expand Down
2 changes: 1 addition & 1 deletion src/gui/ignorelisttablewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 (auto *folder : std::as_const(folderMan->map())) {
for (const auto folder : std::as_const(folderMan->map())) {
folder->journalDb()->forceRemoteDiscoveryNextSync();
folderMan->scheduleFolder(folder);
}
Expand Down
6 changes: 3 additions & 3 deletions src/gui/selectivesyncdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
// list of top-level folders as soon as possible.
if (_oldBlackList == QStringList("/")) {
_oldBlackList.clear();
for (QString path : std::as_const(list)) {
for (auto path : std::as_const(list)) {
path.remove(pathToRemove);
if (path.isEmpty()) {
continue;
Expand Down Expand Up @@ -249,7 +249,7 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
}

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

Expand Down Expand Up @@ -425,7 +425,7 @@ QStringList SelectiveSyncWidget::createBlackList(QTreeWidgetItem *root) const
} else {
// We did not load from the server so we reuse the one from the old black list
QString path = root->data(0, Qt::UserRole).toString();
for (const QString &it : _oldBlackList) {
for (const auto &it : _oldBlackList) {
if (it.startsWith(path))
result += it;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/gui/sharemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace OCC {
*/
static void updateFolder(const AccountPtr &account, QStringView path)
{
for (auto *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();
Expand Down Expand Up @@ -464,7 +464,7 @@ void ShareManager::createShare(const QString &path,
[=](const QJsonDocument &reply) {
// Find existing share permissions (if this was shared with us)
Share::Permissions existingPermissions = SharePermissionAll;
for (const QJsonValue &element : reply.object()["ocs"].toObject()["data"].toArray()) {
for (const auto &element : reply.object()["ocs"].toObject()["data"].toArray()) {
auto map = element.toObject();
if (map["file_target"] == path)
existingPermissions = Share::Permissions(map["permissions"].toInt());
Expand Down
2 changes: 1 addition & 1 deletion src/gui/tray/activitydata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ OCC::Activity Activity::fromActivityJson(const QJsonObject &json, const AccountP
}

auto actions = json.value("actions").toArray();
for (const auto action : actions) {
for (const auto &action : actions) {
activity._links.append(ActivityLink::createFomJsonObject(action.toObject()));
}

Expand Down
4 changes: 2 additions & 2 deletions src/gui/tray/notificationhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
}
_preFetchEtagHeader = postFetchEtagHeader;

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

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

ActivityList list;
ActivityList callList;

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

Expand Down
2 changes: 1 addition & 1 deletion src/libsync/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ void Account::fetchDirectEditors(const QUrl &directEditingURL, const QString &di
void Account::slotDirectEditingRecieved(const QJsonDocument &json)
{
auto data = json.object().value("ocs").toObject().value("data").toObject();
auto editors = data.value("editors").toObject();
const auto editors = data.value("editors").toObject();

for (const auto &editorKey : editors.keys()) {
auto editor = editors.value(editorKey).toObject();
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ void Capabilities::addDirectEditor(DirectEditor* directEditor)

DirectEditor* Capabilities::getDirectEditorForMimetype(const QMimeType &mimeType)
{
for (auto* editor : std::as_const(_directEditors)) {
for (const auto editor : std::as_const(_directEditors)) {
if(editor->hasMimetype(mimeType))
return editor;
}
Expand All @@ -457,7 +457,7 @@ DirectEditor* Capabilities::getDirectEditorForMimetype(const QMimeType &mimeType

DirectEditor* Capabilities::getDirectEditorForOptionalMimetype(const QMimeType &mimeType)
{
for (auto* editor : std::as_const(_directEditors)) {
for (const auto editor : std::as_const(_directEditors)) {
if(editor->hasOptionalMimetype(mimeType))
return editor;
}
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
} else {
char invalid = '\0';
constexpr QByteArrayView invalidChars("\\:?*\"<>|");
for (char x : invalidChars) {
for (const auto x : invalidChars) {
if (item->_file.contains(x)) {
invalid = x;
break;
Expand Down Expand Up @@ -2087,7 +2087,7 @@ int ProcessDirectoryJob::processSubJobs(int nbJobs)
}

int started = 0;
for (auto *rj : std::as_const(_runningJobs)) {
for (const auto rj : std::as_const(_runningJobs)) {
started += rj->processSubJobs(nbJobs - started);
if (started >= nbJobs)
return started;
Expand Down
6 changes: 3 additions & 3 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ void OwncloudPropagator::start(SyncFileItemVector &&items)
}
}

for (auto *it : std::as_const(directoriesToRemove)) {
for (const auto it : std::as_const(directoriesToRemove)) {
_rootJob->appendDirDeletionJob(it);
}

Expand All @@ -641,7 +641,7 @@ void OwncloudPropagator::startDirectoryPropagation(const SyncFileItemPtr &item,
// 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...
for (const SyncFileItemPtr &dirItem : items) {
for (const auto &dirItem : items) {
if (dirItem->destination().startsWith(item->destination() + "/")) {
dirItem->_instruction = CSYNC_INSTRUCTION_NONE;
_anotherSyncNeeded = true;
Expand Down Expand Up @@ -1347,7 +1347,7 @@ void PropagatorCompositeJob::finalize()
qint64 PropagatorCompositeJob::committedDiskSpace() const
{
qint64 needed = 0;
for (auto *job : std::as_const(_runningJobs)) {
for (const auto job : std::as_const(_runningJobs)) {
needed += job->committedDiskSpace();
}
return needed;
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/owncloudpropagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class PropagatorCompositeJob : public PropagatorJob
{
if (!_runningJobs.empty()) {
_abortsCount = _runningJobs.size();
for (auto *j : std::as_const(_runningJobs)) {
for (const auto j : std::as_const(_runningJobs)) {
if (abortType == AbortType::Asynchronous) {
connect(j, &PropagatorJob::abortFinished,
this, &PropagatorCompositeJob::slotSubJobAbortFinished);
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/propagateupload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ void PropagateUploadFileCommon::abortNetworkJobs(
};

// Abort all running jobs, except for explicitly excluded ones
for (auto *job : std::as_const(_jobs)) {
for (const auto job : std::as_const(_jobs)) {
auto reply = job->reply();
if (!reply || !reply->isRunning())
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/syncfilestatustracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector &items)
ProblemsMap oldProblems;
std::swap(_syncProblems, oldProblems);

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

Expand Down

0 comments on commit e15e009

Please sign in to comment.