From f763bd00fb6168ad94f4ff538300ae347c962432 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 10 Apr 2023 19:27:31 +0800 Subject: [PATCH] Add a FileTagModel Signed-off-by: Claudio Cambra --- src/gui/CMakeLists.txt | 2 ++ src/gui/filetagmodel.cpp | 39 +++++++++++++++++++++++++++++++++++++++ src/gui/filetagmodel.h | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 src/gui/filetagmodel.cpp create mode 100644 src/gui/filetagmodel.h diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 1a0c9006a..8e6773829 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -88,6 +88,8 @@ set(client_SRCS editlocallyjob.cpp editlocallymanager.h editlocallymanager.cpp + filetagmodel.h + filetagmodel.cpp folder.h folder.cpp foldercreationdialog.h diff --git a/src/gui/filetagmodel.cpp b/src/gui/filetagmodel.cpp new file mode 100644 index 000000000..cfd17880d --- /dev/null +++ b/src/gui/filetagmodel.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 by Claudio Cambra + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "filetagmodel.h" + +FileTagModel::FileTagModel(QObject *parent) + : QAbstractListModel(parent) +{ +} + +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()) + return 0; + + // FIXME: Implement me! +} + +QVariant FileTagModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + // FIXME: Implement me! + return QVariant(); +} diff --git a/src/gui/filetagmodel.h b/src/gui/filetagmodel.h new file mode 100644 index 000000000..075b64e8a --- /dev/null +++ b/src/gui/filetagmodel.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 by Claudio Cambra + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#pragma once + +#include + +class FileTagModel : public QAbstractListModel +{ + Q_OBJECT + +public: + explicit FileTagModel(QObject *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; + +private: +};