Back to index

salome-gui  6.5.0
CAM_DataObject.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "CAM_DataObject.h"
00024 
00025 #include "CAM_Module.h"
00026 #include "CAM_DataModel.h"
00027 
00028 #include <Qtx.h>
00029 
00042 CAM_DataObject::CAM_DataObject( SUIT_DataObject* parent )
00043 : SUIT_DataObject( parent )
00044 {
00045 }
00046 
00052 CAM_DataObject::~CAM_DataObject()
00053 {
00054 }
00055 
00060 CAM_Module* CAM_DataObject::module() const
00061 { 
00062   CAM_DataModel* dm = dataModel();
00063   return dm ? dm->module() : 0;
00064 }
00065 
00071 CAM_DataModel* CAM_DataObject::dataModel() const
00072 {
00073   CAM_DataObject* parentObj = dynamic_cast<CAM_DataObject*>( parent() );
00074   return parentObj ? parentObj->dataModel() : 0;
00075 }
00076 
00093 CAM_ModuleObject::CAM_ModuleObject( SUIT_DataObject* parent )
00094 : CAM_DataObject( parent ),
00095   myDataModel( 0 )
00096 {
00097 }
00098 
00104 CAM_ModuleObject::CAM_ModuleObject( CAM_DataModel* data, SUIT_DataObject* parent )
00105 : CAM_DataObject( parent ),
00106   myDataModel( data )
00107 {
00108 }
00109 
00115 CAM_ModuleObject::~CAM_ModuleObject()
00116 {
00117 }
00118 
00127 QString CAM_ModuleObject::name() const
00128 {
00129   return myDataModel ? myDataModel->module()->moduleName() : QString();
00130 }
00131 
00140 QPixmap CAM_ModuleObject::icon( const int id ) const
00141 {
00142   QPixmap p;
00143   // show icon only for the "Name" column
00144   if ( id == NameId && dataModel() && dataModel()->module() )
00145     p = dataModel()->module()->moduleIcon();
00146   if ( !p.isNull() )
00147     p = Qtx::scaleIcon( p, 16 );
00148   return p;
00149 }
00150 
00159 QString CAM_ModuleObject::toolTip( const int /*id*/ ) const
00160 {
00161   // show the same tooltip for all columns
00162   QString tip;
00163   if ( dataModel() && dataModel()->module() )
00164     tip = QObject::tr( "MODULE_ROOT_OBJECT_TOOLTIP" ).arg( dataModel()->module()->moduleName() );
00165   return tip;
00166 }
00167 
00172 CAM_DataModel* CAM_ModuleObject::dataModel() const
00173 {
00174   return myDataModel;
00175 }
00176 
00181 void CAM_ModuleObject::setDataModel( CAM_DataModel* dm )
00182 {
00183   myDataModel = dm;
00184 }