Skip to content

Commit

Permalink
fix: replace deprecated qAsConst() by std::as_const() (#12011)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 authored Dec 9, 2024
1 parent 63bdefb commit c16d24a
Show file tree
Hide file tree
Showing 29 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion src/common/syncjournaldb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,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 : qAsConst(_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
4 changes: 2 additions & 2 deletions src/csync/csync_exclude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ bool ExcludedFiles::reloadExcludeFiles()
{
_allExcludes.clear();
bool success = true;
for (const auto &file : qAsConst(_excludeFiles)) {
for (const auto &file : std::as_const(_excludeFiles)) {
QFile f(file);
if (!f.open(QIODevice::ReadOnly)) {
success = false;
Expand Down Expand Up @@ -629,7 +629,7 @@ void ExcludedFiles::prepare()
pattern.append(appendMe);
};

for (auto exclude : qAsConst(_allExcludes)) {
for (auto exclude : std::as_const(_allExcludes)) {
if (exclude[0] == QLatin1Char('\n'))
continue; // empty line
if (exclude[0] == QLatin1Char('\r'))
Expand Down
4 changes: 2 additions & 2 deletions src/gui/accountmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ bool AccountManager::restoreFromLegacySettings()

void AccountManager::save(bool saveCredentials)
{
for (const auto &acc : qAsConst(_accounts)) {
for (const auto &acc : std::as_const(_accounts)) {
saveAccount(acc->account().data(), saveCredentials);
}

Expand Down Expand Up @@ -328,7 +328,7 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings)

AccountStatePtr AccountManager::account(const QString &name)
{
for (const auto &acc : qAsConst(_accounts)) {
for (const auto &acc : std::as_const(_accounts)) {
if (acc->account()->displayNameWithHost() == name) {
return acc;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/accountstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ void AccountState::checkConnectivity(bool blockJobs)
_tlsDialog->setAttribute(Qt::WA_DeleteOnClose);
QSet<QSslCertificate> certs;
certs.reserve(filteredErrors.size());
for (const auto &error : qAsConst(filteredErrors)) {
for (const auto &error : std::as_const(filteredErrors)) {
certs << error.certificate();
}
connect(_tlsDialog, &TlsErrorDialog::accepted, _tlsDialog, [certs, blockJobs, this]() {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/activitywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ActivityWidget::ActivityWidget(QWidget *parent)
showLabels();
}

for (const auto widget : qAsConst(_widgetForNotifId)) {
for (const auto widget : std::as_const(_widgetForNotifId)) {
if (widget->activity().accountUuid() == ast->account()->uuid()) {
scheduleWidgetToRemove(widget);
}
Expand Down
22 changes: 11 additions & 11 deletions src/gui/folderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ Folder *FolderMan::folder(const QByteArray &id)

void FolderMan::scheduleAllFolders()
{
for (auto *f : qAsConst(_folders)) {
for (auto *f : std::as_const(_folders)) {
if (f && f->canSync()) {
scheduler()->enqueueFolder(f);
}
Expand All @@ -374,7 +374,7 @@ void FolderMan::slotIsConnectedChanged()
if (accountState->isConnected()) {
qCInfo(lcFolderMan) << "Account" << accountName << "connected, scheduling its folders";

for (auto *f : qAsConst(_folders)) {
for (auto *f : std::as_const(_folders)) {
if (f
&& f->canSync()
&& f->accountState() == accountState) {
Expand All @@ -385,7 +385,7 @@ void FolderMan::slotIsConnectedChanged()
qCInfo(lcFolderMan) << "Account" << accountName << "disconnected or paused, "
"terminating or descheduling sync folders";

for (auto *f : qAsConst(_folders)) {
for (auto *f : std::as_const(_folders)) {
if (f
&& f->isSyncRunning()
&& f->accountState() == accountState) {
Expand Down Expand Up @@ -415,7 +415,7 @@ void FolderMan::slotRemoveFoldersForAccount(const AccountStatePtr &accountState)
QList<Folder *> foldersToRemove;
// reserve a magic number
foldersToRemove.reserve(16);
for (auto *folder : qAsConst(_folders)) {
for (auto *folder : std::as_const(_folders)) {
if (folder->accountState() == accountState) {
foldersToRemove.append(folder);
}
Expand All @@ -432,7 +432,7 @@ void FolderMan::slotServerVersionChanged(Account *account)
qCWarning(lcFolderMan) << "The server version is unsupported:" << account->capabilities().status().versionString()
<< "pausing all folders on the account";

for (auto &f : qAsConst(_folders)) {
for (auto &f : std::as_const(_folders)) {
if (f->accountState()->account().data() == account) {
f->setSyncPaused(true);
}
Expand Down Expand Up @@ -546,7 +546,7 @@ Folder *FolderMan::folderForPath(const QString &path, QString *relativePath)
{
QString absolutePath = QDir::cleanPath(path) + QLatin1Char('/');

for (auto *folder : qAsConst(_folders)) {
for (auto *folder : std::as_const(_folders)) {
const QString folderPath = folder->cleanPath() + QLatin1Char('/');

if (absolutePath.startsWith(folderPath, (Utility::isWindows() || Utility::isMac()) ? Qt::CaseInsensitive : Qt::CaseSensitive)) {
Expand All @@ -572,7 +572,7 @@ QStringList FolderMan::findFileInLocalFolders(const QString &relPath, const Acco
if (!serverPath.startsWith(QLatin1Char('/')))
serverPath.prepend(QLatin1Char('/'));

for (auto *folder : qAsConst(_folders)) {
for (auto *folder : std::as_const(_folders)) {
if (acc != nullptr && folder->accountState()->account() != acc) {
continue;
}
Expand Down Expand Up @@ -638,7 +638,7 @@ QString FolderMan::getBackupName(QString fullPathName) const

void FolderMan::setDirtyProxy()
{
for (auto *f : qAsConst(_folders)) {
for (auto *f : std::as_const(_folders)) {
if (f) {
if (f->accountState() && f->accountState()->account()
&& f->accountState()->account()->accessManager()) {
Expand All @@ -652,7 +652,7 @@ void FolderMan::setDirtyProxy()

void FolderMan::setDirtyNetworkLimits()
{
for (auto *f : qAsConst(_folders)) {
for (auto *f : std::as_const(_folders)) {
// set only in busy folders. Otherwise they read the config anyway.
if (f && f->isSyncRunning()) {
f->setDirtyNetworkLimits();
Expand Down Expand Up @@ -879,7 +879,7 @@ void FolderMan::setIgnoreHiddenFiles(bool ignore)
{
// Note that the setting will revert to 'true' if all folders
// are deleted...
for (auto *folder : qAsConst(_folders)) {
for (auto *folder : std::as_const(_folders)) {
folder->setIgnoreHiddenFiles(ignore);
folder->saveToSettings();
}
Expand Down Expand Up @@ -917,7 +917,7 @@ bool FolderMan::isSpaceSynced(GraphApi::Space *space) const

void FolderMan::slotReloadSyncOptions()
{
for (auto *f : qAsConst(_folders)) {
for (auto *f : std::as_const(_folders)) {
if (f) {
f->reloadSyncOptions();
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderwatcher_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void FolderWatcherPrivate::slotAddFolderRecursive(const QString &path)
<< path << "'";
}

for (const auto &subfolder : qAsConst(allSubfolders)) {
for (const auto &subfolder : std::as_const(allSubfolders)) {
QDir folder(subfolder);
if (folder.exists() && !_pathToWatch.contains(folder.absolutePath())) {
++subdirCount;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/folderwizard/folderwizardremotepath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void FolderWizardRemotePath::slotUpdateDirectories(const QStringList &list)
}
QStringList sortedList = list;
Utility::sortFilenames(sortedList);
for (auto path : qAsConst(sortedList)) {
for (auto path : std::as_const(sortedList)) {
path.remove(webdavFolder);
QStringList paths = path.split(QLatin1Char('/'));
if (paths.last().isEmpty())
Expand Down Expand Up @@ -323,7 +323,7 @@ bool FolderWizardRemotePath::isComplete() const

bool ok = true;

for (auto *f : qAsConst(FolderMan::instance()->folders())) {
for (auto *f : std::as_const(FolderMan::instance()->folders())) {
if (f->accountState()->account() != folderWizardPrivate()->accountState()->account()) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/lockwatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void LockWatcher::checkFiles()
unlocked.insert(p);
}
}
for (const auto &removed : qAsConst(unlocked)) {
for (const auto &removed : std::as_const(unlocked)) {
_watchedPaths.erase(removed);
}
}
2 changes: 1 addition & 1 deletion src/gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ QString setupTranslations(QApplication *app)
return lang;
};

for (QString lang : qAsConst(uiLanguages)) {
for (QString lang : std::as_const(uiLanguages)) {
lang = substLang(lang);
const QString trFile = Translations::translationsFilePrefix() + lang;
if (QTranslator *translator = new QTranslator(app); translator->load(trFile, trPath) || lang.startsWith(QLatin1String("en"))) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/models/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void ActivityListModel::startFetchJob(AccountStatePtr ast)
void ActivityListModel::combineActivityLists()
{
ActivityList resultList;
for (const ActivityList &list : qAsConst(_activityLists)) {
for (const ActivityList &list : std::as_const(_activityLists)) {
resultList.append(list);
}
setActivityList(std::move(resultList));
Expand Down
2 changes: 1 addition & 1 deletion src/gui/notificationwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void NotificationWidget::slotNotificationRequestFinished(bool success)

if (!success) {
qCWarning(lcNotifications) << "Notification Request to Server failed, leave button visible.";
for (auto *button : qAsConst(_buttons)) {
for (auto *button : std::as_const(_buttons)) {
button->setEnabled(true);
}
//: The second parameter is a time, such as 'failed at 09:58pm'
Expand Down
8 changes: 4 additions & 4 deletions src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,14 @@ void ownCloudGui::slotComputeOverallSyncStatus()
#ifdef Q_OS_WIN
// Windows has a 128-char tray tooltip length limit.
QStringList accountNames;
for (const auto &a : qAsConst(problemAccounts)) {
for (const auto &a : std::as_const(problemAccounts)) {
accountNames.append(a->account()->displayNameWithHost());
}
_tray->setToolTip(tr("Disconnected from %1").arg(accountNames.join(QLatin1String(", "))));
#else
QStringList messages;
messages.append(tr("Disconnected from accounts:"));
for (const auto &a : qAsConst(problemAccounts)) {
for (const auto &a : std::as_const(problemAccounts)) {
QString message = tr("Account %1").arg(a->account()->displayNameWithHost());
if (!a->connectionErrors().empty()) {
message += QLatin1String("\n") + a->connectionErrors().join(QLatin1String("\n"));
Expand Down Expand Up @@ -585,7 +585,7 @@ void ownCloudGui::updateContextMenu()
slotRebuildRecentMenus();

// We must call deleteLater because we might be called from the press in one of the actions.
for (auto *menu : qAsConst(_accountMenus)) {
for (auto *menu : std::as_const(_accountMenus)) {
menu->deleteLater();
}
_accountMenus.clear();
Expand Down Expand Up @@ -742,7 +742,7 @@ void ownCloudGui::slotRebuildRecentMenus()
{
_recentActionsMenu->clear();
if (!_recentItemsActions.isEmpty()) {
for (auto *a : qAsConst(_recentItemsActions)) {
for (auto *a : std::as_const(_recentItemsActions)) {
_recentActionsMenu->addAction(a);
}
_recentActionsMenu->addSeparator();
Expand Down
8 changes: 4 additions & 4 deletions src/gui/selectivesyncwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void SelectiveSyncWidget::recursiveInsert(QTreeWidgetItem *parent, QStringList p
item = new SelectiveSyncTreeViewItem(parent);
if (parent->checkState(0) == Qt::Checked || parent->checkState(0) == Qt::PartiallyChecked) {
item->setCheckState(0, Qt::Checked);
for (const auto &str : qAsConst(_oldBlackList)) {
for (const auto &str : std::as_const(_oldBlackList)) {
if (str == path || str == QLatin1Char('/')) {
item->setCheckState(0, Qt::Unchecked);
break;
Expand Down Expand Up @@ -225,7 +225,7 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)

QStringList relativeList;
relativeList.reserve(list.size());
for (const QString &path : qAsConst(list)) {
for (const QString &path : std::as_const(list)) {
Q_ASSERT(path.startsWith(rootPath));
const QString relativePath = path.mid(rootPath.size());
if (!relativePath.isEmpty()) {
Expand All @@ -237,7 +237,7 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
// list of top-level folders as soon as possible.
if (_oldBlackList.size() == 1 && _oldBlackList.contains(QLatin1String("/"))) {
_oldBlackList.clear();
for (const QString &path : qAsConst(relativeList)) {
for (const QString &path : std::as_const(relativeList)) {
_oldBlackList.insert(path);
}
}
Expand Down Expand Up @@ -270,7 +270,7 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
const bool showChildIndicator = relativeList.size() > 1 || list.contains(rootPath);

Utility::sortFilenames(relativeList);
for (const QString &path : qAsConst(relativeList)) {
for (const QString &path : std::as_const(relativeList)) {
const auto size = job ? job->sizes().value(Utility::ensureTrailingSlash(Utility::concatUrlPathItems({rootPath, path}))) : 0;
const QStringList paths = path.split(QLatin1Char('/'), Qt::SkipEmptyParts);
if (paths.isEmpty()) {
Expand Down
6 changes: 3 additions & 3 deletions src/gui/sharee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ void ShareeModel::fetch(const QString &search, const ShareeSet &blacklist)

// Filter sharees that we have already shared with
QVector<QSharedPointer<Sharee>> filteredSharees;
for (const auto &sharee : qAsConst(newSharees)) {
for (const auto &sharee : std::as_const(newSharees)) {
bool found = false;
for (const auto &blacklistSharee : qAsConst(_shareeBlacklist)) {
for (const auto &blacklistSharee : std::as_const(_shareeBlacklist)) {
if (sharee->type() == blacklistSharee->type() && sharee->shareWith() == blacklistSharee->shareWith()) {
found = true;
break;
Expand Down Expand Up @@ -194,7 +194,7 @@ void ShareeModel::setNewSharees(const QVector<QSharedPointer<Sharee>> &newSharee

QModelIndexList newPersistant;
newPersistant.reserve(persistent.size());
for (const auto &sharee : qAsConst(oldPersistantSharee)) {
for (const auto &sharee : std::as_const(oldPersistantSharee)) {
FindShareeHelper helper = { sharee };
auto it = std::find_if(_sharees.constBegin(), _sharees.constEnd(), helper);
if (it == _sharees.constEnd()) {
Expand Down
6 changes: 3 additions & 3 deletions src/gui/socketapi/socketapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void SocketApi::slotNewConnection()

auto listener = QSharedPointer<SocketListener>::create(socket);
_listeners.insert(socket, listener);
for (const auto &a : qAsConst(_registeredAccounts)) {
for (const auto &a : std::as_const(_registeredAccounts)) {
if (a->hasDefaultSyncRoot()) {
broadcastMessage(buildRegisterPathMessage(Utility::stripTrailingSlash(a->defaultSyncRoot())));
}
Expand Down Expand Up @@ -406,7 +406,7 @@ void SocketApi::slotUpdateFolderView(Folder *f)

void SocketApi::broadcastMessage(const QString &msg, bool doWait)
{
for (const auto &listener : qAsConst(_listeners)) {
for (const auto &listener : std::as_const(_listeners)) {
listener->sendMessage(msg, doWait);
}
}
Expand Down Expand Up @@ -457,7 +457,7 @@ void SocketApi::broadcastStatusPushMessage(const QString &systemPath, SyncFileSt
QString msg = buildMessage(QStringLiteral("STATUS"), systemPath, fileStatus.toSocketAPIString());
Q_ASSERT(!systemPath.endsWith(QLatin1Char('/')));
auto directoryHash = qHash(systemPath.left(systemPath.lastIndexOf(QLatin1Char('/'))));
for (const auto &listener : qAsConst(_listeners)) {
for (const auto &listener : std::as_const(_listeners)) {
listener->sendMessageIfDirectoryMonitored(msg, directoryHash);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/bandwidthmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void BandwidthManager::relativeUploadDelayTimerExpired()
_relativeLimitCurrentMeasuredDevice->setChoked(false);

// choke all other UploadDevices
for (auto *ud : qAsConst(_relativeUploadDeviceList)) {
for (auto *ud : std::as_const(_relativeUploadDeviceList)) {
if (ud != _relativeLimitCurrentMeasuredDevice) {
ud->setBandwidthLimited(true);
ud->setChoked(true);
Expand Down Expand Up @@ -382,7 +382,7 @@ void BandwidthManager::absoluteLimitTimerExpired()
if (usingAbsoluteUploadLimit() && !_absoluteUploadDeviceList.empty()) {
qint64 quotaPerDevice = _currentUploadLimit / _absoluteUploadDeviceList.size();
qCDebug(lcBandwidthManager) << quotaPerDevice << _absoluteUploadDeviceList.size() << _currentUploadLimit;
for (auto *device : qAsConst(_absoluteUploadDeviceList)) {
for (auto *device : std::as_const(_absoluteUploadDeviceList)) {
device->giveBandwidthQuota(quotaPerDevice);
qCDebug(lcBandwidthManager) << "Gave " << quotaPerDevice / 1024.0 << " kB to" << device;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ int ProcessDirectoryJob::processSubJobs(int nbJobs)
}

int started = 0;
for (auto *rj : qAsConst(_runningJobs)) {
for (auto *rj : std::as_const(_runningJobs)) {
started += rj->processSubJobs(nbJobs - started);
if (started >= nbJobs)
return started;
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/networkjobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void PropfindJob::start()
"<d:propfind xmlns:d=\"DAV:\">"
"<d:prop>");

for (const QByteArray &prop : qAsConst(_properties)) {
for (const QByteArray &prop : std::as_const(_properties)) {
const int colIdx = prop.lastIndexOf(':');
if (colIdx >= 0) {
stream << QByteArrayLiteral("<") << prop.mid(colIdx + 1) << QByteArrayLiteral(" xmlns=\"") << prop.left(colIdx) << QByteArrayLiteral("\"/>");
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ void OwncloudPropagator::start(SyncFileItemSet &&items)
// See the `else` statment in the second step.
QString maybeConflictDirectory;

for (const auto &item : qAsConst(items)) {
for (const auto &item : std::as_const(items)) {
// First check if this is an item in a directory which is going to be removed.
if (currentRemoveDirectoryJob && FileSystem::isChildPathOf(item->_file, currentRemoveDirectoryJob->path())) {
// Check the sync instruction for the item:
Expand Down Expand Up @@ -508,7 +508,7 @@ void OwncloudPropagator::start(SyncFileItemSet &&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...
for (const auto &item2 : qAsConst(items)) {
for (const auto &item2 : std::as_const(items)) {
if (item2 != item && FileSystem::isChildPathOf(item2->destination(), item->destination())) {
item2->setInstruction(CSYNC_INSTRUCTION_NONE);
_anotherSyncNeeded = true;
Expand Down
Loading

0 comments on commit c16d24a

Please sign in to comment.