diff options
author | Kevin Ottens <kevin.ottens@nextcloud.com> | 2020-12-07 21:37:21 +0300 |
---|---|---|
committer | Kevin Ottens <kevin.ottens@nextcloud.com> | 2020-12-15 12:59:22 +0300 |
commit | 4fde05b8b6b495949bdf0a47aef9d61cfd514e47 (patch) | |
tree | bd124a071d746500f52938f0483a50b4e5ca953d /src/gui/folderstatusmodel.cpp | |
parent | 8e5a8d9fb9fa5c882d8ab047e36f538736977617 (diff) |
FolderStatusModel now uses the LSCOL job result for encryption status
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
Diffstat (limited to 'src/gui/folderstatusmodel.cpp')
-rw-r--r-- | src/gui/folderstatusmodel.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 2543a48d7..e0dfd2321 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -155,12 +155,9 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const case Qt::CheckStateRole: return x._checked; case Qt::DecorationRole: { - Q_ASSERT(x._folder->remotePath().startsWith('/')); - const auto rootPath = x._folder->remotePath().mid(1); - const auto absoluteRemotePath = rootPath.isEmpty() ? x._path : rootPath + '/' + x._path; - if (_accountState->account()->e2e()->isFolderEncrypted(absoluteRemotePath)) { + if (x._isEncrypted) { return QIcon(QLatin1String(":/client/theme/lock-https.svg")); - } else if (x._size > 0 && _accountState->account()->e2e()->isAnyParentFolderEncrypted(absoluteRemotePath)) { + } else if (x._size > 0 && isAnyAncestorEncrypted(index)) { return QIcon(QLatin1String(":/client/theme/lock-broken.svg")); } return QFileIconProvider().icon(x._isExternal ? QFileIconProvider::Network : QFileIconProvider::Folder); @@ -418,6 +415,20 @@ FolderStatusModel::SubFolderInfo *FolderStatusModel::infoForIndex(const QModelIn } } +bool FolderStatusModel::isAnyAncestorEncrypted(const QModelIndex &index) const +{ + auto parentIndex = parent(index); + while (parentIndex.isValid()) { + const auto info = infoForIndex(parentIndex); + if (info->_isEncrypted) { + return true; + } + parentIndex = parent(parentIndex); + } + + return false; +} + QModelIndex FolderStatusModel::indexForPath(Folder *f, const QString &path) const { if (!f) { |