Salome HOME
Create pop-up on ObjectBrowser root label (issue #23)
[modules/shaper.git] / src / XGUI / XGUI_ObjectsBrowser.h
1
2 #ifndef XGUI_ObjectsBrowser_H
3 #define XGUI_ObjectsBrowser_H
4
5 #include "XGUI.h"
6 #include "XGUI_Constants.h"
7
8 #include <QWidget>
9 #include <QTreeView>
10
11 class XGUI_DocumentDataModel;
12 class QLabel;
13
14
15 class XGUI_DataTree: public QTreeView
16 {
17   Q_OBJECT
18 public:
19   XGUI_DataTree(QWidget* theParent);
20   virtual ~XGUI_DataTree();
21
22   //! Returns list of currently selected features
23   QFeatureList selectedFeatures() const { return mySelectedData; }
24
25   XGUI_DocumentDataModel* dataModel() const;
26
27 signals:
28   //! Emited when selection is changed
29   void selectionChanged();
30   void activePartChanged(FeaturePtr thePart); 
31  
32   //! Emited on context menu request
33   void contextMenuRequested(QContextMenuEvent* theEvent);
34
35 protected:
36   virtual void mouseDoubleClickEvent(QMouseEvent* theEvent);
37   virtual void contextMenuEvent(QContextMenuEvent* theEvent);
38
39 private slots:
40   //! Called when selection in Data Tree is changed
41   void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
42
43 private:
44   //! List of currently selected data
45   QFeatureList mySelectedData;
46 };
47
48
49 /**\class XGUI_ObjectsBrowser
50  * \ingroup GUI
51  * \brief Object browser window object. Represents data tree of current data structure
52  */
53  class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
54 {
55   Q_OBJECT
56 public:
57   XGUI_ObjectsBrowser(QWidget* theParent);
58   virtual ~XGUI_ObjectsBrowser();
59
60   //! Returns Model which provides access to data objects
61   XGUI_DocumentDataModel* dataModel() const { return myDocModel; }
62
63   //! Returns list of currently selected features
64   QFeatureList selectedFeatures() const { return myFeaturesList; }
65
66   //! Returns currently selected indexes
67   QModelIndexList selectedIndexes() const { return myTreeView->selectionModel()->selectedIndexes(); }
68
69   //! Returns TreeView widget
70   XGUI_DataTree* treeView() const { return myTreeView; }
71
72   //! Activates currently selected part. Signal activePartChanged will not be sent
73   void activateCurrentPart(bool toActivate);
74
75 signals:
76   //! Emited when selection is changed
77   void selectionChanged();
78
79   //! Emited when current active document is changed
80   void activePartChanged(FeaturePtr thePart); 
81  
82   //! Emited on context menu request
83   void contextMenuRequested(QContextMenuEvent* theEvent);
84
85 protected:
86   virtual bool eventFilter(QObject* obj, QEvent* theEvent);
87
88 private slots:
89   void onActivePartChanged(FeaturePtr thePart);
90   void onContextMenuRequested(QContextMenuEvent* theEvent);
91   void onLabelContextMenuRequested(const QPoint& thePnt);
92
93 private:
94   //! Internal model
95   XGUI_DocumentDataModel* myDocModel;
96
97   QLabel* myActiveDocLbl;
98   XGUI_DataTree* myTreeView;
99
100   QFeatureList myFeaturesList;
101 };
102
103 #endif