Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
TulipItemDelegate.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
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 TULIPITEMDELEGATE_H
22#define TULIPITEMDELEGATE_H
23
24#include <QStyledItemDelegate>
25
26#include <tulip/TulipItemEditorCreators.h>
27#include <tulip/TulipMetaTypes.h>
28
29namespace tlp {
30
31class TLP_QT_SCOPE TulipItemDelegate : public QStyledItemDelegate {
32 Q_OBJECT
33
34 QMap<int, TulipItemEditorCreator *> _creators;
35
36 QObject *_currentMonitoredChild;
37 QComboBox *_currentMonitoredCombo;
38
39public:
40 static QVariant showEditorDialog(tlp::ElementType, tlp::PropertyInterface *, tlp::Graph *,
41 TulipItemDelegate *, QWidget *dialogParent = nullptr,
42 unsigned int id = UINT_MAX, QString title = "");
43
44 explicit TulipItemDelegate(QObject *parent = nullptr);
45 ~TulipItemDelegate() override;
46
47 template <typename T>
48 void registerCreator(tlp::TulipItemEditorCreator *);
49
50 void unregisterCreator(tlp::TulipItemEditorCreator *);
51
52 template <typename T>
53 void unregisterCreator();
54
55 template <typename T>
56 tlp::TulipItemEditorCreator *creator() const;
57
58 tlp::TulipItemEditorCreator *creator(int) const;
59
60 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
61 const QModelIndex &index) const override;
62 void paint(QPainter *painter, const QStyleOptionViewItem &option,
63 const QModelIndex &index) const override;
64 QString displayText(const QVariant &value, const QLocale &locale) const override;
65 void setEditorData(QWidget *editor, const QModelIndex &index) const override;
66 void setModelData(QWidget *editor, QAbstractItemModel *model,
67 const QModelIndex &index) const override;
68 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
69
70 bool eventFilter(QObject *object, QEvent *event) override;
71
72protected slots:
73 void comboDataChanged();
74};
75} // namespace tlp
76
77#include "cxx/TulipItemDelegate.cxx"
78
79#endif // TULIPITEMDELEGATE_H
80///@endcond
PropertyInterface describes the interface of a graph property.
ElementType
Definition: Graph.h:50