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 ModuleBase_IDocumentDataModel;
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);
30 virtual ~XGUI_DataTree();
32 /// Returns current data model
33 ModuleBase_IDocumentDataModel* dataModel() const;
36 //! Emited on context menu request
37 void contextMenuRequested(QContextMenuEvent* theEvent);
40 /// Clear content of data tree
44 /// Commit modified data (used for renaming of objects)
45 virtual void commitData(QWidget* theEditor);
48 /// Redefinition of virtual method
49 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
51 /// Redefinition of virtual method
52 virtual void resizeEvent(QResizeEvent* theEvent);
56 /**\class XGUI_ObjectsBrowser
58 * \brief Object browser window object. Represents data tree of current data structure
60 class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
65 /// \param theParent a parent widget
66 XGUI_ObjectsBrowser(QWidget* theParent);
67 virtual ~XGUI_ObjectsBrowser();
69 //! Returns Model which provides access to data objects
70 ModuleBase_IDocumentDataModel* dataModel() const
75 //! Returns list of currently selected objects
76 QObjectPtrList selectedObjects() const
78 return mySelectedData;
81 /// Set selected list of objects
82 /// \param theObjects list of objects to select
83 void setObjectsSelected(const QObjectPtrList& theObjects);
85 //! Returns currently selected indexes
86 QModelIndexList selectedIndexes() const
88 return myTreeView->selectionModel()->selectedIndexes();
91 //! Returns TreeView widget
92 XGUI_DataTree* treeView() const
97 /// Returns active doc label object
98 QLineEdit* activeDocLabel() const { return myActiveDocLbl; }
100 /// Rebuild data tree
101 void rebuildDataTree();
103 /// Resets the object browser into initial state
106 /// Set Data Model for the Object Browser
107 void setDataModel(ModuleBase_IDocumentDataModel* theModel);
110 //! Emited when selection is changed
111 void selectionChanged();
113 //! Emited on context menu request
114 void contextMenuRequested(QContextMenuEvent* theEvent);
117 /// Redefinition of virtual method
118 virtual bool eventFilter(QObject* obj, QEvent* theEvent);
121 /// Show context menu
122 /// \param theEvent a context menu event
123 void onContextMenuRequested(QContextMenuEvent* theEvent);
125 /// Show context menu on upper label
126 /// \param thePnt a position of context menu
127 void onLabelContextMenuRequested(const QPoint& thePnt);
129 //! Called on Edit command request
132 //! Called when selection in Data Tree is changed
133 void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
136 void closeDocNameEditing(bool toSave);
139 ModuleBase_IDocumentDataModel* myDocModel;
141 QLineEdit* myActiveDocLbl;
142 XGUI_DataTree* myTreeView;
144 QObjectPtrList mySelectedData;