From 49b5fb32f968d4a5ba0804e6552c06c328d28f92 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 11 Apr 2023 23:26:33 +0800 Subject: [PATCH] Implement FileTagModel QAbstractListModel methods Signed-off-by: Claudio Cambra --- src/gui/filetagmodel.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/gui/filetagmodel.cpp b/src/gui/filetagmodel.cpp index c94f1cfef8..2000d23924 100644 --- a/src/gui/filetagmodel.cpp +++ b/src/gui/filetagmodel.cpp @@ -32,21 +32,25 @@ FileTagModel::FileTagModel(const QString &serverRelativePath, int FileTagModel::rowCount(const QModelIndex &parent) const { - // For list models only the root node (an invalid parent) should return the list's size. For all - // other (valid) parents, rowCount() should return 0 so that it does not become a tree model. - if (parent.isValid()) + if (parent.isValid()) { return 0; + } - // FIXME: Implement me! + return _tags.count(); } QVariant FileTagModel::data(const QModelIndex &index, int role) const { - if (!index.isValid()) + if (!index.isValid()) { return QVariant(); + } - // FIXME: Implement me! - return QVariant(); + switch (role) { + case Qt::DisplayRole: + return _tags.at(index.row()); + default: + return QVariant(); + } } void FileTagModel::fetchFileTags()