qCWarning(lcFileTagModel) << "File tag fetch request job ended with error.";
}
+void FileTagModel::resetForNewFile()
+{
+ beginResetModel();
+ _tags.clear();
+ endResetModel();
+
+ fetchFileTags();
+}
+
+QString FileTagModel::serverRelativePath() const
+{
+ return _serverRelativePath;
+}
+
+void FileTagModel::setServerRelativePath(const QString &serverRelativePath)
+{
+ if (_serverRelativePath == serverRelativePath) {
+ return;
+ }
+
+ _serverRelativePath = serverRelativePath;
+ Q_EMIT serverRelativePathChanged();
+
+ resetForNewFile();
+}
+
+AccountPtr FileTagModel::account() const
+{
+ return _account;
+}
+
+void FileTagModel::setAccount(const AccountPtr &account)
+{
+ if (_account == account) {
+ return;
+ }
+
+ _account = account;
+ Q_EMIT accountChanged();
+
+ resetForNewFile();
+}
+
}
{
Q_OBJECT
+ Q_PROPERTY(QString serverRelativePath READ serverRelativePath WRITE setServerRelativePath NOTIFY serverRelativePathChanged)
+ Q_PROPERTY(AccountPtr account READ account WRITE setAccount NOTIFY accountChanged)
public:
explicit FileTagModel(const QString &serverRelativePath, const AccountPtr &account, QObject * const parent = nullptr);
- // Basic functionality:
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
-
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ [[nodiscard]] QString serverRelativePath() const;
+ [[nodiscard]] AccountPtr account() const;
+
+signals:
+ void serverRelativePathChanged();
+ void accountChanged();
+
+public slots:
+ void setServerRelativePath(const QString &serverRelativePath);
+ void setAccount(const OCC::AccountPtr &account);
+
+ void resetForNewFile();
+
private slots:
void fetchFileTags();
void processFileTagRequestFinished(const QVariantMap &result);