Back to index

salome-gui  6.5.0
TreeGuiManager.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 "TreeGuiManager.hxx"
00023 
00024 // SALOME includes
00025 #include <QStringList>
00026 
00027 // XCAD includes
00028 #include "TreeView.hxx"
00029 #include "QtHelper.hxx"
00030 
00031 // TODO:
00032 // IMP: The constructor should have a dockwidget as argument.
00033 // The creation of the void dockwidget (without the data tree
00034 // embedded) should be done previously by the StandardApp_Module.
00035 // The constructor would fill the dockwidget with a data tree view
00036 
00050 TreeGuiManager::TreeGuiManager(SalomeApp_Application * salomeApp, const char * title)
00051   : TreeObserver()
00052 {
00053   _salomeApp = salomeApp;
00054   
00055   bool tabify = false;
00056   _dockWidgets = new DockWidgets(_salomeApp, tabify, title);
00057 
00058   // Create a TreeView to be associated to a TreeModel dedicated to
00059   // the Xcad data:
00060   _dataTreeView = new TreeView();
00061   QStringList headers;
00062   headers << tr("Name") << tr("Value");
00063   _dataTreeModel = new TreeModel(headers);
00064   _dataTreeView->setModel(_dataTreeModel);
00065 
00066   // Then plug the TreeView in the dock widget:
00067   _dockWidgets->setDataView(_dataTreeView);
00068 
00069   // We specify here the dataview to be observed
00070   this->observe(_dataTreeView);
00071 }
00072 
00077 SalomeApp_Application * TreeGuiManager::getSalomeApplication() {
00078   return _salomeApp;
00079 }
00080 
00081 
00086 void TreeGuiManager::tabifyDockWidgets(bool tabify) {
00087   _dockWidgets->tabify(tabify);
00088 }
00089 
00094 void TreeGuiManager::showDockWidgets(bool isVisible) {
00095   _dockWidgets->show(isVisible);
00096 }
00097 
00103 TreeModel * TreeGuiManager::getDataTreeModel() {
00104   return _dataTreeModel;
00105 }
00106 
00112 TreeView * TreeGuiManager::getDataTreeView() {
00113   return _dataTreeView;
00114 }
00115 
00116 
00121 void TreeGuiManager::setDataModel(DataModel * dataModel) {
00122   _dataModel = dataModel;
00123 }
00124 
00125 DataModel * TreeGuiManager::getDataModel() {
00126   return _dataModel;
00127 }
00128 
00139 void TreeGuiManager::processItemList(QStringList itemNameIdList,
00140                                  int actionId)
00141 {
00142   // WARN: THIS IS A DEFAULT IMPLEMENTATION GIVEN FOR DEMONSTRATION
00143   // OF WHAT TO DO WITH THE PARAMETERS
00144 
00145   QString itemNameId = itemNameIdList[0];
00146   LOG("TreeGuiManager: signal received : process item "<<itemNameId);
00147   DataObject * dataObject = _dataModel->getDataObject(QS2S(itemNameId));
00148   if ( dataObject != NULL ) {
00149     LOG("TreeGuiManager: dataObject = "<<dataObject->toString().c_str());
00150   } else {
00151     LOG("TreeGuiManager: no data object associated to this item");
00152   }
00153 }