File indexing completed on 2024-03-24 05:39:28
0001 /* 0002 SPDX-FileCopyrightText: 2013 Reza Fatahilah Shah <rshah0385@kireihana.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef THEMESMODEL_H 0008 #define THEMESMODEL_H 0009 0010 #include <QAbstractListModel> 0011 0012 class ThemeMetadata; 0013 0014 class ThemesModel : public QAbstractListModel 0015 { 0016 Q_OBJECT 0017 Q_PROPERTY(QString currentTheme READ currentTheme WRITE setCurrentTheme NOTIFY currentIndexChanged) 0018 Q_PROPERTY(int currentIndex READ currentIndex NOTIFY currentIndexChanged) 0019 public: 0020 enum Roles { 0021 IdRole = Qt::UserRole, 0022 PathRole, 0023 AuthorRole, 0024 DescriptionRole, 0025 VersionRole, 0026 PreviewRole, 0027 EmailRole, 0028 WebsiteRole, 0029 LicenseRole, 0030 CopyrightRole, 0031 ThemeApiRole, 0032 ConfigFileRole, 0033 CurrentBackgroundRole, 0034 DeletableRole, 0035 }; 0036 Q_ENUM(Roles) 0037 0038 explicit ThemesModel(QObject *parent = nullptr); 0039 ~ThemesModel() Q_DECL_OVERRIDE; 0040 0041 int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; 0042 QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; 0043 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; 0044 QHash<int, QByteArray> roleNames() const override; 0045 0046 QString currentTheme() const; 0047 void setCurrentTheme(const QString &theme); 0048 int currentIndex() const; 0049 0050 public Q_SLOTS: 0051 void populate(); 0052 Q_SIGNALS: 0053 void currentIndexChanged(); 0054 0055 private: 0056 void add(const QString &name, const QString &path); 0057 void dump(const QString &id, const QString &path); 0058 0059 int m_currentIndex; 0060 QList<ThemeMetadata> mThemeList; 0061 QHash<QString, QString> m_currentWallpapers; 0062 QList<QString> m_customInstalledThemes; 0063 }; 0064 0065 #endif // THEMESMODEL_H