Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.16] Removed deprecated Qt macros/functions #7915

Merged
merged 6 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/common/ownsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <QDateTime>

Check failure on line 19 in src/common/ownsql.cpp

View workflow job for this annotation

GitHub Actions / build

src/common/ownsql.cpp:19:10 [clang-diagnostic-error]

'QDateTime' file not found
#include <QLoggingCategory>
#include <QString>
#include <QFile>
Expand Down Expand Up @@ -186,7 +186,8 @@
void SqlDatabase::close()
{
if (_db) {
foreach (auto q, _queries) {
const auto queries = _queries;
for (const auto q : queries) {
q->finish();
}
SQLITE_DO(sqlite3_close(_db));
Expand Down
4 changes: 2 additions & 2 deletions src/common/syncjournaldb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <QCryptographicHash>

Check failure on line 19 in src/common/syncjournaldb.cpp

View workflow job for this annotation

GitHub Actions / build

src/common/syncjournaldb.cpp:19:10 [clang-diagnostic-error]

'QCryptographicHash' file not found
#include <QFile>
#include <QLoggingCategory>
#include <QStringList>
Expand Down Expand Up @@ -950,7 +950,7 @@
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 + "/";
foreach (const QByteArray &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 Expand Up @@ -1718,7 +1718,7 @@

qCDebug(lcDb) << "Removing stale" << name << "entries:" << entries.join(QStringLiteral(", "));
// FIXME: Was ported from execBatch, check if correct!
foreach (const QString &entry, entries) {
for (const auto &entry : entries) {
query.reset_and_clear_bindings();
query.bindValue(1, entry);
if (!query.exec()) {
Expand Down
15 changes: 8 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 (Folder *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 (Folder *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 (Folder *f : folderMapValues) {
for (const auto f : folderMapValues) {
if (f
&& f->canSync()
&& f->accountState() == accountState) {
Expand All @@ -853,7 +853,8 @@ void FolderMan::slotAccountStateChanged()
qCInfo(lcFolderMan) << "Account" << accountName << "disconnected or paused, "
"terminating or descheduling sync folders";

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

const auto mapValues = map().values();
for (Folder *folder : mapValues) {
for (const auto folder : mapValues) {
if (acc && folder->accountState()->account() != acc) {
continue;
}
Expand Down Expand Up @@ -1705,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) {
Expand Down Expand Up @@ -2008,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 (const auto folder : std::as_const(_folderMap)) {
folder->setIgnoreHiddenFiles(ignore);
folder->saveToSettings();
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ bool FolderWizardRemotePath::selectByPath(QString path)
QTreeWidgetItem *it = _ui.folderTreeWidget->topLevelItem(0);
if (!path.isEmpty()) {
const QStringList pathTrail = path.split(QLatin1Char('/'));
foreach (const QString &path, pathTrail) {
for (const auto &path : pathTrail) {
if (!it) {
return false;
}
Expand Down Expand Up @@ -367,7 +367,7 @@ void FolderWizardRemotePath::slotUpdateDirectories(const QStringList &list)
}
QStringList sortedList = list;
Utility::sortFilenames(sortedList);
foreach (QString 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)
foreach (Folder *folder, folderMan->map()) {
for (const auto folder : std::as_const(folderMan->map())) {
folder->journalDb()->forceRemoteDiscoveryNextSync();
folderMan->scheduleFolder(folder);
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/lockwatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void LockWatcher::checkFiles()
{
QSet<QString> unlocked;

foreach (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);
Expand Down
10 changes: 4 additions & 6 deletions src/gui/openfilemanager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/openfilemanager.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/openfilemanager.cpp

File src/gui/openfilemanager.cpp does not conform to Custom style guidelines. (lines 64)
* Copyright (C) by Klaas Freitag <[email protected]>
* Copyright (C) by Daniel Molkentin <[email protected]>
*
Expand Down Expand Up @@ -60,12 +60,10 @@
return QString();

QFileInfo fi;
QStringList dirs = xdgDataDirs();
QStringList subdirs;
subdirs << "/applications/"
<< "/applications/kde4/";
foreach (QString dir, dirs) {
foreach (QString subdir, subdirs) {
const QStringList dirs = xdgDataDirs();

Check warning on line 63 in src/gui/openfilemanager.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/openfilemanager.cpp:63:23 [cppcoreguidelines-init-variables]

variable 'dirs' is not initialized
const QStringList subdirs { "/applications/", "/applications/kde4/" };

Check warning on line 64 in src/gui/openfilemanager.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/openfilemanager.cpp:64:23 [cppcoreguidelines-init-variables]

variable 'subdirs' is not initialized
for (const auto &dir : dirs) {
for (const auto &subdir : subdirs) {
fi.setFile(dir + subdir + fileName);
if (fi.exists()) {
return fi.absoluteFilePath();
Expand Down
8 changes: 4 additions & 4 deletions src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ void ownCloudGui::slotComputeOverallSyncStatus()
#ifdef Q_OS_WIN
// Windows has a 128-char tray tooltip length limit.
QStringList accountNames;
foreach (AccountStatePtr a, problemAccounts) {
for (const AccountStatePtr &a : problemAccounts) {
accountNames.append(a->account()->displayName());
}
_tray->setToolTip(tr("Disconnected from %1").arg(accountNames.join(QLatin1String(", "))));
Expand Down Expand Up @@ -569,8 +569,8 @@ void ownCloudGui::slotLogin()
account->account()->resetRejectedCertificates();
account->signIn();
} else {
auto list = AccountManager::instance()->accounts();
foreach (const auto &a, list) {
const auto list = AccountManager::instance()->accounts();
for (const auto &a : list) {
a->signIn();
}
}
Expand All @@ -584,7 +584,7 @@ void ownCloudGui::slotLogout()
list.append(account);
}

foreach (const auto &ai, list) {
for (const auto &ai : std::as_const(list)) {
ai->signOutByUi();
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/gui/selectivesyncdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
foreach (const QString &str, _oldBlackList) {
for (const auto &str : std::as_const(_oldBlackList)) {
if (str == path || str == QLatin1String("/")) {
item->setCheckState(0, Qt::Unchecked);
break;
Expand Down 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();
foreach (QString path, 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);
foreach (QString path, 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();
foreach (const QString &it, _oldBlackList) {
for (const auto &it : _oldBlackList) {
if (it.startsWith(path))
result += it;
}
Expand Down Expand Up @@ -533,7 +533,7 @@ void SelectiveSyncDialog::accept()
// (the ones that are no longer in the blacklist)
auto blackListSet = QSet<QString>{blackList.begin(), blackList.end()};
auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet);
foreach (const auto &it, changes) {
for (const auto &it : changes) {
_folder->journalDb()->schedulePathForRemoteDiscovery(it);
_folder->schedulePathForLocalDiscovery(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));

Q_FOREACH (QAction *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
6 changes: 3 additions & 3 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)
{
foreach (Folder *f, 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;
foreach (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 Expand Up @@ -559,7 +559,7 @@ const QList<SharePtr> ShareManager::parseShares(const QJsonDocument &reply) cons

QList<SharePtr> shares;

foreach (const auto &share, tmpShares) {
for (const auto &share : tmpShares) {
auto data = share.toObject();

auto shareType = data.value("share_type").toInt();
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;
foreach (QSslCertificate cert, 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
4 changes: 2 additions & 2 deletions src/gui/sslerrordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "configfile.h"

Check failure on line 14 in src/gui/sslerrordialog.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/sslerrordialog.cpp:14:10 [clang-diagnostic-error]

'configfile.h' file not found
#include "sslerrordialog.h"
#include "theme.h"

Expand Down Expand Up @@ -138,10 +138,10 @@
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\">");
foreach (const QSslCertificate &cert, _unknownCerts) {
for (const auto &cert : _unknownCerts) {
msg += QL("<div id=\"ca_error\">");
// add the errors for this cert
foreach (QSslError err, errors) {
for (const auto &err : errors) {
if (err.certificate() == cert) {
msg += QL("<p>") + err.errorString() + QL("</p>");
}
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 @@ -12,7 +12,7 @@
* for more details.
*/

#include <QtCore>

Check failure on line 15 in src/gui/tray/activitydata.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/tray/activitydata.cpp:15:10 [clang-diagnostic-error]

'QtCore' file not found

#include "activitydata.h"
#include "folderman.h"
Expand Down Expand Up @@ -174,7 +174,7 @@
}

auto actions = json.value("actions").toArray();
foreach (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/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
return displayLocation();
case ActionsLinksRole: {
QList<QVariant> customList;
foreach (ActivityLink activityLink, a._links) {
for (const auto &activityLink : std::as_const(a._links)) {
customList << QVariant::fromValue(activityLink);
}
return customList;
Expand Down Expand Up @@ -610,7 +610,7 @@ void ActivityListModel::addIgnoredFileToList(const Activity &newActivity)
return;
}

foreach (Activity activity, _listOfIgnoredFiles) {
for (const auto &activity : _listOfIgnoredFiles) {
if (activity._file == newActivity._file) {
duplicate = true;
break;
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;

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

Expand Down
6 changes: 3 additions & 3 deletions src/gui/tray/usermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -589,7 +589,7 @@ void User::slotProgressInfo(const QString &folder, const ProgressInfo &progress)
return;
const auto &engine = f->syncEngine();
const auto style = engine.lastLocalDiscoveryStyle();
foreach (Activity activity, _activityModel->errorsList()) {
for (const auto &activity : _activityModel->errorsList()) {
if (activity._expireAtMsecs != -1) {
// we process expired activities in a different slot
continue;
Expand Down Expand Up @@ -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;
foreach (Activity activity, _activityModel->errorsList()) {
for (const auto &activity : _activityModel->errorsList()) {
if (activity._folder == folder
&& activity._syncFileItemStatus == SyncFileItem::Conflict) {
conflicts.append(activity._file);
Expand Down
Loading
Loading