1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Author: Guillaume Boulant (EDF/R&D)
22 #include "DockWidgets.hxx"
25 #include <QMainWindow>
28 #include <SUIT_Desktop.h>
29 #include <SUIT_DataBrowser.h>
30 #include <QtxTreeView.h>
33 * This create a gui container to hold widgets dedicated to the XCAD
34 * data model. By default, the dock widgets are not visible. Use the
35 * show() method to control the visibility (usefull when activating
36 * and desactivating the module to show/hide the dock widgets).
38 * This class does not make any hypothesis on what will be embedded in
39 * the dock widgets (only that it is QTreeView). The QTreeView is
40 * defined elsewhere and is generaly rendering a tree model containing
43 DockWidgets::DockWidgets(SalomeApp_Application* salomeApp,
46 _salomeApp = salomeApp;
48 QMainWindow *parent = _salomeApp->desktop();
49 _dwDataPanel = new QDockWidget(parent);
50 _dwDataPanel->setVisible(false);
51 _dwDataPanel->setWindowTitle(title);
52 _dwDataPanel->setObjectName(title);
53 parent->addDockWidget(Qt::LeftDockWidgetArea, _dwDataPanel);
55 // At this step, the _dwDataPanel is located side by side with the object
56 // browser (or one over the other).
58 // It is possible to tabify the different dock widgets in one single
59 // tabbed widget. See the above example:
63 void DockWidgets::tabify(bool tabify) {
65 // We first get the object browser tree view, and then the
66 // associated DockWidget. Note that the tree view is a SALOME
67 // specific extention of the originate QTreeView and called
69 SUIT_DataBrowser* objectBrowser = _salomeApp->objectBrowser();
70 QtxTreeView* treeView = objectBrowser->treeView();
71 QWidget* pw = treeView->parentWidget();
72 QDockWidget* dwObjectBrowser = 0;
73 while ( pw && !dwObjectBrowser ) {
74 dwObjectBrowser = ::qobject_cast<QDockWidget*>( pw );
75 pw = pw->parentWidget();
77 QMainWindow *parent = _salomeApp->desktop();
78 parent->tabifyDockWidget(_dwDataPanel, dwObjectBrowser);
79 parent->setTabOrder(_dwDataPanel, dwObjectBrowser);
80 parent->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
88 * This function controls the visibility of the dock widgets.
90 void DockWidgets::show(bool isVisible) {
91 _dwDataPanel->setVisible(isVisible);
95 * This function initializes the central part of the dock widget with
96 * a tree view that can hold a hierarchical data model.
98 void DockWidgets::setDataView(QTreeView * dataView) {
99 _tvDataView = dataView;
100 _tvDataView->setParent(_dwDataPanel);
101 _tvDataView->setMinimumHeight(200);
102 _dwDataPanel->setWidget(_tvDataView);
105 void DockWidgets::setPropertiesView(QTreeView * propertiesView) {
106 // Not implemented yet