1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 #ifndef XGUI_ObjectsBrowser_H
4 #define XGUI_ObjectsBrowser_H
7 #include <ModuleBase_Definitions.h>
8 #include <ModelAPI_Object.h>
9 #include <ModelAPI_ResultPart.h>
10 #include <ModelAPI_Events.h>
15 class XGUI_DocumentDataModel;
20 * Implementation of Data Tree object for Object Browser
22 class XGUI_DataTree : public QTreeView
27 /// \param theParent a parent widget
28 XGUI_DataTree(QWidget* theParent);
29 virtual ~XGUI_DataTree();
31 //! Returns list of currently selected objects
32 QObjectPtrList selectedObjects() const
34 return mySelectedData;
37 /// Returns current data model
38 XGUI_DocumentDataModel* dataModel() const;
41 //! Emited when selection is changed
42 void selectionChanged();
44 //! Emited when active part changed
45 void activePartChanged(ObjectPtr thePart);
47 //! Emited on context menu request
48 void contextMenuRequested(QContextMenuEvent* theEvent);
51 /// Clear content of data tree
55 /// Commit modified data (used for renaming of objects)
56 virtual void commitData(QWidget* theEditor);
59 /// Redefinition of virtual method
60 virtual void mouseDoubleClickEvent(QMouseEvent* theEvent);
62 /// Redefinition of virtual method
63 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
66 //! Called when selection in Data Tree is changed
67 void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
70 //! List of currently selected data
71 QObjectPtrList mySelectedData;
74 /**\class XGUI_ObjectsBrowser
76 * \brief Object browser window object. Represents data tree of current data structure
78 class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
83 /// \param theParent a parent widget
84 XGUI_ObjectsBrowser(QWidget* theParent);
85 virtual ~XGUI_ObjectsBrowser();
87 //! Returns Model which provides access to data objects
88 XGUI_DocumentDataModel* dataModel() const
93 //! Returns list of currently selected objects
94 QObjectPtrList selectedObjects() const
99 /// Set selected list of objects
100 /// \param theObjects list of objects to select
101 void setObjectsSelected(const QObjectPtrList& theObjects);
103 //! Returns currently selected indexes
104 QModelIndexList selectedIndexes() const
106 return myTreeView->selectionModel()->selectedIndexes();
109 //! Returns TreeView widget
110 XGUI_DataTree* treeView() const
115 //! Activates currently selected part. Signal activePartChanged will not be sent
116 void activatePart(const ResultPartPtr& thePart);
118 /// Rebuild data tree
119 void rebuildDataTree();
121 /// Process application event
122 /// \param theMessage an event message
123 void processEvent(const std::shared_ptr<Events_Message>& theMessage);
125 /// Resets the object browser into initial state
129 //! Emited when selection is changed
130 void selectionChanged();
132 //! Emited when current active document is changed
133 void activePartChanged(ObjectPtr thePart);
135 //! Emited on context menu request
136 void contextMenuRequested(QContextMenuEvent* theEvent);
139 /// Redefinition of virtual method
140 virtual bool eventFilter(QObject* obj, QEvent* theEvent);
144 /// \param thePart a part to activate
145 void onActivePartChanged(ObjectPtr thePart);
147 /// Show context menu
148 /// \param theEvent a context menu event
149 void onContextMenuRequested(QContextMenuEvent* theEvent);
151 /// Show context menu on upper label
152 /// \param thePnt a position of context menu
153 void onLabelContextMenuRequested(const QPoint& thePnt);
155 //! Called on Edit command request
158 /// Process selection changed event
159 void onSelectionChanged();
162 void closeDocNameEditing(bool toSave);
165 XGUI_DocumentDataModel* myDocModel;
167 QLineEdit* myActiveDocLbl;
168 XGUI_DataTree* myTreeView;
170 QObjectPtrList myObjectsList;