Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Verbruggen <erik@verbruggen.consulting>2021-10-14 14:22:13 +0300
committerHannah von Reth <vonreth@kde.org>2021-10-15 11:38:55 +0300
commite8dc85a34961a6c98293c499d946600f8aee4c10 (patch)
treed1ec5f6ef092cc41739e2d10eb1dfde30b879dfa
parent7f6a1c8a9bd042dbb8b44178bd7eead2214ebc1d (diff)
Fix remove sync root folder on disabled folder
Fixes: #9129
-rw-r--r--src/gui/accountsettings.cpp2
-rw-r--r--src/gui/folderstatusdelegate.h3
-rw-r--r--src/gui/folderstatusmodel.cpp11
3 files changed, 9 insertions, 7 deletions
diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index 016b786f0..2ac102159 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -247,7 +247,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
QModelIndex index = tv->indexAt(pos);
if (!index.isValid()) {
return;
- } else if (!(index.flags() & Qt::ItemIsEnabled)) {
+ } else if (!_model->data(index, FolderStatusDelegate::IsReady).toBool()) {
QMenu *menu = new QMenu(tv);
menu->setAttribute(Qt::WA_DeleteOnClose);
removeFolderAction(menu);
diff --git a/src/gui/folderstatusdelegate.h b/src/gui/folderstatusdelegate.h
index d919e646a..ab207300f 100644
--- a/src/gui/folderstatusdelegate.h
+++ b/src/gui/folderstatusdelegate.h
@@ -47,8 +47,9 @@ public:
AddButton, // 1 = enabled; 2 = disabled
FolderSyncText,
- DataRoleCount
+ DataRoleCount,
+ IsReady // boolean
};
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override;
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const override;
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp
index 8e3caece7..6f2f40fe5 100644
--- a/src/gui/folderstatusmodel.cpp
+++ b/src/gui/folderstatusmodel.cpp
@@ -107,11 +107,10 @@ Qt::ItemFlags FolderStatusModel::flags(const QModelIndex &index) const
return nullptr;
}
- auto flags = Qt::ItemIsEnabled;
- if (_folders.size() > index.row()) {
- const SubFolderInfo &folderInfo = _folders.at(index.row());
- flags = folderInfo._folder->isReady() ? Qt::ItemIsEnabled : Qt::NoItemFlags;
- }
+ // Always enable the item. If it isn't enabled, it cannot be in the selection model, so all
+ // actions from the context menu and the pop-up menu will have some other model index than the
+ // one under the mouse cursor!
+ const auto flags = Qt::ItemIsEnabled;
switch (classify(index)) {
case AddButton: {
@@ -271,6 +270,8 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
return progress._overallSyncString;
case FolderStatusDelegate::FolderSyncText:
return tr("Local folder: %1").arg(f->shortGuiLocalPath());
+ case FolderStatusDelegate::IsReady:
+ return f->isReady();
}
return QVariant();
}