1 #ifndef XGUI_ObjectsBrowser_H
2 #define XGUI_ObjectsBrowser_H
5 #include <ModuleBase_Definitions.h>
6 #include <ModelAPI_Object.h>
7 #include <ModelAPI_ResultPart.h>
8 #include <ModelAPI_Events.h>
13 class XGUI_DocumentDataModel;
16 class XGUI_DataTree : public QTreeView
20 XGUI_DataTree(QWidget* theParent);
21 virtual ~XGUI_DataTree();
23 //! Returns list of currently selected objects
24 QList<ObjectPtr> selectedObjects() const
26 return mySelectedData;
29 XGUI_DocumentDataModel* dataModel() const;
32 //! Emited when selection is changed
33 void selectionChanged();
34 void activePartChanged(ObjectPtr thePart);
36 //! Emited on context menu request
37 void contextMenuRequested(QContextMenuEvent* theEvent);
43 virtual void commitData(QWidget* theEditor);
46 virtual void mouseDoubleClickEvent(QMouseEvent* theEvent);
47 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
50 //! Called when selection in Data Tree is changed
51 void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
54 //! List of currently selected data
55 QList<ObjectPtr> mySelectedData;
58 /**\class XGUI_ObjectsBrowser
60 * \brief Object browser window object. Represents data tree of current data structure
62 class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
66 XGUI_ObjectsBrowser(QWidget* theParent);
67 virtual ~XGUI_ObjectsBrowser();
69 //! Returns Model which provides access to data objects
70 XGUI_DocumentDataModel* dataModel() const
75 //! Returns list of currently selected objects
76 QList<ObjectPtr> selectedObjects() const
81 void setObjectsSelected(const QList<ObjectPtr>& theObjects);
83 //! Returns currently selected indexes
84 QModelIndexList selectedIndexes() const
86 return myTreeView->selectionModel()->selectedIndexes();
89 //! Returns TreeView widget
90 XGUI_DataTree* treeView() const
95 //! Activates currently selected part. Signal activePartChanged will not be sent
96 void activatePart(const ResultPartPtr& thePart);
98 void rebuildDataTree();
100 void processEvent(const boost::shared_ptr<Events_Message>& theMessage);
102 // Resets the object browser into initial state
106 //! Emited when selection is changed
107 void selectionChanged();
109 //! Emited when current active document is changed
110 void activePartChanged(ObjectPtr thePart);
112 //! Emited on context menu request
113 void contextMenuRequested(QContextMenuEvent* theEvent);
116 virtual bool eventFilter(QObject* obj, QEvent* theEvent);
119 void onActivePartChanged(ObjectPtr thePart);
120 void onContextMenuRequested(QContextMenuEvent* theEvent);
121 void onLabelContextMenuRequested(const QPoint& thePnt);
123 //! Called on Edit command request
126 void onSelectionChanged();
129 void closeDocNameEditing(bool toSave);
132 XGUI_DocumentDataModel* myDocModel;
134 QLineEdit* myActiveDocLbl;
135 XGUI_DataTree* myTreeView;
137 QList<ObjectPtr> myObjectsList;