File indexing completed on 2025-04-27 04:08:16
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2012 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef PALETTECOLORSMODEL_H 0008 #define PALETTECOLORSMODEL_H 0009 0010 #include <QAbstractListModel> 0011 #include <QColor> 0012 #include <KoColorSet.h> 0013 0014 class PaletteColorsModel : public QAbstractListModel 0015 { 0016 Q_OBJECT 0017 Q_PROPERTY(QObject* colorSet READ colorSet WRITE setColorSet NOTIFY colorSetChanged) 0018 Q_PROPERTY(QObject* view READ view WRITE setView NOTIFY viewChanged) 0019 public: 0020 enum PaletteColorsRoles { 0021 ImageRole = Qt::UserRole + 1, 0022 TextRole 0023 }; 0024 0025 explicit PaletteColorsModel(QObject *parent = nullptr); 0026 ~PaletteColorsModel() override; 0027 QHash<int, QByteArray> roleNames() const override; 0028 int rowCount(const QModelIndex &parent) const override; 0029 QVariant data(const QModelIndex &index, int role) const override; 0030 QVariant headerData(int section, 0031 Qt::Orientation orientation, 0032 int role) const override; 0033 0034 QObject* view() const; 0035 void setView(QObject* newView); 0036 QObject* colorSet() const; 0037 void setColorSet(QObject* newColorSet); 0038 0039 Q_SIGNALS: 0040 void colorChanged(QColor newColor, bool backgroundChanged); 0041 void colorSetChanged(); 0042 void viewChanged(); 0043 0044 public Q_SLOTS: 0045 void activateColor(int index, bool setBackgroundColor); 0046 0047 private: 0048 class Private; 0049 Private* d; 0050 }; 0051 0052 #endif // PALETTECOLORSMODEL_H