FolderStatusModel now uses the LSCOL job result for encryption status

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
Kevin Ottens 2020-12-07 19:37:21 +01:00
Родитель 8e5a8d9fb9
Коммит 4fde05b8b6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 074BBBCB8DECC9E2
3 изменённых файлов: 19 добавлений и 7 удалений

Просмотреть файл

@ -375,8 +375,8 @@ void AccountSettings::slotSubfolderContextMenuRequested(const QModelIndex& index
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"));

Просмотреть файл

@ -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) {

Просмотреть файл

@ -107,6 +107,7 @@ public:
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; }