File indexing completed on 2024-05-12 16:23:39
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Dimitris Kardarakos <dimkard@posteo.net> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QAbstractListModel> 0010 0011 /** 0012 * @brief Data structure to store a single feed group entry 0013 * 0014 */ 0015 struct FeedGroup { 0016 QString name; 0017 QString description; 0018 bool isDefault; 0019 }; 0020 0021 /** 0022 * @brief Model that provides the feed groups 0023 * 0024 */ 0025 class FeedGroupsModel : public QAbstractListModel 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 explicit FeedGroupsModel(QObject *parent = nullptr); 0031 0032 enum RoleNames { GroupName = Qt::UserRole + 1, GroupDescription, IsDefault }; 0033 0034 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0035 QHash<int, QByteArray> roleNames() const override; 0036 int rowCount(const QModelIndex &parent) const override; 0037 0038 private: 0039 void loadFromDatabase(); 0040 QVector<FeedGroup> m_feed_groups; 0041 };