Scribus
Open source desktop publishing at your fingertips
proptree.h
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  proptree.h - description
9  -------------------
10  begin : Mon Feb 3 2014
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 PROPTREE_H
25 #define PROPTREE_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 #include "sccolor.h"
35 class PropTreeWidget;
36 
37 class SCRIBUS_API PropTreeItemDelegate : public QItemDelegate
38 {
39  Q_OBJECT
40 
41 public:
43  virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
44  virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
45  virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
46  virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
47  virtual void destroyEditor(QWidget * editor, const QModelIndex & index) const;
48  virtual void updateEditorGeometry(QWidget *editor,const QStyleOptionViewItem &option, const QModelIndex &index) const;
49  virtual QSize sizeHint(const QStyleOptionViewItem &opt, const QModelIndex &index) const;
50 private slots:
51  void valueHasChanged();
52 private:
53  PropTreeWidget *m_parent;
54  mutable QWidget *m_edit;
55 };
56 
57 class SCRIBUS_API PropTreeItem : public QObject, public QTreeWidgetItem
58 {
59  Q_OBJECT
60 
61 public:
62  PropTreeItem(QTreeWidget* parent, int typ, QString title);
63  PropTreeItem(PropTreeItem* parent, int typ, QString title);
64 // PropTreeItem(QTreeWidget *parent, QString title, int value, int min, int max, int unit);
65 // PropTreeItem(QTreeWidget* parent, QString title, double value, double min, double max, int decimals, int unit);
66 // PropTreeItem(QTreeWidget *parent, QString title, QString value, QStringList values);
67 // PropTreeItem(QTreeWidget* parent, QString title, bool value);
68 // PropTreeItem(QTreeWidget *parent, QString title, QString value);
69  ~PropTreeItem() {};
70 
71  enum PropItemType
72  {
73  Title = 0,
74  IntSpinBox = 1,
75  DoubleSpinBox = 2,
76  ComboBox = 3,
77  CheckBox = 4,
78  ColorComboBox = 5
79  };
80 
81  int valueAsInt();
82  double valueAsDouble();
83  bool valueAsBool();
84  QString valueAsString();
85  void setIntValue(int value);
86  void setDoubleValue(double value);
87  void setBoolValue(bool value);
88  void setStringValue(QString value);
89  void setUnitValue(int unit);
90  void setDecimalsValue(int unit);
91  void setComboStrings(QStringList value);
92  void setMinMaxValues(int min, int max);
93  void setMinMaxValues(double min, double max);
94  void setColorList(ColorList colors);
95  int m_type;
96  int m_unit;
97  int m_decimals;
98  double m_fmin;
99  double m_fmax;
100  int m_min;
101  int m_max;
102  int m_comboIndex;
103  ColorList m_colors;
104 
105 signals:
106  void valueChanged(int);
107  void valueChanged(double);
108  void valueChanged(bool);
109  void valueChanged(QString);
110  void editFinished();
111  void editStarted();
112 };
113 
114 class SCRIBUS_API PropTreeWidget : public QTreeWidget
115 {
116  Q_OBJECT
117 public:
118  PropTreeWidget(QWidget* pa);
119  PropTreeItem* indexToItem(const QModelIndex &index);
120  ~PropTreeWidget() {};
121 protected:
122  void mousePressEvent(QMouseEvent *event);
123  void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
124 private:
125  PropTreeItemDelegate *delegate;
126 private slots:
127  void handleMousePress(QTreeWidgetItem *item);
128 };
129 
130 #endif // PROPTREE_H
Definition: proptree.h:57
Definition: sccolor.h:155
Definition: proptree.h:114
Definition: proptree.h:37