Tulip  4.6.0
Better Visualization Through Research
library/tulip-gui/include/tulip/TulipItemDelegate.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 ///@cond DOXYGEN_HIDDEN
00020 
00021 #ifndef TULIPITEMDELEGATE_H
00022 #define TULIPITEMDELEGATE_H
00023 
00024 #include <climits>
00025 #include <QStyledItemDelegate>
00026 
00027 #include <tulip/TulipItemEditorCreators.h>
00028 #include <tulip/TulipMetaTypes.h>
00029 
00030 namespace tlp {
00031 
00032 class TLP_QT_SCOPE TulipItemDelegate : public QStyledItemDelegate {
00033   Q_OBJECT
00034 
00035   QMap<int,TulipItemEditorCreator*> _creators;
00036 
00037   QObject* _currentMonitoredChild;
00038   QComboBox* _currentMonitoredCombo;
00039 
00040 public:
00041   static QVariant showEditorDialog(tlp::ElementType,tlp::PropertyInterface*,tlp::Graph*,TulipItemDelegate*, QWidget* dialogParent = NULL, unsigned int id = UINT_MAX);
00042 
00043   explicit TulipItemDelegate(QObject* parent=NULL);
00044   virtual ~TulipItemDelegate();
00045 
00046   template<typename T>
00047   void registerCreator(tlp::TulipItemEditorCreator*);
00048 
00049   void unregisterCreator(tlp::TulipItemEditorCreator*);
00050 
00051   template<typename T>
00052   void unregisterCreator();
00053 
00054   template<typename T>
00055   tlp::TulipItemEditorCreator* creator() const;
00056 
00057   tlp::TulipItemEditorCreator* creator(int) const;
00058 
00059   QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
00060   void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00061   QString displayText(const QVariant &value, const QLocale &locale) const;
00062   void setEditorData(QWidget *editor, const QModelIndex &index) const;
00063   void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
00064   QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
00065 
00066   bool eventFilter(QObject *object, QEvent *event);
00067 
00068 protected slots:
00069   void comboDataChanged();
00070 };
00071 
00072 }
00073 
00074 #include "cxx/TulipItemDelegate.cxx"
00075 
00076 #endif // TULIPITEMDELEGATE_H
00077 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties