diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2022-04-13 16:47:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-13 16:47:44 +0300 |
commit | 4033411ffadb7d9491fafe89a2dc72f47173897e (patch) | |
tree | 4583f645f7a13f45ace8af34f9543b545f427cbd /src/gui/folderstatusmodel.cpp | |
parent | 5205defcd23a65d4e7ed889e005d082745bf340b (diff) |
Use the folder object directly instead of looking it up by its name (#9583)
Diffstat (limited to 'src/gui/folderstatusmodel.cpp')
-rw-r--r-- | src/gui/folderstatusmodel.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 591ca9f1c..c7d12e807 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -74,14 +74,15 @@ void FolderStatusModel::setAccountState(AccountStatePtr accountState) connect(FolderMan::instance(), &FolderMan::scheduleQueueChanged, this, &FolderStatusModel::slotFolderScheduleQueueChanged, Qt::UniqueConnection); - for (const auto &f : FolderMan::instance()->map()) { + for (const auto &f : FolderMan::instance()->folders()) { if (!accountState) break; if (f->accountState() != accountState) continue; SubFolderInfo info; - info._name = f->alias(); - info._path = "/"; + // the name is not actually used with the root element + info._name = QLatin1Char('/'); + info._path = QLatin1Char('/'); info._folder = f; info._checked = Qt::PartiallyChecked; _folders << info; @@ -232,8 +233,6 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const return f->syncResult().status() == SyncResult::SyncRunning; case FolderStatusDelegate::HeaderRole: return f->shortGuiRemotePathOrAppName(); - case FolderStatusDelegate::FolderAliasRole: - return f->alias(); case FolderStatusDelegate::FolderSyncPaused: return f->syncPaused(); case FolderStatusDelegate::FolderAccountConnected: @@ -278,6 +277,12 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const return QVariant(); } +Folder *FolderStatusModel::folder(const QModelIndex &index) const +{ + Q_ASSERT(checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid)); + return _folders.at(index.row())._folder; +} + bool FolderStatusModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (role == Qt::CheckStateRole) { @@ -1065,7 +1070,7 @@ void FolderStatusModel::slotFolderSyncStateChange(Folder *f) } else if (state == SyncResult::NotYetStarted) { FolderMan *folderMan = FolderMan::instance(); int pos = folderMan->scheduleQueue().indexOf(f); - for (auto other : folderMan->map()) { + for (auto other : folderMan->folders()) { if (other != f && other->isSyncRunning()) pos += 1; } @@ -1096,7 +1101,7 @@ void FolderStatusModel::slotFolderSyncStateChange(Folder *f) void FolderStatusModel::slotFolderScheduleQueueChanged() { // Update messages on waiting folders. - for (auto *f : FolderMan::instance()->map()) { + for (auto *f : FolderMan::instance()->folders()) { slotFolderSyncStateChange(f); } } |