1 /*************************************************************************** 2 ** ** 3 ** Polyphone, a soundfont editor ** 4 ** Copyright (C) 2013-2020 Davy Triponney ** 5 ** ** 6 ** This program is free software: you can redistribute it and/or modify ** 7 ** it under the terms of the GNU General Public License as published by ** 8 ** the Free Software Foundation, either version 3 of the License, or ** 9 ** (at your option) any later version. ** 10 ** ** 11 ** This program is distributed in the hope that it will be useful, ** 12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** 13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 14 ** GNU General Public License for more details. ** 15 ** ** 16 ** You should have received a copy of the GNU General Public License ** 17 ** along with this program. If not, see http://www.gnu.org/licenses/. ** 18 ** ** 19 **************************************************************************** 20 ** Author: Davy Triponney ** 21 ** Website/Contact: https://www.polyphone-soundfonts.com ** 22 ** Date: 01.01.2013 ** 23 ***************************************************************************/ 24 25 #ifndef TREEITEMDELEGATE_H 26 #define TREEITEMDELEGATE_H 27 28 #include <QStyledItemDelegate> 29 30 class TreeItemDelegate : public QStyledItemDelegate 31 { 32 Q_OBJECT 33 34 public: 35 TreeItemDelegate(QObject *parent); 36 37 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; 38 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; 39 40 public slots: 41 bool helpEvent(QHelpEvent* e, QAbstractItemView* view, const QStyleOptionViewItem& option, const QModelIndex& index); 42 43 private: 44 void drawRoot(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, bool expandable) const; 45 void drawElement(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, 46 const QPixmap &leftIcon, bool expandable, bool withIndent) const; 47 48 class Icons 49 { 50 public: 51 QPixmap getPixmap(QString name, int colorType, bool fixedColor); 52 53 private: 54 QMap<QString, QPixmap> _pixmaps; 55 }; 56 57 class Colors 58 { 59 public: 60 Colors(); 61 62 QColor _borderColor; 63 QColor _alternateColor; 64 QColor _textColor; 65 QColor _highlightColorBackground; 66 QColor _highlightColorText; 67 }; 68 69 static Icons * s_icons; 70 static Colors * s_colors; 71 static const int MARGIN; 72 }; 73 74 #endif // TREEITEMDELEGATE_H 75