21 #ifndef TULIPITEMEDITORCREATORS_H
22 #define TULIPITEMEDITORCREATORS_H
24 #include <QtCore/QObject>
25 #include <QtGui/QItemEditorCreatorBase>
26 #include <QtGui/QStyleOptionViewItem>
27 #include <QtGui/QPainter>
29 #include <tulip/tulipconf.h>
30 #include <tulip/PropertyTypes.h>
31 #include <tulip/TulipMetaTypes.h>
35 class TLP_QT_SCOPE TulipItemEditorCreator {
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 {
44 virtual void setEditorData(QWidget*,
const QVariant&,
bool isMandatory,
tlp::Graph* g=NULL)=0;
45 virtual QVariant editorData(QWidget*,
tlp::Graph* g=NULL)=0;
50 class TLP_QT_SCOPE StringDisplayEditorCreator:
public TulipItemEditorCreator {
52 inline QString displayText(
const QVariant& v)
const {
53 return T::toString(v.value<
typename T::RealType>()).c_str();
57 class TLP_QT_SCOPE ColorEditorCreator:
public tlp::TulipItemEditorCreator {
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*);
66 class LineEditEditorCreator:
public StringDisplayEditorCreator<T> {
68 QWidget* createWidget(QWidget*)
const;
69 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
70 virtual QVariant editorData(QWidget*,
tlp::Graph*);
73 class TLP_QT_SCOPE BooleanEditorCreator:
public TulipItemEditorCreator {
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*);
81 class TLP_QT_SCOPE CoordEditorCreator:
public StringDisplayEditorCreator<tlp::PointType> {
83 QWidget* createWidget(QWidget*)
const;
84 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
85 virtual QVariant editorData(QWidget*,
tlp::Graph*);
88 template<
typename PROP>
89 class PropertyEditorCreator:
public tlp::TulipItemEditorCreator {
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;
97 class TLP_QT_SCOPE PropertyInterfaceEditorCreator:
public tlp::TulipItemEditorCreator {
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;
105 class TLP_QT_SCOPE ColorScaleEditorCreator:
public tlp::TulipItemEditorCreator {
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*);
113 class TLP_QT_SCOPE StringCollectionEditorCreator:
public tlp::TulipItemEditorCreator {
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;
121 class TLP_QT_SCOPE TulipFileDescriptorEditorCreator:
public tlp::TulipItemEditorCreator {
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;
129 class TLP_QT_SCOPE NodeShapeEditorCreator:
public tlp::TulipItemEditorCreator {
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;
138 class TLP_QT_SCOPE EdgeExtremityShapeEditorCreator:
public tlp::TulipItemEditorCreator {
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;
147 class TLP_QT_SCOPE EdgeShapeEditorCreator:
public tlp::TulipItemEditorCreator {
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;
155 template<
typename ElementType>
156 class VectorEditorCreator :
public tlp::TulipItemEditorCreator {
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;
165 class TLP_QT_SCOPE TulipFontEditorCreator:
public tlp::TulipItemEditorCreator {
167 QWidget* createWidget(QWidget*)
const;
168 void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
170 QString displayText(
const QVariant &)
const;
173 class TLP_QT_SCOPE TulipLabelPositionEditorCreator:
public tlp::TulipItemEditorCreator {
174 static QVector<QString> POSITION_LABEL;
176 QWidget* createWidget(QWidget*)
const;
177 void setEditorData(QWidget*w,
const QVariant&var,
bool,
tlp::Graph*);
179 QString displayText(
const QVariant &)
const;
182 class TLP_QT_SCOPE GraphEditorCreator:
public tlp::TulipItemEditorCreator {
184 QWidget* createWidget(QWidget* parent)
const;
185 void setEditorData(QWidget*w,
const QVariant&var,
bool,
tlp::Graph*);
187 QString displayText(
const QVariant &)
const;
190 class TLP_QT_SCOPE QStringEditorCreator:
public tlp::TulipItemEditorCreator {
192 QWidget* createWidget(QWidget* parent)
const;
193 void setEditorData(QWidget*w,
const QVariant&var,
bool,
tlp::Graph*);
195 QString displayText(
const QVariant &)
const;
201 #if defined(__clang__)
202 template class tlp::StringDisplayEditorCreator<tlp::PointType>;
203 template class tlp::StringDisplayEditorCreator<tlp::SizeType>;
207 #include "cxx/TulipItemEditorCreators.cxx"
209 #endif // TULIPITEMEDITORCREATORS_H