1 /* 2 For general Scribus (>=1.3.2) copyright and licensing information please refer 3 to the COPYING file provided with the program. Following this notice may exist 4 a copyright and/or license notice that predates the release of Scribus 1.3.2 5 for which a new license (GPL+exception) is in place. 6 */ 7 /*************************************************************************** 8 sctreewidget.h - description 9 ------------------- 10 begin : Wed Jun 18 2008 11 copyright : (C) 2008 by Franz Schmid 12 email : Franz.Schmid@altmuehlnet.de 13 ***************************************************************************/ 14 15 /*************************************************************************** 16 * * 17 * This program is free software; you can redistribute it and/or modify * 18 * it under the terms of the GNU General Public License as published by * 19 * the Free Software Foundation; either version 2 of the License, or * 20 * (at your option) any later version. * 21 * * 22 ***************************************************************************/ 23 24 #ifndef SCTREEWIDGET_H 25 #define SCTREEWIDGET_H 26 27 #include <QItemDelegate> 28 #include <QTreeWidget> 29 #include <QString> 30 #include <QWidget> 31 #include <QHash> 32 #include <QEvent> 33 #include "scribusapi.h" 34 35 class SCRIBUS_API ScTreeWidgetDelegate : public QItemDelegate 36 { 37 Q_OBJECT 38 public: 39 ScTreeWidgetDelegate(QTreeWidget *view, QWidget *parent); 40 virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; 41 virtual QSize sizeHint(const QStyleOptionViewItem &opt, const QModelIndex &index) const; 42 43 private: 44 QTreeWidget *m_view; 45 }; 46 47 48 class SCRIBUS_API ScTreeWidget : public QTreeWidget 49 { 50 Q_OBJECT 51 public: 52 ScTreeWidget(QWidget* pa); ~ScTreeWidget()53 ~ScTreeWidget() {} 54 55 QTreeWidgetItem* addWidget(const QString& title, QWidget* widget); 56 void setToolBoxMode(bool enable); 57 int addItem(QWidget* widget, const QString& title); 58 QWidget* widget(int index); 59 void setItemEnabled(int index, bool enable); 60 bool isItemEnabled(int index); 61 void setCurrentIndex(int index); 62 int currentIndex(); 63 void setItemText(int index, const QString& text); 64 65 private slots: 66 void handleMousePress(QTreeWidgetItem *item); 67 68 signals: 69 void currentChanged2(int); 70 71 private: 72 bool m_toolboxMode { false }; 73 QHash<int, QTreeWidgetItem*> keySList; 74 75 protected: 76 bool event(QEvent *e); 77 }; 78 #endif 79