Tulip  4.6.1
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
TreeViewComboBox.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
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 
22 #ifndef TREEVIEWCOMBOBOX_H
23 #define TREEVIEWCOMBOBOX_H
24 
25 #include <QComboBox>
26 #include <QTreeView>
27 #include <QMap>
28 #include <QPair>
29 
30 #include <tulip/tulipconf.h>
31 
32 class QTimer;
33 
34 class TLP_QT_SCOPE DeferredUpdateTreeView : public QTreeView {
35 
36  Q_OBJECT
37 
38 public:
39 
40  DeferredUpdateTreeView(QWidget *parent = 0);
41 
42  ~DeferredUpdateTreeView();
43 
44 protected slots:
45 
46  void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
47 
48  void callDataChanged();
49 
50  void rowsAboutToBeRemoved(const QModelIndex & parent, int start, int end);
51 
52  void rowsInserted(const QModelIndex & parent, int start, int end);
53 
54 private:
55 
56  void cancelUpdates(const QModelIndex &parent);
57 
58  QMap<QPair<QModelIndex, QModelIndex>, QTimer *> _updateTimers;
59 
60 };
61 
62 class TLP_QT_SCOPE TreeViewComboBox : public QComboBox {
63 
64  Q_OBJECT
65  QTreeView* _treeView;
66  bool _skipNextHide;
67  bool _popupVisible;
68  QModelIndex _lastIndex;
69 
70 public:
71  explicit TreeViewComboBox(QWidget *parent = NULL);
72 
73  void setModel(QAbstractItemModel * model);
74 
75  virtual void showPopup();
76  virtual void hidePopup();
77 
78  QModelIndex selectedIndex() const;
79 
80  bool eventFilter(QObject*, QEvent*);
81 
82 public slots:
83 
84  void selectIndex(const QModelIndex&);
85  void rowsRemoved(const QModelIndex&, int, int);
86  void currentIndexChanged();
87 
88 signals:
89 
90  void currentItemChanged();
91 
92 };
93 
94 #endif // TREEVIEWCOMBOBOX_H
95 ///@endcond