Implement FileTagModel QAbstractListModel methods
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 11 Apr 2023 15:26:33 +0000 (23:26 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 16 May 2023 10:23:33 +0000 (18:23 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/filetagmodel.cpp

index c94f1cfef8d6d4798bd06ef54b3111bb23358eb7..2000d239246c3a5e612e1749f6290cd5e64da928 100644 (file)
@@ -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()