From b79a038d9218a84f2a100552d05b33f09c872507 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 20 Apr 2023 21:17:24 +0800 Subject: [PATCH] Add support for system tags in filetagmodel Signed-off-by: Claudio Cambra --- src/gui/filetagmodel.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gui/filetagmodel.cpp b/src/gui/filetagmodel.cpp index 4f00e41f2..a9bd35bbd 100644 --- a/src/gui/filetagmodel.cpp +++ b/src/gui/filetagmodel.cpp @@ -65,7 +65,8 @@ void FileTagModel::fetchFileTags() qCDebug(lcFileTagModel) << "Starting fetch of filetags for file at:" << _serverRelativePath; const auto propfindJob = new PropfindJob(_account, _serverRelativePath, this); - propfindJob->setProperties({ QByteArrayLiteral("http://nextcloud.org/ns:tags") }); + propfindJob->setProperties({ QByteArrayLiteral("http://nextcloud.org/ns:tags"), + QByteArrayLiteral("http://nextcloud.org/ns:system-tags") }); connect(propfindJob, &PropfindJob::result, this, &FileTagModel::processFileTagRequestFinished); connect(propfindJob, &PropfindJob::finishedWithError, this, &FileTagModel::processFileTagRequestFinishedWithError); @@ -85,7 +86,20 @@ void FileTagModel::processFileTagRequestFinished(const QVariantMap &result) << _serverRelativePath; beginResetModel(); - _tags = result.value(QStringLiteral("tags")).toStringList(); + _tags.clear(); + + const auto normalTags = result.value(QStringLiteral("tags")).toStringList(); + const auto systemTags = result.value(QStringLiteral("system-tags")).toList(); + + auto systemTagStringList = QStringList(); + for (const auto &systemTagMapVariant : systemTags) { + const auto systemTagMap = systemTagMapVariant.toMap(); + const auto systemTag = systemTagMap.value(QStringLiteral("tag")).toString(); + systemTagStringList << systemTag; + } + + _tags << normalTags << systemTagStringList; + Q_EMIT totalTagsChanged(); endResetModel(); } -- 2.30.2