diff options
author | Kevin Ottens <kevin.ottens@nextcloud.com> | 2020-12-09 18:54:49 +0300 |
---|---|---|
committer | Kevin Ottens <kevin.ottens@nextcloud.com> | 2020-12-15 12:59:24 +0300 |
commit | 70c2dc70a1257c77dafb30dcd58366125a5405e9 (patch) | |
tree | d17f27bbbdaa75617a13245485bc3fe1dc6e20e8 /src/gui/folderstatusmodel.cpp | |
parent | 9f0e0b0f6abc3f4434d863413f0f27734ae84fdf (diff) |
Resurrect the display of subfolders for VFS sync folders
This got removed from the settings since in that case selective sync
isn't supported. Unfortunately that's also necessary to display them to
allow encrypting folders via the context menu.
So we display the subfolders again but in the case of VFS we disable the
ability to (un)check them. They just have an icon, a name and a context
menu.
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
Diffstat (limited to 'src/gui/folderstatusmodel.cpp')
-rw-r--r-- | src/gui/folderstatusmodel.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index e0dfd2321..d2e906c0e 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -105,6 +105,10 @@ Qt::ItemFlags FolderStatusModel::flags(const QModelIndex &index) const if (!_accountState) { return {}; } + + const auto info = infoForIndex(index); + const auto supportsSelectiveSync = info && info->_folder && info->_folder->supportsSelectiveSync(); + switch (classify(index)) { case AddButton: { Qt::ItemFlags ret; @@ -119,7 +123,11 @@ Qt::ItemFlags FolderStatusModel::flags(const QModelIndex &index) const case RootFolder: return Qt::ItemIsEnabled; case SubFolder: - return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable; + if (supportsSelectiveSync) { + return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable; + } else { + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } } return {}; } @@ -146,6 +154,8 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const } case SubFolder: { const auto &x = static_cast<SubFolderInfo *>(index.internalPointer())->_subs.at(index.row()); + const auto supportsSelectiveSync = x._folder && x._folder->supportsSelectiveSync(); + switch (role) { case Qt::DisplayRole: //: Example text: "File.txt (23KB)" @@ -153,7 +163,11 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const case Qt::ToolTipRole: return QString(QLatin1String("<qt>") + Utility::escape(x._size < 0 ? x._name : tr("%1 (%2)").arg(x._name, Utility::octetsToString(x._size))) + QLatin1String("</qt>")); case Qt::CheckStateRole: - return x._checked; + if (supportsSelectiveSync) { + return x._checked; + } else { + return QVariant(); + } case Qt::DecorationRole: { if (x._isEncrypted) { return QIcon(QLatin1String(":/client/theme/lock-https.svg")); @@ -294,6 +308,7 @@ bool FolderStatusModel::setData(const QModelIndex &index, const QVariant &value, { if (role == Qt::CheckStateRole) { auto info = infoForIndex(index); + Q_ASSERT(info->_folder && info->_folder->supportsSelectiveSync()); auto checked = static_cast<Qt::CheckState>(value.toInt()); if (info && info->_checked != checked) { @@ -543,9 +558,6 @@ bool FolderStatusModel::hasChildren(const QModelIndex &parent) const if (!info) return false; - if (info->_folder && !info->_folder->supportsSelectiveSync()) - return false; - if (!info->_fetched) return true; @@ -571,10 +583,6 @@ bool FolderStatusModel::canFetchMore(const QModelIndex &parent) const // Keep showing the error to the user, it will be hidden when the account reconnects return false; } - if (info->_folder && !info->_folder->supportsSelectiveSync()) { - // Selective sync is hidden in that case - return false; - } return true; } @@ -666,9 +674,6 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list) if (!parentInfo) { return; } - if (!parentInfo->_folder->supportsSelectiveSync()) { - return; - } ASSERT(parentInfo->_fetchingJob == job); ASSERT(parentInfo->_subs.isEmpty()); |