From: Hannah von Reth Date: Wed, 22 Jul 2020 19:02:09 +0000 (+0200) Subject: Use const access where possible X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~74 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=93281c85602c28f5bc59ed46fd0e394fa5b7ec39;p=nextcloud-desktop.git Use const access where possible --- diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 8741a1f16..6c56ae39d 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -144,7 +144,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const return QVariant(); } case SubFolder: { - const auto &x = static_cast(index.internalPointer())->_subs[index.row()]; + const auto &x = static_cast(index.internalPointer())->_subs.at(index.row()); switch (role) { case Qt::DisplayRole: //: Example text: "File.txt (23KB)" @@ -315,7 +315,7 @@ bool FolderStatusModel::setData(const QModelIndex &index, const QVariant &value, } // also check all the children for (int i = 0; i < info->_subs.count(); ++i) { - if (info->_subs[i]._checked != Qt::Checked) { + if (info->_subs.at(i)._checked != Qt::Checked) { setData(this->index(i, 0, index), Qt::Checked, Qt::CheckStateRole); } } @@ -330,7 +330,7 @@ bool FolderStatusModel::setData(const QModelIndex &index, const QVariant &value, // Uncheck all the children for (int i = 0; i < info->_subs.count(); ++i) { - if (info->_subs[i]._checked != Qt::Unchecked) { + if (info->_subs.at(i)._checked != Qt::Unchecked) { setData(this->index(i, 0, index), Qt::Unchecked, Qt::CheckStateRole); } } @@ -512,7 +512,7 @@ QModelIndex FolderStatusModel::parent(const QModelIndex &child) const const SubFolderInfo *info = &_folders[pathIdx.at(0)]; while (i < pathIdx.count() - 1) { ASSERT(pathIdx.at(i) < info->_subs.count()); - info = &info->_subs[pathIdx.at(i)]; + info = &info->_subs.at(pathIdx.at(i)); ++i; } return createIndex(pathIdx.at(i), 0, const_cast(info)); @@ -789,15 +789,12 @@ void FolderStatusModel::slotLscolFinishedWithError(QNetworkReply *r) } } -QStringList FolderStatusModel::createBlackList(FolderStatusModel::SubFolderInfo *root, +QStringList FolderStatusModel::createBlackList(const FolderStatusModel::SubFolderInfo &root, const QStringList &oldBlackList) const { - if (!root) - return QStringList(); - - switch (root->_checked) { + switch (root._checked) { case Qt::Unchecked: - return QStringList(root->_path); + return QStringList(root._path); case Qt::Checked: return QStringList(); case Qt::PartiallyChecked: @@ -805,13 +802,13 @@ QStringList FolderStatusModel::createBlackList(FolderStatusModel::SubFolderInfo } QStringList result; - if (root->_fetched) { - for (int i = 0; i < root->_subs.count(); ++i) { - result += createBlackList(&root->_subs[i], oldBlackList); + if (root._fetched) { + for (int i = 0; i < root._subs.count(); ++i) { + result += createBlackList(root._subs.at(i), oldBlackList); } } else { // We did not load from the server so we re-use the one from the old black list - QString path = root->_path; + const QString path = root._path; foreach (const QString &it, oldBlackList) { if (it.startsWith(path)) result += it; @@ -846,7 +843,7 @@ void FolderStatusModel::slotApplySelectiveSync() qCWarning(lcFolderStatus) << "Could not read selective sync list from db."; continue; } - QStringList blackList = createBlackList(&_folders[i], oldBlackList); + QStringList blackList = createBlackList(_folders.at(i), oldBlackList); folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blackList); auto blackListSet = blackList.toSet(); diff --git a/src/gui/folderstatusmodel.h b/src/gui/folderstatusmodel.h index a4248a6f5..ecc13c209 100644 --- a/src/gui/folderstatusmodel.h +++ b/src/gui/folderstatusmodel.h @@ -138,7 +138,7 @@ private slots: void slotShowFetchProgress(); private: - QStringList createBlackList(OCC::FolderStatusModel::SubFolderInfo *root, + QStringList createBlackList(const OCC::FolderStatusModel::SubFolderInfo &root, const QStringList &oldBlackList) const; const AccountState *_accountState = nullptr; bool _dirty = false; // If the selective sync checkboxes were changed