File indexing completed on 2024-04-21 05:54:07
0001 /** 0002 * SPDX-FileCopyrightText: 2021 by Alexander Stippich <a.stippich@gmx.net> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #ifndef OPTIONS_MODEL_H 0008 #define OPTIONS_MODEL_H 0009 0010 #include <QObject> 0011 #include <QList> 0012 #include <QAbstractListModel> 0013 0014 #include <memory> 0015 0016 #include <KSaneCore/Option> 0017 0018 class OptionsModelPrivate; 0019 0020 class OptionsModel : public QAbstractListModel 0021 { 0022 Q_OBJECT 0023 0024 Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged) 0025 0026 public: 0027 enum OptionsModelRoles { 0028 NameRole = Qt::UserRole + 1, 0029 TitleRole, 0030 DescriptionRole, 0031 ValueRole, 0032 MaximumValueRole, 0033 MinimumValueRole, 0034 StepValueRole, 0035 ValueListRole, 0036 UnitRole, 0037 TypeRole, 0038 StateRole, 0039 QuickAccessRole 0040 }; 0041 0042 explicit OptionsModel(QObject *parent = nullptr); 0043 0044 ~OptionsModel(); 0045 0046 QHash<int, QByteArray> roleNames() const override; 0047 0048 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0049 0050 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0051 0052 bool setData(const QModelIndex &index, const QVariant &value, int role = ValueRole) override; 0053 0054 void setOptionsList(const QList<KSaneCore::Option *> &optionsList); 0055 0056 void clearOptions(); 0057 0058 Q_SIGNALS: 0059 0060 void rowCountChanged(); 0061 0062 private: 0063 0064 std::unique_ptr<OptionsModelPrivate> d; 0065 }; 0066 0067 #endif // OPTIONS_MODEL_H