File indexing completed on 2024-05-19 05:38:25
0001 /* 0002 SPDX-FileCopyrightText: 2019 Kai Uwe Broulik <kde@pbroulik.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QAbstractListModel> 0010 #include <QList> 0011 #include <QString> 0012 0013 struct StylesModelData { 0014 QString display; 0015 QString styleName; 0016 QString description; 0017 QString configPage; 0018 }; 0019 Q_DECLARE_TYPEINFO(StylesModelData, Q_RELOCATABLE_TYPE); 0020 0021 class StylesModel : public QAbstractListModel 0022 { 0023 Q_OBJECT 0024 0025 Q_PROPERTY(QString selectedStyle READ selectedStyle WRITE setSelectedStyle NOTIFY selectedStyleChanged) 0026 Q_PROPERTY(int selectedStyleIndex READ selectedStyleIndex NOTIFY selectedStyleIndexChanged) 0027 0028 public: 0029 StylesModel(QObject *parent); 0030 ~StylesModel() override; 0031 0032 enum Roles { 0033 StyleNameRole = Qt::UserRole + 1, 0034 DescriptionRole, 0035 ConfigurableRole, 0036 }; 0037 0038 int rowCount(const QModelIndex &parent) const override; 0039 QVariant data(const QModelIndex &index, int role) const override; 0040 QHash<int, QByteArray> roleNames() const override; 0041 0042 QString selectedStyle() const; 0043 void setSelectedStyle(const QString &style); 0044 0045 int indexOfStyle(const QString &style) const; 0046 int selectedStyleIndex() const; 0047 0048 QString styleConfigPage(const QString &style) const; 0049 0050 void load(); 0051 0052 Q_SIGNALS: 0053 void selectedStyleChanged(const QString &style); 0054 void selectedStyleIndexChanged(); 0055 0056 private: 0057 QString m_selectedStyle; 0058 0059 QList<StylesModelData> m_data; 0060 };