Skip to content

Commit

Permalink
Replaced qAsConst with std::as_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 21, 2025
1 parent 951e54f commit 8840e8c
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/common/ownsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ QString SqlDatabase::error() const
void SqlDatabase::close()
{
if (_db) {
for (auto q : qAsConst(_queries)) {
for (auto q : std::as_const(_queries)) {
q->finish();
}
SQLITE_DO(sqlite3_close(_db));
Expand Down
3 changes: 2 additions & 1 deletion src/gui/folderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,8 @@ void FolderMan::slotAccountStateChanged()
qCInfo(lcFolderMan) << "Account" << accountName << "disconnected or paused, "
"terminating or descheduling sync folders";

for (Folder *f : qAsConst(_folderMap.values())) {
auto folderValues = _folderMap.values();
for (Folder *f : std::as_const(folderValues)) {
if (f
&& f->isSyncRunning()
&& f->accountState() == accountState) {
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 (Folder *folder : qAsConst(folderMan->map())) {
for (Folder *folder : std::as_const(folderMan->map())) {
folder->journalDb()->forceRemoteDiscoveryNextSync();
folderMan->scheduleFolder(folder);
}
Expand Down
4 changes: 2 additions & 2 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 : qAsConst(list)) {
for (QString 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 : qAsConst(list)) {
for (QString path : std::as_const(list)) {
auto size = job ? job->_folderInfos[path].size : 0;
path.remove(pathToRemove);

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 (QAction *a : qAsConst(_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
2 changes: 1 addition & 1 deletion 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 (Folder *f : qAsConst(FolderMan::instance()->map())) {
for (Folder *f : std::as_const(FolderMan::instance()->map())) {
if (f->accountState()->account() != account)
continue;
auto folderPath = f->remotePath();
Expand Down
4 changes: 2 additions & 2 deletions src/gui/sslbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ void SslButton::slotUpdateMenu()
const auto systemCerts = QSslConfiguration::systemCaCertificates();

QList<QSslCertificate> tmpChain;
for (const QSslCertificate &cert : qAsConst(chain)) {
for (const auto &cert : chain) {
tmpChain << cert;
if (systemCerts.contains(cert))
break;
}
chain = tmpChain;

// find trust anchor (informational only, verification is done by QSslSocket!)
for (const QSslCertificate &rootCA : systemCerts) {
for (const auto &rootCA : systemCerts) {
if (rootCA.issuerInfo(QSslCertificate::CommonName) == chain.last().issuerInfo(QSslCertificate::CommonName)
&& rootCA.issuerInfo(QSslCertificate::Organization) == chain.last().issuerInfo(QSslCertificate::Organization)) {
chain.append(rootCA);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/tray/notificationhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
ActivityList list;
ActivityList callList;

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

Expand Down
4 changes: 2 additions & 2 deletions src/libsync/capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void Capabilities::addDirectEditor(DirectEditor* directEditor)

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

DirectEditor* Capabilities::getDirectEditorForOptionalMimetype(const QMimeType &mimeType)
{
for (DirectEditor* editor : qAsConst(_directEditors)) {
for (DirectEditor* editor : std::as_const(_directEditors)) {
if(editor->hasOptionalMimetype(mimeType))
return editor;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2086,7 +2086,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
4 changes: 2 additions & 2 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 (PropagatorJob *it : qAsConst(directoriesToRemove)) {
for (PropagatorJob *it : std::as_const(directoriesToRemove)) {
_rootJob->appendDirDeletionJob(it);
}

Expand Down Expand Up @@ -1347,7 +1347,7 @@ void PropagatorCompositeJob::finalize()
qint64 PropagatorCompositeJob::committedDiskSpace() const
{
qint64 needed = 0;
for (PropagatorJob *job : qAsConst(_runningJobs)) {
for (PropagatorJob *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 (PropagatorJob *j : qAsConst(_runningJobs)) {
for (PropagatorJob *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 (AbstractNetworkJob *job : qAsConst(_jobs)) {
for (AbstractNetworkJob *job : std::as_const(_jobs)) {
auto reply = job->reply();
if (!reply || !reply->isRunning())
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/propagateuploadv1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void PropagateUploadFileV1::slotPutFinished()
SyncJournalDb::UploadInfo pi;
pi._valid = true;
auto currentChunk = job->_chunk;
for (auto *otherJob : qAsConst(_jobs)) {
for (auto *otherJob : std::as_const(_jobs)) {
// Take the minimum finished one
if (auto putJob = qobject_cast<PUTFileJob *>(job)) {
currentChunk = qMin(currentChunk, putJob->_chunk - 1);
Expand Down Expand Up @@ -373,7 +373,7 @@ void PropagateUploadFileV1::slotUploadProgress(qint64 sent, qint64 total)
sender()->setProperty("byteWritten", sent);
if (_jobs.count() > 1) {
amount -= (_jobs.count() - 1) * chunkSize();
for (QObject *j : qAsConst(_jobs)) {
for (QObject *j : std::as_const(_jobs)) {
amount += j->property("byteWritten").toULongLong();
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/propagatorjobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,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;
for (const auto &it : qAsConst(deleted)) {
for (const auto &it : deleted) {
if (!it.first.startsWith(propagator()->localPath()))
continue;
if (!deletedDir.isEmpty() && it.first.startsWith(deletedDir))
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void SyncEngine::deleteStaleUploadInfos(const SyncFileItemVector &syncItems)
{
// Find all blacklisted paths that we want to preserve.
QSet<QString> upload_file_paths;
for (const SyncFileItemPtr &it, syncItems) {
for (const SyncFileItemPtr &it: syncItems) {
if (it->_direction == SyncFileItem::Up
&& it->_type == ItemTypeFile
&& isFileTransferInstruction(it->_instruction)) {
Expand All @@ -250,7 +250,7 @@ void SyncEngine::deleteStaleUploadInfos(const SyncFileItemVector &syncItems)

// Delete the stales chunk on the server.
if (account()->capabilities().chunkingNg()) {
for (uint transferId : qAsConst(ids)) {
for (uint transferId : std::as_const(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));
Expand Down

0 comments on commit 8840e8c

Please sign in to comment.