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 QSize sizeHint(
const QStyleOptionViewItem &,
const QModelIndex &)
const {
48 virtual void setEditorData(QWidget*,
const QVariant&,
bool isMandatory,
tlp::Graph* g=NULL)=0;
49 virtual QVariant editorData(QWidget*,
tlp::Graph* g=NULL)=0;
54 class TLP_QT_SCOPE StringDisplayEditorCreator:
public TulipItemEditorCreator {
56 inline QString displayText(
const QVariant& v)
const {
57 QString text = QString::fromUtf8(T::toString(v.value<
typename T::RealType>()).c_str());
62 class TLP_QT_SCOPE ColorEditorCreator:
public tlp::TulipItemEditorCreator {
64 QWidget* createWidget(QWidget*)
const;
65 bool paint(QPainter*,
const QStyleOptionViewItem&,
const QVariant&)
const;
66 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
67 virtual QVariant editorData(QWidget*,
tlp::Graph*);
71 class LineEditEditorCreator:
public StringDisplayEditorCreator<T> {
73 QWidget* createWidget(QWidget*)
const;
74 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
75 virtual QVariant editorData(QWidget*,
tlp::Graph*);
79 class MultiLinesEditEditorCreator:
public StringDisplayEditorCreator<T> {
81 QWidget* createWidget(QWidget*)
const;
82 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
83 virtual QVariant editorData(QWidget*,
tlp::Graph*);
84 virtual QSize sizeHint(
const QStyleOptionViewItem &,
const QModelIndex &)
const;
85 bool paint(QPainter*,
const QStyleOptionViewItem&,
const QVariant&)
const;
88 class TLP_QT_SCOPE BooleanEditorCreator:
public TulipItemEditorCreator {
90 virtual QWidget* createWidget(QWidget*)
const;
91 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
92 virtual QVariant editorData(QWidget*,
tlp::Graph*);
93 virtual QString displayText(
const QVariant &)
const;
96 class TLP_QT_SCOPE CoordEditorCreator:
public StringDisplayEditorCreator<tlp::PointType> {
98 QWidget* createWidget(QWidget*)
const;
99 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
100 virtual QVariant editorData(QWidget*,
tlp::Graph*);
103 template<
typename PROP>
104 class PropertyEditorCreator:
public tlp::TulipItemEditorCreator {
106 QWidget* createWidget(QWidget*)
const;
107 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
108 virtual QVariant editorData(QWidget*,
tlp::Graph*);
109 virtual QString displayText(
const QVariant &)
const;
112 class TLP_QT_SCOPE PropertyInterfaceEditorCreator:
public tlp::TulipItemEditorCreator {
114 QWidget* createWidget(QWidget*)
const;
115 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
116 virtual QVariant editorData(QWidget*,
tlp::Graph*);
117 virtual QString displayText(
const QVariant &)
const;
120 class TLP_QT_SCOPE ColorScaleEditorCreator:
public tlp::TulipItemEditorCreator {
122 QWidget* createWidget(QWidget*)
const;
123 bool paint(QPainter*,
const QStyleOptionViewItem&,
const QVariant&)
const;
124 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
125 virtual QVariant editorData(QWidget*,
tlp::Graph*);
128 class TLP_QT_SCOPE StringCollectionEditorCreator:
public tlp::TulipItemEditorCreator {
130 QWidget* createWidget(QWidget*)
const;
131 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
132 virtual QVariant editorData(QWidget*,
tlp::Graph*);
133 virtual QString displayText(
const QVariant &)
const;
136 class TLP_QT_SCOPE TulipFileDescriptorEditorCreator:
public tlp::TulipItemEditorCreator {
138 QWidget* createWidget(QWidget*)
const;
139 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
140 virtual QVariant editorData(QWidget*,
tlp::Graph*);
141 virtual bool paint(QPainter *,
const QStyleOptionViewItem &,
const QVariant &)
const;
142 QSize sizeHint(
const QStyleOptionViewItem &,
const QModelIndex &)
const;
145 class TLP_QT_SCOPE NodeShapeEditorCreator:
public tlp::TulipItemEditorCreator {
147 QWidget* createWidget(QWidget*)
const;
148 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
149 virtual QVariant editorData(QWidget*,
tlp::Graph*);
150 virtual QString displayText(
const QVariant &)
const;
151 virtual bool paint(QPainter*,
const QStyleOptionViewItem&,
const QVariant&)
const;
152 QSize sizeHint(
const QStyleOptionViewItem &,
const QModelIndex &)
const;
155 class TLP_QT_SCOPE EdgeExtremityShapeEditorCreator:
public tlp::TulipItemEditorCreator {
157 QWidget* createWidget(QWidget*)
const;
158 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
159 virtual QVariant editorData(QWidget*,
tlp::Graph*);
160 virtual QString displayText(
const QVariant &)
const;
161 virtual bool paint(QPainter*,
const QStyleOptionViewItem&,
const QVariant&)
const;
164 class TLP_QT_SCOPE EdgeShapeEditorCreator:
public tlp::TulipItemEditorCreator {
166 QWidget* createWidget(QWidget*)
const;
167 virtual void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
168 virtual QVariant editorData(QWidget*,
tlp::Graph*);
169 virtual QString displayText(
const QVariant &)
const;
172 template<
typename ElementType>
173 class VectorEditorCreator :
public tlp::TulipItemEditorCreator {
175 QWidget* createWidget(QWidget* parent)
const;
176 virtual void setEditorData(QWidget* editor,
const QVariant& data,
bool,
tlp::Graph*);
177 virtual QVariant editorData(QWidget* editor,
tlp::Graph*);
178 virtual QString displayText(
const QVariant &data)
const;
182 class TLP_QT_SCOPE TulipFontEditorCreator:
public tlp::TulipItemEditorCreator {
184 QWidget* createWidget(QWidget*)
const;
185 void setEditorData(QWidget*,
const QVariant&,
bool,
tlp::Graph*);
187 QString displayText(
const QVariant &)
const;
190 class TLP_QT_SCOPE TulipLabelPositionEditorCreator:
public tlp::TulipItemEditorCreator {
191 static QVector<QString> POSITION_LABEL;
193 QWidget* createWidget(QWidget*)
const;
194 void setEditorData(QWidget*w,
const QVariant&var,
bool,
tlp::Graph*);
196 QString displayText(
const QVariant &)
const;
199 class TLP_QT_SCOPE GraphEditorCreator:
public tlp::TulipItemEditorCreator {
201 QWidget* createWidget(QWidget* parent)
const;
202 void setEditorData(QWidget*w,
const QVariant&var,
bool,
tlp::Graph*);
204 QString displayText(
const QVariant &)
const;
207 class TLP_QT_SCOPE QStringEditorCreator:
public tlp::TulipItemEditorCreator {
209 QWidget* createWidget(QWidget* parent)
const;
210 void setEditorData(QWidget*w,
const QVariant&var,
bool,
tlp::Graph*);
212 QString displayText(
const QVariant &)
const;
215 class TLP_QT_SCOPE QStringListEditorCreator:
public tlp::TulipItemEditorCreator {
217 QWidget* createWidget(QWidget* parent)
const;
218 void setEditorData(QWidget*w,
const QVariant& var,
bool,
tlp::Graph*);
220 QString displayText(
const QVariant &)
const;
226 #if defined(__clang__)
227 template class tlp::StringDisplayEditorCreator<tlp::PointType>;
228 template class tlp::StringDisplayEditorCreator<tlp::SizeType>;
232 #include "cxx/TulipItemEditorCreators.cxx"
234 #endif // TULIPITEMEDITORCREATORS_H