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