Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
TulipItemEditorCreators.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef TULIPITEMEDITORCREATORS_H
22 #define TULIPITEMEDITORCREATORS_H
23 
24 #include <QtCore/QObject>
25 #include <QtGui/QItemEditorCreatorBase>
26 #include <QtGui/QStyleOptionViewItem>
27 #include <QtGui/QPainter>
28 
29 #include <tulip/tulipconf.h>
30 #include <tulip/PropertyTypes.h>
31 #include <tulip/TulipMetaTypes.h>
32 
33 namespace tlp {
34 
35 class TLP_QT_SCOPE TulipItemEditorCreator {
36 public:
37  virtual ~TulipItemEditorCreator() {}
38  virtual QWidget* createWidget(QWidget*) const=0;
39  virtual bool paint(QPainter*, const QStyleOptionViewItem&, const QVariant&) const;
40  virtual QString displayText(const QVariant &) const {
41  return "";
42  }
43 
44  virtual void setEditorData(QWidget*,const QVariant&,bool isMandatory,tlp::Graph* g=NULL)=0;
45  virtual QVariant editorData(QWidget*,tlp::Graph* g=NULL)=0;
46 
47 };
48 
49 template<typename T>
50 class TLP_QT_SCOPE StringDisplayEditorCreator: public TulipItemEditorCreator {
51 public:
52  inline QString displayText(const QVariant& v) const {
53  return T::toString(v.value<typename T::RealType>()).c_str();
54  }
55 };
56 
57 class TLP_QT_SCOPE ColorEditorCreator: public tlp::TulipItemEditorCreator {
58 public:
59  QWidget* createWidget(QWidget*) const;
60  bool paint(QPainter*, const QStyleOptionViewItem&, const QVariant&) const;
61  virtual void setEditorData(QWidget*, const QVariant&,bool,tlp::Graph*);
62  virtual QVariant editorData(QWidget*,tlp::Graph*);
63 };
64 
65 template<typename T>
66 class LineEditEditorCreator: public StringDisplayEditorCreator<T> {
67 public:
68  QWidget* createWidget(QWidget*) const;
69  virtual void setEditorData(QWidget*, const QVariant&,bool,tlp::Graph*);
70  virtual QVariant editorData(QWidget*,tlp::Graph*);
71 };
72 
73 class TLP_QT_SCOPE BooleanEditorCreator: public TulipItemEditorCreator {
74 public:
75  virtual QWidget* createWidget(QWidget*) const;
76  virtual bool paint(QPainter*, const QStyleOptionViewItem&, const QVariant &) const;
77  virtual void setEditorData(QWidget*,const QVariant&,bool,tlp::Graph*);
78  virtual QVariant editorData(QWidget*,tlp::Graph*);
79 };
80 
81 class TLP_QT_SCOPE CoordEditorCreator: public StringDisplayEditorCreator<tlp::PointType> {
82 public:
83  QWidget* createWidget(QWidget*) const;
84  virtual void setEditorData(QWidget*, const QVariant&,bool,tlp::Graph*);
85  virtual QVariant editorData(QWidget*,tlp::Graph*);
86 };
87 
88 template<typename PROP>
89 class PropertyEditorCreator: public tlp::TulipItemEditorCreator {
90 public:
91  QWidget* createWidget(QWidget*) const;
92  virtual void setEditorData(QWidget*, const QVariant&,bool,tlp::Graph*);
93  virtual QVariant editorData(QWidget*,tlp::Graph*);
94  virtual QString displayText(const QVariant &) const;
95 };
96 
97 class TLP_QT_SCOPE PropertyInterfaceEditorCreator: public tlp::TulipItemEditorCreator {
98 public:
99  QWidget* createWidget(QWidget*) const;
100  virtual void setEditorData(QWidget*, const QVariant&,bool,tlp::Graph*);
101  virtual QVariant editorData(QWidget*,tlp::Graph*);
102  virtual QString displayText(const QVariant &) const;
103 };
104 
105 class TLP_QT_SCOPE ColorScaleEditorCreator: public tlp::TulipItemEditorCreator {
106 public:
107  QWidget* createWidget(QWidget*) const;
108  bool paint(QPainter*, const QStyleOptionViewItem&, const QVariant&) const;
109  virtual void setEditorData(QWidget*, const QVariant&,bool,tlp::Graph*);
110  virtual QVariant editorData(QWidget*,tlp::Graph*);
111 };
112 
113 class TLP_QT_SCOPE StringCollectionEditorCreator: public tlp::TulipItemEditorCreator {
114 public:
115  QWidget* createWidget(QWidget*) const;
116  virtual void setEditorData(QWidget*, const QVariant&,bool,tlp::Graph*);
117  virtual QVariant editorData(QWidget*,tlp::Graph*);
118  virtual QString displayText(const QVariant &) const;
119 };
120 
121 class TLP_QT_SCOPE TulipFileDescriptorEditorCreator: public tlp::TulipItemEditorCreator {
122 public:
123  QWidget* createWidget(QWidget*) const;
124  virtual void setEditorData(QWidget*, const QVariant&,bool,tlp::Graph*);
125  virtual QVariant editorData(QWidget*,tlp::Graph*);
126  virtual bool paint(QPainter *, const QStyleOptionViewItem &, const QVariant &) const;
127 };
128 
129 class TLP_QT_SCOPE NodeShapeEditorCreator: public tlp::TulipItemEditorCreator {
130 public:
131  QWidget* createWidget(QWidget*) const;
132  virtual void setEditorData(QWidget*, const QVariant&,bool,tlp::Graph*);
133  virtual QVariant editorData(QWidget*,tlp::Graph*);
134  virtual QString displayText(const QVariant &) const;
135  virtual bool paint(QPainter*, const QStyleOptionViewItem&, const QVariant&) const;
136 };
137 
138 class TLP_QT_SCOPE EdgeExtremityShapeEditorCreator: public tlp::TulipItemEditorCreator {
139 public:
140  QWidget* createWidget(QWidget*) const;
141  virtual void setEditorData(QWidget*, const QVariant&,bool,tlp::Graph*);
142  virtual QVariant editorData(QWidget*,tlp::Graph*);
143  virtual QString displayText(const QVariant &) const;
144  virtual bool paint(QPainter*, const QStyleOptionViewItem&, const QVariant&) const;
145 };
146 
147 class TLP_QT_SCOPE EdgeShapeEditorCreator: public tlp::TulipItemEditorCreator {
148 public:
149  QWidget* createWidget(QWidget*) const;
150  virtual void setEditorData(QWidget*, const QVariant&,bool,tlp::Graph*);
151  virtual QVariant editorData(QWidget*,tlp::Graph*);
152  virtual QString displayText(const QVariant &) const;
153 };
154 
155 template<typename ElementType>
156 class VectorEditorCreator : public tlp::TulipItemEditorCreator {
157 public:
158  QWidget* createWidget(QWidget* parent) const;
159  virtual void setEditorData(QWidget* editor, const QVariant& data,bool,tlp::Graph*);
160  virtual QVariant editorData(QWidget* editor,tlp::Graph*);
161  virtual QString displayText(const QVariant &data) const;
162 };
163 
164 
165 class TLP_QT_SCOPE TulipFontEditorCreator: public tlp::TulipItemEditorCreator {
166 public:
167  QWidget* createWidget(QWidget*) const;
168  void setEditorData(QWidget*, const QVariant&,bool,tlp::Graph*);
169  QVariant editorData(QWidget*,tlp::Graph*);
170  QString displayText(const QVariant &) const;
171 };
172 
173 class TLP_QT_SCOPE TulipLabelPositionEditorCreator: public tlp::TulipItemEditorCreator {
174  static QVector<QString> POSITION_LABEL;
175 public:
176  QWidget* createWidget(QWidget*) const;
177  void setEditorData(QWidget*w, const QVariant&var, bool, tlp::Graph*);
178  QVariant editorData(QWidget*,tlp::Graph*);
179  QString displayText(const QVariant &) const;
180 };
181 
182 class TLP_QT_SCOPE GraphEditorCreator: public tlp::TulipItemEditorCreator {
183 public:
184  QWidget* createWidget(QWidget* parent) const;
185  void setEditorData(QWidget*w, const QVariant&var, bool, tlp::Graph*);
186  QVariant editorData(QWidget*,tlp::Graph*);
187  QString displayText(const QVariant &) const;
188 };
189 
190 class TLP_QT_SCOPE QStringEditorCreator: public tlp::TulipItemEditorCreator {
191 public:
192  QWidget* createWidget(QWidget* parent) const;
193  void setEditorData(QWidget*w, const QVariant&var, bool, tlp::Graph*);
194  QVariant editorData(QWidget*,tlp::Graph*);
195  QString displayText(const QVariant &) const;
196 };
197 
198 }
199 
200 
201 #if defined(__clang__)
202 template class tlp::StringDisplayEditorCreator<tlp::PointType>;
203 template class tlp::StringDisplayEditorCreator<tlp::SizeType>;
204 #endif
205 
206 
207 #include "cxx/TulipItemEditorCreators.cxx"
208 
209 #endif // TULIPITEMEDITORCREATORS_H
210 ///@endcond