1 /* This file is part of the KDE project 2 * Copyright (C) 2012 Dan Leinir Turthra Jensen <admin@leinir.dk> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef PALETTECOLORSMODEL_H 20 #define PALETTECOLORSMODEL_H 21 22 #include <QAbstractListModel> 23 #include <QColor> 24 25 class PaletteColorsModel : public QAbstractListModel 26 { 27 Q_OBJECT 28 Q_PROPERTY(QObject* colorSet READ colorSet WRITE setColorSet NOTIFY colorSetChanged) 29 Q_PROPERTY(QObject* view READ view WRITE setView NOTIFY viewChanged) 30 public: 31 enum PaletteColorsRoles { 32 ImageRole = Qt::UserRole + 1, 33 TextRole 34 }; 35 36 explicit PaletteColorsModel(QObject *parent = 0); 37 virtual ~PaletteColorsModel(); 38 QHash<int, QByteArray> roleNames() const; 39 virtual int rowCount(const QModelIndex &parent) const; 40 virtual QVariant data(const QModelIndex &index, int role) const; 41 virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; 42 43 QObject* view() const; 44 void setView(QObject* newView); 45 QObject* colorSet() const; 46 void setColorSet(QObject* newColorSet); 47 48 Q_SIGNALS: 49 void colorChanged(QColor newColor, bool backgroundChanged); 50 void colorSetChanged(); 51 void viewChanged(); 52 53 public Q_SLOTS: 54 void activateColor(int index, bool setBackgroundColor); 55 56 private: 57 class Private; 58 Private* d; 59 }; 60 61 #endif // PALETTECOLORSMODEL_H 62