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;
19 #define ModuleDataModel
23 * Implementation of Data Tree object for Object Browser
25 class XGUI_DataTree : public QTreeView
30 /// \param theParent a parent widget
31 XGUI_DataTree(QWidget* theParent);
33 virtual ~XGUI_DataTree();
35 /// Returns current data model
36 ModuleBase_IDocumentDataModel* dataModel() const;
39 //! Emited on context menu request
40 void contextMenuRequested(QContextMenuEvent* theEvent);
43 /// Clear content of data tree
47 /// Commit modified data (used for renaming of objects)
48 virtual void commitData(QWidget* theEditor);
51 /// Redefinition of virtual method
52 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
54 /// Redefinition of virtual method
55 virtual void resizeEvent(QResizeEvent* theEvent);
59 /**\class XGUI_ObjectsBrowser
61 * \brief Object browser window object. Represents data tree of current data structure
63 class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
68 /// \param theParent a parent widget
69 XGUI_ObjectsBrowser(QWidget* theParent);
70 virtual ~XGUI_ObjectsBrowser();
72 //! Returns Model which provides access to data objects
73 #ifdef ModuleDataModel
74 ModuleBase_IDocumentDataModel* dataModel() const
79 XGUI_DataModel* dataModel() const
85 //! Returns list of currently selected objects
86 //! \param theIndexes - output list of corresponded indexes (can be NULL)
87 QObjectPtrList selectedObjects(QModelIndexList* theIndexes = 0) const;
89 /// Set selected list of objects
90 /// \param theObjects list of objects to select
91 void setObjectsSelected(const QObjectPtrList& theObjects);
93 //! Returns currently selected indexes
94 QModelIndexList selectedIndexes() const
96 return myTreeView->selectionModel()->selectedIndexes();
99 //! Returns TreeView widget
100 XGUI_DataTree* treeView() const
105 /// Returns active doc label object
106 QLineEdit* activeDocLabel() const { return myActiveDocLbl; }
108 /// Rebuild data tree
109 void rebuildDataTree();
111 /// Resets the object browser into initial state
114 /// Set Data Model for the Object Browser
115 void setDataModel(ModuleBase_IDocumentDataModel* theModel);
118 //! Emited when selection is changed
119 void selectionChanged();
121 //! Emited on context menu request
122 void contextMenuRequested(QContextMenuEvent* theEvent);
124 //! Segnal is emitted when user cliks by mouse in header label of object browser
125 void headerMouseDblClicked(const QModelIndex&);
128 /// Redefinition of virtual method
129 virtual bool eventFilter(QObject* obj, QEvent* theEvent);
132 /// Show context menu
133 /// \param theEvent a context menu event
134 void onContextMenuRequested(QContextMenuEvent* theEvent);
136 /// Show context menu on upper label
137 /// \param thePnt a position of context menu
138 void onLabelContextMenuRequested(const QPoint& thePnt);
140 //! Called on Edit command request
143 //! Called when selection in Data Tree is changed
144 void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
147 void closeDocNameEditing(bool toSave);
150 #ifdef ModuleDataModel
151 ModuleBase_IDocumentDataModel* myDocModel;
153 XGUI_DataModel* myDocModel;
155 QLineEdit* myActiveDocLbl;
156 XGUI_DataTree* myTreeView;