Salome HOME
Merge branch 'master' of newgeom:newgeom
[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   void setFeaturesSelected(const QFeatureList& theFeatures);
70
71   //! Returns currently selected indexes
72   QModelIndexList selectedIndexes() const { return myTreeView->selectionModel()->selectedIndexes(); }
73
74   //! Returns TreeView widget
75   XGUI_DataTree* treeView() const { return myTreeView; }
76
77   //! Activates currently selected part. Signal activePartChanged will not be sent
78   void activatePart(const FeaturePtr& thePart);
79
80   void rebuildDataTree();
81
82 signals:
83   //! Emited when selection is changed
84   void selectionChanged();
85
86   //! Emited when current active document is changed
87   void activePartChanged(FeaturePtr thePart); 
88  
89   //! Emited on context menu request
90   void contextMenuRequested(QContextMenuEvent* theEvent);
91
92 protected:
93   virtual bool eventFilter(QObject* obj, QEvent* theEvent);
94
95 private slots:
96   void onActivePartChanged(FeaturePtr thePart);
97   void onContextMenuRequested(QContextMenuEvent* theEvent);
98   void onLabelContextMenuRequested(const QPoint& thePnt);
99
100   //! Called on Edit command request
101   void onEditItem();
102
103   void onSelectionChanged();
104
105 private:
106   void closeDocNameEditing(bool toSave);
107
108   //! Internal model
109   XGUI_DocumentDataModel* myDocModel;
110
111   QLineEdit* myActiveDocLbl;
112   XGUI_DataTree* myTreeView;
113
114   QFeatureList myFeaturesList;
115 };
116
117 #endif