diff --git a/src/gui/filedetails/filedetails.cpp b/src/gui/filedetails/filedetails.cpp index 2b76c70ad296e..9ebe8fac2bc1a 100644 --- a/src/gui/filedetails/filedetails.cpp +++ b/src/gui/filedetails/filedetails.cpp @@ -170,11 +170,7 @@ FileTagModel *FileDetails::fileTagModel() const void FileDetails::updateFileTagModel(const AccountPtr &account) { - Q_ASSERT(account); - - const auto serverRelPath = QString(folder->remotePathTrailingSlash() + name()); - - _fileTagModel = std::make_unique(serverRelPath, account); + _fileTagModel = std::make_unique(_fileRecord, _folder, account); Q_EMIT fileTagModelChanged(); } diff --git a/src/gui/filetagmodel.cpp b/src/gui/filetagmodel.cpp index 64cab4486a4f9..282ff84c18848 100644 --- a/src/gui/filetagmodel.cpp +++ b/src/gui/filetagmodel.cpp @@ -20,13 +20,21 @@ Q_LOGGING_CATEGORY(lcFileTagModel, "nextcloud.gui.filetagmodel", QtInfoMsg) namespace OCC { -FileTagModel::FileTagModel(const QString &serverRelativePath, +FileTagModel::FileTagModel(const SyncJournalFileRecord &fileRecord, + const Folder * const syncFolder, const AccountPtr &account, QObject * const parent) : QAbstractListModel(parent) - , _serverRelativePath(serverRelativePath) , _account(account) { + _serverRelativePath = syncFolder->remotePathTrailingSlash() + fileRecord.path(); + + if (const auto vfsMode = syncFolder->vfs().mode(); fileRecord.isVirtualFile() && vfsMode == Vfs::WithSuffix) { + if (const auto suffix = syncFolder->vfs().fileSuffix(); !suffix.isEmpty() && _serverRelativePath.endsWith(suffix)) { + _serverRelativePath.chop(suffix.length()); + } + } + fetchFileTags(); } diff --git a/src/gui/filetagmodel.h b/src/gui/filetagmodel.h index 618702e8b5b09..77933eccd9841 100644 --- a/src/gui/filetagmodel.h +++ b/src/gui/filetagmodel.h @@ -16,6 +16,8 @@ #include +#include "common/syncjournalfilerecord.h" +#include "gui/folder.h" #include "libsync/account.h" namespace OCC { @@ -31,7 +33,10 @@ class FileTagModel : public QAbstractListModel Q_PROPERTY(QString overflowTagsString READ overflowTagsString NOTIFY overflowTagsStringChanged) public: - explicit FileTagModel(const QString &serverRelativePath, const AccountPtr &account, QObject * const parent = nullptr); + explicit FileTagModel(const SyncJournalFileRecord &fileRecord, + const Folder *const syncFolder, + const AccountPtr &account, + QObject *const parent = nullptr); [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override; [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;