Back to index

salome-gui  6.5.0
DockWidgets.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // Author: Guillaume Boulant (EDF/R&D)
00021 
00022 #include "DockWidgets.hxx"
00023 
00024 // Qt includes
00025 #include <QMainWindow>
00026 
00027 // SALOME includes
00028 #include <SUIT_Desktop.h>
00029 #include <SUIT_DataBrowser.h>
00030 #include <QtxTreeView.h>
00031 
00043 DockWidgets::DockWidgets(SalomeApp_Application* salomeApp,
00044                       bool tabify,
00045                       const char * title) {
00046   _salomeApp = salomeApp;
00047 
00048   QMainWindow *parent = _salomeApp->desktop();
00049   _dwDataPanel = new QDockWidget(parent);
00050   _dwDataPanel->setVisible(false);
00051   _dwDataPanel->setWindowTitle(title);
00052   parent->addDockWidget(Qt::LeftDockWidgetArea, _dwDataPanel);
00053   //
00054   // At this step, the _dwDataPanel is located side by side with the object
00055   // browser (or one over the other).
00056   //
00057   // It is possible to tabify the different dock widgets in one single
00058   // tabbed widget. See the above example:
00059   this->tabify(tabify);
00060 }
00061 
00062 void DockWidgets::tabify(bool tabify) {
00063   if ( tabify ) {    
00064     // We first get the object browser tree view, and then the
00065     // associated DockWidget. Note that the tree view is a SALOME
00066     // specific extention of the originate QTreeView and called
00067     // QtxTreeView.
00068     SUIT_DataBrowser* objectBrowser = _salomeApp->objectBrowser();
00069     QtxTreeView* treeView = objectBrowser->treeView();
00070     QWidget* pw = treeView->parentWidget();
00071     QDockWidget* dwObjectBrowser = 0;
00072     while ( pw && !dwObjectBrowser ) {
00073       dwObjectBrowser = ::qobject_cast<QDockWidget*>( pw );
00074       pw = pw->parentWidget();
00075     };
00076     QMainWindow *parent = _salomeApp->desktop();
00077     parent->tabifyDockWidget(_dwDataPanel, dwObjectBrowser);
00078     parent->setTabOrder(_dwDataPanel, dwObjectBrowser);
00079     parent->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
00080   }
00081   else {
00082     // TO BE IMPLEMENTED
00083   }
00084 }
00085 
00089 void DockWidgets::show(bool isVisible) {
00090   _dwDataPanel->setVisible(isVisible);
00091 }
00092 
00097 void DockWidgets::setDataView(QTreeView * dataView) {
00098   _tvDataView = dataView;
00099   _tvDataView->setParent(_dwDataPanel);
00100   _tvDataView->setMinimumHeight(200);
00101   _dwDataPanel->setWidget(_tvDataView);
00102 }
00103 
00104 void DockWidgets::setPropertiesView(QTreeView * propertiesView) {
00105   // Not implemented yet
00106 }