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>
16 class ModuleBase_IDocumentDataModel;
21 * Implementation of root label in Object Browser
23 class XGUI_ActiveDocLbl: public QLineEdit
28 /// \param theParent a parent widget
29 XGUI_ActiveDocLbl(const QString& theText, QWidget* theParent );
31 void setTreeView(QTreeView* theView);
33 QTreeView* treePalette() const { return myTreeView;}
35 virtual bool event(QEvent* theEvent);
41 virtual void mouseReleaseEvent( QMouseEvent* e);
44 QString myPreSelectionStyle;
45 QString myNeutralStyle;
46 QString mySelectionStyle;
48 QTreeView* myTreeView;
54 * Implementation of Data Tree object for Object Browser
56 class XGUI_DataTree : public QTreeView
61 /// \param theParent a parent widget
62 XGUI_DataTree(QWidget* theParent);
64 virtual ~XGUI_DataTree();
66 /// Returns current data model
67 XGUI_DataModel* dataModel() const;
70 //! Emited on context menu request
71 void contextMenuRequested(QContextMenuEvent* theEvent);
74 /// Clear content of data tree
78 /// Commit modified data (used for renaming of objects)
79 virtual void commitData(QWidget* theEditor);
81 /// A slot which is called on mouse double click
82 void onDoubleClick(const QModelIndex&);
85 /// Redefinition of virtual method
86 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
88 /// Redefinition of virtual method
89 virtual void resizeEvent(QResizeEvent* theEvent);
93 /**\class XGUI_ObjectsBrowser
95 * \brief Object browser window object. Represents data tree of current data structure
97 class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
102 /// \param theParent a parent widget
103 XGUI_ObjectsBrowser(QWidget* theParent);
104 virtual ~XGUI_ObjectsBrowser();
106 //! Returns Model which provides access to data objects
107 XGUI_DataModel* dataModel() const
112 //! Returns list of currently selected objects
113 //! \param theIndexes - output list of corresponded indexes (can be NULL)
114 QObjectPtrList selectedObjects(QModelIndexList* theIndexes = 0) const;
116 /// Set selected list of objects
117 /// \param theObjects list of objects to select
118 void setObjectsSelected(const QObjectPtrList& theObjects);
120 //! Returns currently selected indexes
121 QModelIndexList selectedIndexes() const
123 return myTreeView->selectionModel()->selectedIndexes();
126 //! Returns TreeView widget
127 XGUI_DataTree* treeView() const
132 /// Returns active doc label object
133 QLineEdit* activeDocLabel() const { return myActiveDocLbl; }
135 /// Rebuild data tree
136 void rebuildDataTree();
138 /// Resets the object browser into initial state
142 //! Called on Edit command request
146 //! Emited when selection is changed
147 void selectionChanged();
149 //! Emited on context menu request
150 void contextMenuRequested(QContextMenuEvent* theEvent);
152 //! Segnal is emitted when user cliks by mouse in header label of object browser
153 void headerMouseDblClicked(const QModelIndex&);
156 /// Show context menu
157 /// \param theEvent a context menu event
158 void onContextMenuRequested(QContextMenuEvent* theEvent);
160 /// Show context menu on upper label
161 /// \param thePnt a position of context menu
162 void onLabelContextMenuRequested(const QPoint& thePnt);
164 //! Called when selection in Data Tree is changed
165 void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
170 XGUI_DataModel* myDocModel;
171 XGUI_ActiveDocLbl* myActiveDocLbl;
172 XGUI_DataTree* myTreeView;