mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 06:45:49 +03:00
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>
This commit is contained in:
parent
9f0e0b0f6a
commit
70c2dc70a1
1 changed files with 17 additions and 12 deletions
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in a new issue