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);
43 bool eventFilter(QObject* theObj, QEvent* theEvent);
46 QString myPreSelectionStyle;
47 QString myNeutralStyle;
48 QString mySelectionStyle;
50 QTreeView* myTreeView;
56 * Implementation of Data Tree object for Object Browser
58 class XGUI_DataTree : public QTreeView
63 /// \param theParent a parent widget
64 XGUI_DataTree(QWidget* theParent);
66 virtual ~XGUI_DataTree();
68 /// Returns current data model
69 XGUI_DataModel* dataModel() const;
72 //! Emited on context menu request
73 void contextMenuRequested(QContextMenuEvent* theEvent);
76 /// Clear content of data tree
80 /// Commit modified data (used for renaming of objects)
81 virtual void commitData(QWidget* theEditor);
83 /// A slot which is called on mouse double click
84 void onDoubleClick(const QModelIndex&);
87 /// Redefinition of virtual method
88 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
90 /// Redefinition of virtual method
91 virtual void resizeEvent(QResizeEvent* theEvent);
95 /**\class XGUI_ObjectsBrowser
97 * \brief Object browser window object. Represents data tree of current data structure
99 class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
104 /// \param theParent a parent widget
105 XGUI_ObjectsBrowser(QWidget* theParent);
106 virtual ~XGUI_ObjectsBrowser();
108 //! Returns Model which provides access to data objects
109 XGUI_DataModel* dataModel() const
114 //! Returns list of currently selected objects
115 //! \param theIndexes - output list of corresponded indexes (can be NULL)
116 QObjectPtrList selectedObjects(QModelIndexList* theIndexes = 0) const;
118 /// Set selected list of objects
119 /// \param theObjects list of objects to select
120 void setObjectsSelected(const QObjectPtrList& theObjects);
122 //! Returns currently selected indexes
123 QModelIndexList selectedIndexes() const
125 return myTreeView->selectionModel()->selectedIndexes();
128 //! Returns TreeView widget
129 XGUI_DataTree* treeView() const
134 /// Returns active doc label object
135 QLineEdit* activeDocLabel() const { return myActiveDocLbl; }
137 /// Rebuild data tree
138 void rebuildDataTree();
140 /// Resets the object browser into initial state
144 //! Called on Edit command request
148 //! Emited when selection is changed
149 void selectionChanged();
151 //! Emited on context menu request
152 void contextMenuRequested(QContextMenuEvent* theEvent);
154 //! Segnal is emitted when user cliks by mouse in header label of object browser
155 void headerMouseDblClicked(const QModelIndex&);
158 /// Show context menu
159 /// \param theEvent a context menu event
160 void onContextMenuRequested(QContextMenuEvent* theEvent);
162 /// Show context menu on upper label
163 /// \param thePnt a position of context menu
164 void onLabelContextMenuRequested(const QPoint& thePnt);
166 //! Called when selection in Data Tree is changed
167 void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
172 XGUI_DataModel* myDocModel;
173 XGUI_ActiveDocLbl* myActiveDocLbl;
174 XGUI_DataTree* myTreeView;