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);
50 /// Returns true if theObject can be renamed in theName
51 bool canRename(const ObjectPtr& theObject, const QString& theName);
54 /// Redefinition of virtual method
55 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
57 /// Redefinition of virtual method
58 virtual void resizeEvent(QResizeEvent* theEvent);
62 /**\class XGUI_ObjectsBrowser
64 * \brief Object browser window object. Represents data tree of current data structure
66 class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
71 /// \param theParent a parent widget
72 XGUI_ObjectsBrowser(QWidget* theParent);
73 virtual ~XGUI_ObjectsBrowser();
75 //! Returns Model which provides access to data objects
76 #ifdef ModuleDataModel
77 ModuleBase_IDocumentDataModel* dataModel() const
82 XGUI_DataModel* dataModel() const
88 //! Returns list of currently selected objects
89 //! \param theIndexes - output list of corresponded indexes (can be NULL)
90 QObjectPtrList selectedObjects(QModelIndexList* theIndexes = 0) const;
92 /// Set selected list of objects
93 /// \param theObjects list of objects to select
94 void setObjectsSelected(const QObjectPtrList& theObjects);
96 //! Returns currently selected indexes
97 QModelIndexList selectedIndexes() const
99 return myTreeView->selectionModel()->selectedIndexes();
102 //! Returns TreeView widget
103 XGUI_DataTree* treeView() const
108 /// Returns active doc label object
109 QLineEdit* activeDocLabel() const { return myActiveDocLbl; }
111 /// Rebuild data tree
112 void rebuildDataTree();
114 /// Resets the object browser into initial state
117 /// Set Data Model for the Object Browser
118 void setDataModel(ModuleBase_IDocumentDataModel* theModel);
121 //! Emited when selection is changed
122 void selectionChanged();
124 //! Emited on context menu request
125 void contextMenuRequested(QContextMenuEvent* theEvent);
127 //! Segnal is emitted when user cliks by mouse in header label of object browser
128 void headerMouseDblClicked(const QModelIndex&);
131 /// Redefinition of virtual method
132 virtual bool eventFilter(QObject* obj, QEvent* theEvent);
135 /// Show context menu
136 /// \param theEvent a context menu event
137 void onContextMenuRequested(QContextMenuEvent* theEvent);
139 /// Show context menu on upper label
140 /// \param thePnt a position of context menu
141 void onLabelContextMenuRequested(const QPoint& thePnt);
143 //! Called on Edit command request
146 //! Called when selection in Data Tree is changed
147 void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
150 void closeDocNameEditing(bool toSave);
153 #ifdef ModuleDataModel
154 ModuleBase_IDocumentDataModel* myDocModel;
156 XGUI_DataModel* myDocModel;
158 QLineEdit* myActiveDocLbl;
159 XGUI_DataTree* myTreeView;