Warning, file /plasma/plasma-workspace/kcms/desktoptheme/themesmodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net> 0003 SPDX-FileCopyrightText: 2007 Jeremy Whiting <jpwhiting@kde.org> 0004 SPDX-FileCopyrightText: 2016 Olivier Churlaud <olivier@churlaud.com> 0005 SPDX-FileCopyrightText: 2019 Kai Uwe Broulik <kde@privat.broulik.de> 0006 SPDX-FileCopyrightText: 2019 David Redondo <kde@david-redondo.de> 0007 0008 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0009 */ 0010 0011 #pragma once 0012 0013 #include <QAbstractListModel> 0014 #include <QPalette> 0015 #include <QString> 0016 #include <QVector> 0017 0018 #include <memory> 0019 0020 struct ThemesModelData; 0021 0022 class ThemesModel : public QAbstractListModel 0023 { 0024 Q_OBJECT 0025 0026 Q_PROPERTY(QString selectedTheme READ selectedTheme WRITE setSelectedTheme NOTIFY selectedThemeChanged) 0027 Q_PROPERTY(int selectedThemeIndex READ selectedThemeIndex NOTIFY selectedThemeChanged) 0028 0029 public: 0030 ThemesModel(QObject *parent); 0031 ~ThemesModel() override; 0032 0033 enum Roles { 0034 PluginNameRole = Qt::UserRole + 1, 0035 ThemeNameRole, 0036 DescriptionRole, 0037 FollowsSystemColorsRole, 0038 ColorTypeRole, 0039 IsLocalRole, 0040 PendingDeletionRole, 0041 }; 0042 Q_ENUM(Roles) 0043 enum ColorType { 0044 LightTheme, 0045 DarkTheme, 0046 FollowsColorTheme, 0047 }; 0048 Q_ENUM(ColorType) 0049 0050 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0051 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0052 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; 0053 QHash<int, QByteArray> roleNames() const override; 0054 0055 QString selectedTheme() const; 0056 void setSelectedTheme(const QString &pluginName); 0057 0058 int pluginIndex(const QString &pluginName) const; 0059 int selectedThemeIndex() const; 0060 0061 QStringList pendingDeletions() const; 0062 void removeRow(int row); 0063 0064 void load(); 0065 0066 Q_SIGNALS: 0067 void selectedThemeChanged(const QString &pluginName); 0068 void selectedThemeIndexChanged(); 0069 0070 void pendingDeletionsChanged(); 0071 0072 private: 0073 QString m_selectedTheme; 0074 // Can't use QVector because unique_ptr causes deletion of copy-ctor 0075 QVector<ThemesModelData> m_data; 0076 }; 0077 0078 struct ThemesModelData { 0079 QString display; 0080 QString pluginName; 0081 QString description; 0082 ThemesModel::ColorType type; 0083 bool isLocal; 0084 bool pendingDeletion; 0085 };