File indexing completed on 2024-05-19 05:38:06

0001 /*
0002     SPDX-FileCopyrightText: 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
0003     SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
0004 
0005     KDE Frameworks 5 port:
0006     SPDX-FileCopyrightText: 2013 Jonathan Riddell <jr@jriddell.org>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #pragma once
0012 
0013 #include <QAbstractListModel>
0014 #include <QList>
0015 #include <QString>
0016 
0017 class IconsSettings;
0018 
0019 struct IconsModelData {
0020     QString display;
0021     QString themeName;
0022     QString description;
0023     bool removable;
0024     bool pendingDeletion;
0025 };
0026 Q_DECLARE_TYPEINFO(IconsModelData, Q_RELOCATABLE_TYPE);
0027 
0028 class IconsModel : public QAbstractListModel
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     IconsModel(IconsSettings *iconsSettings, QObject *parent = nullptr);
0034     ~IconsModel() override;
0035 
0036     enum Roles {
0037         ThemeNameRole = Qt::UserRole + 1,
0038         DescriptionRole,
0039         RemovableRole,
0040         PendingDeletionRole,
0041     };
0042 
0043     int rowCount(const QModelIndex &parent) const override;
0044     QVariant data(const QModelIndex &index, int role) const override;
0045     bool setData(const QModelIndex &index, const QVariant &value, int role) override;
0046     QHash<int, QByteArray> roleNames() const override;
0047 
0048     QStringList pendingDeletions() const;
0049     void removeItemsPendingDeletion();
0050 
0051     void load();
0052 
0053 Q_SIGNALS:
0054     void pendingDeletionsChanged();
0055 
0056 private:
0057     QList<IconsModelData> m_data;
0058     IconsSettings *m_settings;
0059 };