21 #ifndef TULIPITEMEDITORCREATORS_H
22 #define TULIPITEMEDITORCREATORS_H
24 #include <tulip/tulipconf.h>
25 #include <tulip/PropertyTypes.h>
32 class QStyleOptionViewItem;
37 class PropertyInterface;
39 class TLP_QT_SCOPE TulipItemEditorCreator {
41 virtual ~TulipItemEditorCreator() {}
42 virtual QWidget* createWidget(QWidget*)
const=0;
43 virtual bool paint(QPainter*,
const QStyleOptionViewItem&,
const QVariant&)
const;
44 virtual QString displayText(
const QVariant &)
const {
48 virtual QSize sizeHint(
const QStyleOptionViewItem &,
const QModelIndex &)
const;
50 virtual void setEditorData(QWidget*,
const QVariant&,
bool isMandatory,
tlp::Graph* g=NULL)=0;
51 virtual QVariant editorData(QWidget*,
tlp::Graph* g=NULL)=0;
56 class TLP_QT_SCOPE StringDisplayEditorCreator:
public TulipItemEditorCreator {
58 inline QString displayText(
const QVariant& v)
const {
59 return QString::fromUtf8(T::toString(v.value<
typename T::RealType>()).c_str());
63 class TLP_QT_SCOPE ColorEditorCreator:
public tlp::TulipItemEditorCreator {
65 QWidget* createWidget(QWidget*)
const;
66 bool paint(QPainter*,
const QStyleOptionViewItem&,
const QVariant&)
const;
67 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
68 virtual QVariant editorData(QWidget*,
tlp::Graph*);
72 class LineEditEditorCreator:
public StringDisplayEditorCreator<T> {
74 QWidget* createWidget(QWidget*)
const;
75 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
76 virtual QVariant editorData(QWidget*,
tlp::Graph*);
80 class MultiLinesEditEditorCreator:
public StringDisplayEditorCreator<T> {
82 QWidget* createWidget(QWidget*)
const;
83 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
84 virtual QVariant editorData(QWidget*,
tlp::Graph*);
85 virtual QSize sizeHint(
const QStyleOptionViewItem &,
const QModelIndex &)
const;
86 bool paint(QPainter*,
const QStyleOptionViewItem&,
const QVariant&)
const;
89 class TLP_QT_SCOPE BooleanEditorCreator:
public TulipItemEditorCreator {
91 virtual 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;
97 class TLP_QT_SCOPE CoordEditorCreator:
public StringDisplayEditorCreator<tlp::PointType> {
100 CoordEditorCreator():editSize(false) {}
101 QWidget* createWidget(QWidget*)
const;
102 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
103 virtual QVariant editorData(QWidget*,
tlp::Graph*);
107 template<
typename PROP>
108 class PropertyEditorCreator:
public tlp::TulipItemEditorCreator {
110 QWidget* createWidget(QWidget*)
const;
111 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
112 virtual QVariant editorData(QWidget*,
tlp::Graph*);
113 virtual QString displayText(
const QVariant &)
const;
116 class TLP_QT_SCOPE PropertyInterfaceEditorCreator:
public tlp::TulipItemEditorCreator {
118 QWidget* createWidget(QWidget*)
const;
119 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
120 virtual QVariant editorData(QWidget*,
tlp::Graph*);
121 virtual QString displayText(
const QVariant &)
const;
124 class TLP_QT_SCOPE NumericPropertyEditorCreator:
public tlp::TulipItemEditorCreator {
126 QWidget* createWidget(QWidget*)
const;
127 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
128 virtual QVariant editorData(QWidget*,
tlp::Graph*);
129 virtual QString displayText(
const QVariant &)
const;
132 class TLP_QT_SCOPE ColorScaleEditorCreator:
public tlp::TulipItemEditorCreator {
134 QWidget* createWidget(QWidget*)
const;
135 bool paint(QPainter*,
const QStyleOptionViewItem&,
const QVariant&)
const;
136 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
137 virtual QVariant editorData(QWidget*,
tlp::Graph*);
140 class TLP_QT_SCOPE StringCollectionEditorCreator:
public tlp::TulipItemEditorCreator {
142 QWidget* createWidget(QWidget*)
const;
143 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
144 virtual QVariant editorData(QWidget*,
tlp::Graph*);
145 virtual QString displayText(
const QVariant &)
const;
148 class TLP_QT_SCOPE TulipFileDescriptorEditorCreator:
public tlp::TulipItemEditorCreator {
150 QWidget* createWidget(QWidget*)
const;
151 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
152 virtual QVariant editorData(QWidget*,
tlp::Graph*);
153 virtual bool paint(QPainter *,
const QStyleOptionViewItem &,
const QVariant &)
const;
154 QSize sizeHint(
const QStyleOptionViewItem &,
const QModelIndex &)
const;
157 class TLP_QT_SCOPE NodeShapeEditorCreator:
public tlp::TulipItemEditorCreator {
159 QWidget* createWidget(QWidget*)
const;
160 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
161 virtual QVariant editorData(QWidget*,
tlp::Graph*);
162 virtual QString displayText(
const QVariant &)
const;
163 virtual bool paint(QPainter*,
const QStyleOptionViewItem&,
const QVariant&)
const;
164 QSize sizeHint(
const QStyleOptionViewItem &,
const QModelIndex &)
const;
167 class TLP_QT_SCOPE EdgeExtremityShapeEditorCreator:
public tlp::TulipItemEditorCreator {
169 QWidget* createWidget(QWidget*)
const;
170 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
171 virtual QVariant editorData(QWidget*,
tlp::Graph*);
172 virtual QString displayText(
const QVariant &)
const;
173 virtual bool paint(QPainter*,
const QStyleOptionViewItem&,
const QVariant&)
const;
174 QSize sizeHint(
const QStyleOptionViewItem &,
const QModelIndex &)
const;
177 class TLP_QT_SCOPE EdgeShapeEditorCreator:
public tlp::TulipItemEditorCreator {
179 QWidget* createWidget(QWidget*)
const;
180 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
181 virtual QVariant editorData(QWidget*,
tlp::Graph*);
182 virtual QString displayText(
const QVariant &)
const;
185 template<
typename ElementType>
186 class VectorEditorCreator :
public tlp::TulipItemEditorCreator {
188 QWidget* createWidget(QWidget* parent)
const;
189 virtual void setEditorData(QWidget* editor,
const QVariant& data,
bool,
tlp::Graph*);
190 virtual QVariant editorData(QWidget* editor,
tlp::Graph*);
191 virtual QString displayText(
const QVariant &data)
const;
195 class TLP_QT_SCOPE TulipFontEditorCreator:
public tlp::TulipItemEditorCreator {
197 QWidget* createWidget(QWidget*)
const;
198 void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
200 QString displayText(
const QVariant &)
const;
203 class TLP_QT_SCOPE TulipLabelPositionEditorCreator:
public tlp::TulipItemEditorCreator {
204 static QVector<QString> POSITION_LABEL;
206 QWidget* createWidget(QWidget*)
const;
207 void setEditorData(QWidget*w,
const QVariant&var,
bool,
tlp::Graph*);
209 QString displayText(
const QVariant &)
const;
212 class TLP_QT_SCOPE GraphEditorCreator:
public tlp::TulipItemEditorCreator {
214 QWidget* createWidget(QWidget* parent)
const;
215 void setEditorData(QWidget*w,
const QVariant&var,
bool,
tlp::Graph*);
217 QString displayText(
const QVariant &)
const;
220 class TLP_QT_SCOPE QStringEditorCreator:
public tlp::TulipItemEditorCreator {
222 QWidget* createWidget(QWidget* parent)
const;
223 void setEditorData(QWidget*w,
const QVariant&var,
bool,
tlp::Graph*);
225 QString displayText(
const QVariant &)
const;
228 class TLP_QT_SCOPE QStringListEditorCreator:
public tlp::TulipItemEditorCreator {
230 QWidget* createWidget(QWidget* parent)
const;
231 void setEditorData(QWidget*w,
const QVariant& var,
bool,
tlp::Graph*);
233 QString displayText(
const QVariant &)
const;
239 #if defined(__clang__)
240 template class tlp::StringDisplayEditorCreator<tlp::PointType>;
241 template class tlp::StringDisplayEditorCreator<tlp::SizeType>;
245 #include "cxx/TulipItemEditorCreators.cxx"
247 #endif // TULIPITEMEDITORCREATORS_H