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