Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
TulipItemDelegate.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
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 
29 namespace tlp {
30 
31 class TLP_QT_SCOPE TulipItemDelegate : public QStyledItemDelegate {
32  Q_OBJECT
33 
34  QMap<int,TulipItemEditorCreator*> _creators;
35 
36  QObject* _currentMonitoredChild;
37  QComboBox* _currentMonitoredCombo;
38 
39 public:
40  static QVariant showEditorDialog(tlp::ElementType,tlp::PropertyInterface*,tlp::Graph*,TulipItemDelegate*, QWidget* dialogParent = NULL);
41 
42  explicit TulipItemDelegate(QObject* parent=NULL);
43  virtual ~TulipItemDelegate();
44 
45  template<typename T>
46  void registerCreator(tlp::TulipItemEditorCreator*);
47 
48  void unregisterCreator(tlp::TulipItemEditorCreator*);
49 
50  template<typename T>
51  void unregisterCreator();
52 
53  template<typename T>
54  tlp::TulipItemEditorCreator* creator() const;
55 
56  tlp::TulipItemEditorCreator* creator(int) const;
57 
58  QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
59  void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
60  QString displayText(const QVariant &value, const QLocale &locale) const;
61  void setEditorData(QWidget *editor, const QModelIndex &index) const;
62  void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
63  QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
64 
65  bool eventFilter(QObject *object, QEvent *event);
66 
67 protected slots:
68  void comboDataChanged();
69 };
70 
71 }
72 
73 #include "cxx/TulipItemDelegate.cxx"
74 
75 #endif // TULIPITEMDELEGATE_H
76 ///@endcond