if (acc->capabilities().clientSideEncryptionAvailable()) {
// Verify if the folder is empty before attempting to encrypt.
- bool isEncrypted = acc->e2e()->isFolderEncrypted(info->_path);
- bool isParentEncrypted = acc->e2e()->isAnyParentFolderEncrypted(info->_path);
+ bool isEncrypted = info->_isEncrypted;
+ bool isParentEncrypted = _model->isAnyAncestorEncrypted(index);
if (!isEncrypted && !isParentEncrypted) {
ac = menu.addAction(tr("Encrypt"));
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);
}
}
+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) {
FetchLabel };
ItemType classify(const QModelIndex &index) const;
SubFolderInfo *infoForIndex(const QModelIndex &index) const;
+ bool isAnyAncestorEncrypted(const QModelIndex &index) const;
// If the selective sync check boxes were changed
bool isDirty() { return _dirty; }