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 void onDoubleClick(const QModelIndex&);
53 /// Redefinition of virtual method
54 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
56 /// Redefinition of virtual method
57 virtual void resizeEvent(QResizeEvent* theEvent);
61 /**\class XGUI_ObjectsBrowser
63 * \brief Object browser window object. Represents data tree of current data structure
65 class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
70 /// \param theParent a parent widget
71 XGUI_ObjectsBrowser(QWidget* theParent);
72 virtual ~XGUI_ObjectsBrowser();
74 //! Returns Model which provides access to data objects
75 #ifdef ModuleDataModel
76 ModuleBase_IDocumentDataModel* dataModel() const
81 XGUI_DataModel* dataModel() const
87 //! Returns list of currently selected objects
88 //! \param theIndexes - output list of corresponded indexes (can be NULL)
89 QObjectPtrList selectedObjects(QModelIndexList* theIndexes = 0) const;
91 /// Set selected list of objects
92 /// \param theObjects list of objects to select
93 void setObjectsSelected(const QObjectPtrList& theObjects);
95 //! Returns currently selected indexes
96 QModelIndexList selectedIndexes() const
98 return myTreeView->selectionModel()->selectedIndexes();
101 //! Returns TreeView widget
102 XGUI_DataTree* treeView() const
107 /// Returns active doc label object
108 QLineEdit* activeDocLabel() const { return myActiveDocLbl; }
110 /// Rebuild data tree
111 void rebuildDataTree();
113 /// Resets the object browser into initial state
116 /// Set Data Model for the Object Browser
117 #ifdef ModuleDataModel
118 void setDataModel(ModuleBase_IDocumentDataModel* theModel);
122 //! Called on Edit command request
126 //! Emited when selection is changed
127 void selectionChanged();
129 //! Emited on context menu request
130 void contextMenuRequested(QContextMenuEvent* theEvent);
132 //! Segnal is emitted when user cliks by mouse in header label of object browser
133 void headerMouseDblClicked(const QModelIndex&);
136 /// Redefinition of virtual method
137 virtual bool eventFilter(QObject* obj, QEvent* theEvent);
140 /// Show context menu
141 /// \param theEvent a context menu event
142 void onContextMenuRequested(QContextMenuEvent* theEvent);
144 /// Show context menu on upper label
145 /// \param thePnt a position of context menu
146 void onLabelContextMenuRequested(const QPoint& thePnt);
148 //! Called when selection in Data Tree is changed
149 void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
152 void closeDocNameEditing(bool toSave);
155 #ifdef ModuleDataModel
156 ModuleBase_IDocumentDataModel* myDocModel;
158 XGUI_DataModel* myDocModel;
160 QLineEdit* myActiveDocLbl;
161 XGUI_DataTree* myTreeView;