Tulip 6.1.0
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>
25class QComboBox;
26
27#include <tulip/TulipMetaTypes.h>
28#include <tulip/TulipItemEditorCreators.h>
29
30namespace tlp {
31
32class TLP_QT_SCOPE TulipItemDelegate : public QStyledItemDelegate {
33 Q_OBJECT
34
35 QMap<int, TulipItemEditorCreator *> _creators;
36
37 QObject *_currentMonitoredChild;
38 QComboBox *_currentMonitoredCombo;
39
40public:
41 static QVariant showEditorDialog(tlp::ElementType, tlp::PropertyInterface *, tlp::Graph *,
42 TulipItemDelegate *, QWidget *dialogParent = nullptr,
43 unsigned int id = UINT_MAX, QString title = "");
44
45 explicit TulipItemDelegate(QObject *parent = nullptr);
46 ~TulipItemDelegate() override;
47
48 template <typename T>
49 void registerCreator(tlp::TulipItemEditorCreator *);
50
51 void unregisterCreator(tlp::TulipItemEditorCreator *);
52
53 template <typename T>
54 void unregisterCreator();
55
56 template <typename T>
57 tlp::TulipItemEditorCreator *creator() const;
58
59 tlp::TulipItemEditorCreator *creator(int) const;
60
61 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
62 const QModelIndex &index) const override;
63 void paint(QPainter *painter, const QStyleOptionViewItem &option,
64 const QModelIndex &index) const override;
65 QString displayText(const QVariant &value, const QLocale &locale) const override;
66 void setEditorData(QWidget *editor, const QModelIndex &index) const override;
67 void setModelData(QWidget *editor, QAbstractItemModel *model,
68 const QModelIndex &index) const override;
69 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
70
71 bool eventFilter(QObject *object, QEvent *event) override;
72
73protected slots:
74 void comboDataChanged();
75};
76} // namespace tlp
77
78#include "cxx/TulipItemDelegate.cxx"
79
80#endif // TULIPITEMDELEGATE_H
81///@endcond
ElementType
Definition Graph.h:50