Dooble
dooble_charts_property_editor.h
1 /*
2 ** Copyright (c) 2008 - present, Alexis Megas.
3 ** All rights reserved.
4 **
5 ** Redistribution and use in source and binary forms, with or without
6 ** modification, are permitted provided that the following conditions
7 ** are met:
8 ** 1. Redistributions of source code must retain the above copyright
9 ** notice, this list of conditions and the following disclaimer.
10 ** 2. Redistributions in binary form must reproduce the above copyright
11 ** notice, this list of conditions and the following disclaimer in the
12 ** documentation and/or other materials provided with the distribution.
13 ** 3. The name of the author may not be used to endorse or promote products
14 ** derived from Dooble without specific prior written permission.
15 **
16 ** DOOBLE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 ** DOOBLE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef dooble_charts_property_editor_h
29 #define dooble_charts_property_editor_h
30 
31 #include <QPointer>
32 #include <QStandardItemModel>
33 #include <QStyledItemDelegate>
34 
35 #include "dooble_charts.h"
36 
37 class dooble_charts_property_editor_model_delegate: public QStyledItemDelegate
38 {
39  Q_OBJECT
40 
41  public:
43  QStyledItemDelegate(parent)
44  {
45  }
46 
48  {
49  }
50 
51  QSize sizeHint(const QStyleOptionViewItem &option,
52  const QModelIndex &index) const;
53  QWidget *createEditor(QWidget *parent,
54  const QStyleOptionViewItem &option,
55  const QModelIndex &index) const;
56  void setEditorData(QWidget *editor, const QModelIndex &index) const;
57  void setModelData(QWidget *editor,
58  QAbstractItemModel *model,
59  const QModelIndex &index) const;
60  void updateEditorGeometry(QWidget *editor,
61  const QStyleOptionViewItem &option,
62  const QModelIndex &index) const;
63 
64  private slots:
65  void slot_show_color_dialog(void);
66  void slot_show_file_dialog(void);
67  void slot_show_font_dialog(void);
68  void slot_text_changed(void);
69 
70  signals:
71  void show_color_dialog(const dooble_charts::Properties property);
72  void show_file_dialog
73  (QPushButton *push_button, const dooble_charts::Properties property);
74  void show_font_dialog(const dooble_charts::Properties property);
75 };
76 
77 class dooble_charts_property_editor_model: public QStandardItemModel
78 {
79  Q_OBJECT
80 
81  public:
82  dooble_charts_property_editor_model(QObject *parent);
84  QStandardItem *item_from_property
85  (const dooble_charts::Properties property, const int column) const;
86 
87  protected:
88  QList<QStandardItem *> find_all_child_items(const QString &text) const;
89  QStandardItem *find_specific_item(const QString &text) const;
90 };
91 
92 class dooble_charts_property_editor: public QWidget
93 {
94  Q_OBJECT
95 
96  public:
97  dooble_charts_property_editor(QTreeView *tree);
99  QPointer<dooble_charts_property_editor_model> model(void) const;
100  QStandardItem *item_from_property
101  (const dooble_charts::Properties property, const int column) const;
102  QVariant property(const dooble_charts::Properties property);
103  void scroll_to_item(const dooble_charts::Properties property);
104  void set_property(const dooble_charts::Properties property,
105  const QVariant &value);
106 
107  private:
108  QToolButton *m_collapse;
109 
110  private slots:
111  void slot_collapse_all(void);
112  void slot_horizontal_scroll_bar_value_changed(int value);
113  void slot_show_color_dialog(const dooble_charts::Properties property);
114  void slot_show_file_dialog
115  (QPushButton *push_button, const dooble_charts::Properties property);
116  void slot_show_font_dialog(const dooble_charts::Properties property);
117 
118  protected:
119  QPointer<QTreeView> m_tree;
120  QPointer<dooble_charts_property_editor_model> m_model;
121  void prepare_generic(dooble_charts *chart);
122 };
123 
124 #endif
Definition: dooble_charts_property_editor.h:38
Definition: dooble_charts_property_editor.h:78
Definition: dooble_charts_property_editor.h:93
Definition: dooble_charts.h:49