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 #if (!defined HAVE_SALOME) && (defined WIN32)
36 virtual bool event(QEvent* theEvent);
43 virtual void mouseReleaseEvent( QMouseEvent* e);
45 bool eventFilter(QObject* theObj, QEvent* theEvent);
48 QString myPreSelectionStyle;
49 QString myNeutralStyle;
50 QString mySelectionStyle;
52 QTreeView* myTreeView;
57 #if (!defined HAVE_SALOME) && (defined WIN32)
58 #include <QWindowsVistaStyle>
61 * Implementation of XGUI_DataTree custom style
63 class XGUI_TreeViewStyle : public QWindowsVistaStyle
67 XGUI_TreeViewStyle() : QWindowsVistaStyle() {}
69 void drawPrimitive(PrimitiveElement theElement, const QStyleOption* theOption,
70 QPainter* thePainter, const QWidget* theWidget = 0) const;
72 void setIndex(const QModelIndex& theIndex) { myIndex = theIndex; }
73 QModelIndex index() const { return myIndex; }
82 * Implementation of Data Tree object for Object Browser
84 class XGUI_DataTree : public QTreeView
89 /// \param theParent a parent widget
90 XGUI_DataTree(QWidget* theParent);
92 virtual ~XGUI_DataTree();
94 /// Returns current data model
95 XGUI_DataModel* dataModel() const;
98 //! Emited on context menu request
99 void contextMenuRequested(QContextMenuEvent* theEvent);
102 /// Clear content of data tree
103 virtual void clear();
106 /// Commit modified data (used for renaming of objects)
107 virtual void commitData(QWidget* theEditor);
109 /// A slot which is called on mouse double click
110 void onDoubleClick(const QModelIndex&);
113 /// Redefinition of virtual method
114 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
116 /// Redefinition of virtual method
117 virtual void resizeEvent(QResizeEvent* theEvent);
119 #if (!defined HAVE_SALOME) && (defined WIN32)
120 virtual void drawRow(QPainter* thePainter,
121 const QStyleOptionViewItem& theOptions,
122 const QModelIndex& theIndex) const;
124 XGUI_TreeViewStyle* myStyle;
128 /**\class XGUI_ObjectsBrowser
130 * \brief Object browser window object. Represents data tree of current data structure
132 class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
137 /// \param theParent a parent widget
138 XGUI_ObjectsBrowser(QWidget* theParent);
139 virtual ~XGUI_ObjectsBrowser();
141 //! Returns Model which provides access to data objects
142 XGUI_DataModel* dataModel() const
147 //! Returns list of currently selected objects
148 //! \param theIndexes - output list of corresponded indexes (can be NULL)
149 QObjectPtrList selectedObjects(QModelIndexList* theIndexes = 0) const;
151 /// Set selected list of objects
152 /// \param theObjects list of objects to select
153 void setObjectsSelected(const QObjectPtrList& theObjects);
155 //! Returns currently selected indexes
156 QModelIndexList selectedIndexes() const
158 return myTreeView->selectionModel()->selectedIndexes();
161 //! Returns TreeView widget
162 XGUI_DataTree* treeView() const
167 /// Returns active doc label object
168 QLineEdit* activeDocLabel() const { return myActiveDocLbl; }
170 /// Rebuild data tree
171 void rebuildDataTree();
173 /// Resets the object browser into initial state
177 //! Called on Edit command request
181 //! Emited when selection is changed
182 void selectionChanged();
184 //! Emited on context menu request
185 void contextMenuRequested(QContextMenuEvent* theEvent);
187 //! Segnal is emitted when user cliks by mouse in header label of object browser
188 void headerMouseDblClicked(const QModelIndex&);
191 /// Show context menu
192 /// \param theEvent a context menu event
193 void onContextMenuRequested(QContextMenuEvent* theEvent);
195 /// Show context menu on upper label
196 /// \param thePnt a position of context menu
197 void onLabelContextMenuRequested(const QPoint& thePnt);
199 //! Called when selection in Data Tree is changed
200 void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
205 XGUI_DataModel* myDocModel;
206 XGUI_ActiveDocLbl* myActiveDocLbl;
207 XGUI_DataTree* myTreeView;