Tulip  4.6.0
Better Visualization Through Research
library/tulip-gui/include/tulip/TreeViewComboBox.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 
00022 #ifndef TREEVIEWCOMBOBOX_H
00023 #define TREEVIEWCOMBOBOX_H
00024 
00025 #include <QComboBox>
00026 #include <QTreeView>
00027 #include <QMap>
00028 #include <QPair>
00029 
00030 #include <tulip/tulipconf.h>
00031 
00032 class QTimer;
00033 
00034 class TLP_QT_SCOPE DeferredUpdateTreeView : public QTreeView {
00035 
00036   Q_OBJECT
00037 
00038 public:
00039 
00040   DeferredUpdateTreeView(QWidget *parent = 0);
00041 
00042   ~DeferredUpdateTreeView();
00043 
00044 protected slots:
00045 
00046   void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
00047 
00048   void callDataChanged();
00049 
00050   void rowsAboutToBeRemoved(const QModelIndex & parent, int start, int end);
00051 
00052   void rowsInserted(const QModelIndex & parent, int start, int end);
00053 
00054 private:
00055 
00056   void cancelUpdates(const QModelIndex &parent);
00057 
00058   QMap<QPair<QModelIndex, QModelIndex>, QTimer *> _updateTimers;
00059 
00060 };
00061 
00062 class TLP_QT_SCOPE TreeViewComboBox : public QComboBox {
00063 
00064   Q_OBJECT
00065   QTreeView* _treeView;
00066   bool _skipNextHide;
00067   bool _popupVisible;
00068   QModelIndex _lastIndex;
00069 
00070 public:
00071   explicit TreeViewComboBox(QWidget *parent = NULL);
00072 
00073   void setModel(QAbstractItemModel * model);
00074 
00075   virtual void showPopup();
00076   virtual void hidePopup();
00077 
00078   QModelIndex selectedIndex() const;
00079 
00080   bool eventFilter(QObject*, QEvent*);
00081 
00082 public slots:
00083 
00084   void selectIndex(const QModelIndex&);
00085   void rowsRemoved(const QModelIndex&, int, int);
00086   void currentIndexChanged();
00087 
00088 signals:
00089 
00090   void currentItemChanged();
00091 
00092 };
00093 
00094 #endif // TREEVIEWCOMBOBOX_H
00095 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties