File indexing completed on 2024-05-19 04:29:05
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2010 Cyrille Berger <cberger@cberger.net> 0003 * SPDX-FileCopyrightText: 2011 Silvio Heinrich <plassyqweb.de> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef _KIS_PAINTOP_OPTION_LIST_MODEL_H_ 0009 #define _KIS_PAINTOP_OPTION_LIST_MODEL_H_ 0010 0011 #include <kis_categorized_list_model.h> 0012 #include <kis_paintop_option.h> 0013 #include <kritaui_export.h> 0014 0015 #include <QString> 0016 #include <QSignalMapper> 0017 0018 struct KRITAUI_EXPORT KisOptionInfo 0019 { 0020 KisOptionInfo() = default; 0021 0022 KisOptionInfo(KisPaintOpOption* o, int i, const QString &label) 0023 : label(label) 0024 , option(o) 0025 , index(i) 0026 {} 0027 0028 KisOptionInfo(const KisOptionInfo &) = default; 0029 0030 QString label; 0031 KisPaintOpOption *option {nullptr}; 0032 int index; 0033 }; 0034 0035 KRITAUI_EXPORT bool operator==(const KisOptionInfo& a, const KisOptionInfo& b); 0036 0037 struct KRITAUI_EXPORT OptionInfoToQStringConverter { 0038 QString operator() (const KisOptionInfo &info) { 0039 return info.label; 0040 } 0041 }; 0042 0043 typedef KisCategorizedListModel<KisOptionInfo, OptionInfoToQStringConverter> BaseOptionCategorizedListModel; 0044 0045 /** 0046 * This model can be use to show a list of visible composite op in a list view. 0047 */ 0048 class KRITAUI_EXPORT KisPaintOpOptionListModel : public BaseOptionCategorizedListModel 0049 { 0050 public: 0051 KisPaintOpOptionListModel(QObject *parent); 0052 void addPaintOpOption(KisPaintOpOption *option, int widgetIndex, const QString &label, const QString &category); 0053 QVariant data(const QModelIndex& idx, int role = Qt::DisplayRole) const override; 0054 bool setData(const QModelIndex& idx, const QVariant& value, int role=Qt::EditRole) override; 0055 void signalDataChanged(const QModelIndex& index); 0056 0057 static QString categoryName(KisPaintOpOption::PaintopCategory category); 0058 0059 private Q_SLOTS: 0060 void slotCheckedEnabledStateChanged(int row); 0061 0062 private: 0063 QSignalMapper m_stateSignalsMapper; 0064 }; 0065 0066 #endif // _KIS_PAINTOP_OPTION_LIST_MODEL_H_