зеркало из https://github.com/nextcloud/desktop.git
FolderStatusModel now uses the LSCOL job result for encryption status
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
Родитель
8e5a8d9fb9
Коммит
4fde05b8b6
|
@ -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; }
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче