Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[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 QLineEdit;
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 slots:
36   virtual void commitData(QWidget* theEditor);
37
38 protected:
39   virtual void mouseDoubleClickEvent(QMouseEvent* theEvent);
40   virtual void contextMenuEvent(QContextMenuEvent* theEvent);
41
42 private slots:
43   //! Called when selection in Data Tree is changed
44   void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
45
46 private:
47   //! List of currently selected data
48   QFeatureList mySelectedData;
49 };
50
51
52 /**\class XGUI_ObjectsBrowser
53  * \ingroup GUI
54  * \brief Object browser window object. Represents data tree of current data structure
55  */
56  class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
57 {
58   Q_OBJECT
59 public:
60   XGUI_ObjectsBrowser(QWidget* theParent);
61   virtual ~XGUI_ObjectsBrowser();
62
63   //! Returns Model which provides access to data objects
64   XGUI_DocumentDataModel* dataModel() const { return myDocModel; }
65
66   //! Returns list of currently selected features
67   QFeatureList selectedFeatures() const { return myFeaturesList; }
68
69   //! Returns currently selected indexes
70   QModelIndexList selectedIndexes() const { return myTreeView->selectionModel()->selectedIndexes(); }
71
72   //! Returns TreeView widget
73   XGUI_DataTree* treeView() const { return myTreeView; }
74
75   //! Activates currently selected part. Signal activePartChanged will not be sent
76   void activatePart(const FeaturePtr& thePart);
77
78 signals:
79   //! Emited when selection is changed
80   void selectionChanged();
81
82   //! Emited when current active document is changed
83   void activePartChanged(FeaturePtr thePart); 
84  
85   //! Emited on context menu request
86   void contextMenuRequested(QContextMenuEvent* theEvent);
87
88 protected:
89   virtual bool eventFilter(QObject* obj, QEvent* theEvent);
90
91 private slots:
92   void onActivePartChanged(FeaturePtr thePart);
93   void onContextMenuRequested(QContextMenuEvent* theEvent);
94   void onLabelContextMenuRequested(const QPoint& thePnt);
95
96   //! Called on Edit command request
97   void onEditItem();
98
99 private:
100   void closeDocNameEditing(bool toSave);
101
102   //! Internal model
103   XGUI_DocumentDataModel* myDocModel;
104
105   QLineEdit* myActiveDocLbl;
106   XGUI_DataTree* myTreeView;
107
108   QFeatureList myFeaturesList;
109 };
110
111 #endif