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;
21 * Implementation of Data Tree object for Object Browser
23 class XGUI_DataTree : public QTreeView
28 /// \param theParent a parent widget
29 XGUI_DataTree(QWidget* theParent);
31 virtual ~XGUI_DataTree();
33 /// Returns current data model
34 XGUI_DataModel* dataModel() const;
37 //! Emited on context menu request
38 void contextMenuRequested(QContextMenuEvent* theEvent);
41 /// Clear content of data tree
45 /// Commit modified data (used for renaming of objects)
46 virtual void commitData(QWidget* theEditor);
48 /// A slot which is called on mouse double click
49 void onDoubleClick(const QModelIndex&);
52 /// Redefinition of virtual method
53 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
55 /// Redefinition of virtual method
56 virtual void resizeEvent(QResizeEvent* theEvent);
60 /**\class XGUI_ObjectsBrowser
62 * \brief Object browser window object. Represents data tree of current data structure
64 class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
69 /// \param theParent a parent widget
70 XGUI_ObjectsBrowser(QWidget* theParent);
71 virtual ~XGUI_ObjectsBrowser();
73 //! Returns Model which provides access to data objects
74 XGUI_DataModel* dataModel() const
79 //! Returns list of currently selected objects
80 //! \param theIndexes - output list of corresponded indexes (can be NULL)
81 QObjectPtrList selectedObjects(QModelIndexList* theIndexes = 0) const;
83 /// Set selected list of objects
84 /// \param theObjects list of objects to select
85 void setObjectsSelected(const QObjectPtrList& theObjects);
87 //! Returns currently selected indexes
88 QModelIndexList selectedIndexes() const
90 return myTreeView->selectionModel()->selectedIndexes();
93 //! Returns TreeView widget
94 XGUI_DataTree* treeView() const
99 /// Returns active doc label object
100 QLineEdit* activeDocLabel() const { return myActiveDocLbl; }
102 /// Rebuild data tree
103 void rebuildDataTree();
105 /// Resets the object browser into initial state
109 //! Called on Edit command request
113 //! Emited when selection is changed
114 void selectionChanged();
116 //! Emited on context menu request
117 void contextMenuRequested(QContextMenuEvent* theEvent);
119 //! Segnal is emitted when user cliks by mouse in header label of object browser
120 void headerMouseDblClicked(const QModelIndex&);
123 /// Redefinition of virtual method
124 virtual bool eventFilter(QObject* obj, QEvent* theEvent);
127 /// Show context menu
128 /// \param theEvent a context menu event
129 void onContextMenuRequested(QContextMenuEvent* theEvent);
131 /// Show context menu on upper label
132 /// \param thePnt a position of context menu
133 void onLabelContextMenuRequested(const QPoint& thePnt);
135 //! Called when selection in Data Tree is changed
136 void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
139 void closeDocNameEditing(bool toSave);
142 XGUI_DataModel* myDocModel;
143 QLineEdit* myActiveDocLbl;
144 XGUI_DataTree* myTreeView;