-// LIGHT : sample (no-corba-engine) SALOME module
-//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2005-2008 OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// LIGHT : sample (no-corba-engine) SALOME module
+// File : LIGHTGUI_DataObject.cxx
+// Author : Julia DOROVSKIKH
//
-// Author : Julia DOROVSKIKH
-// Date : 01/01/2005
-// $Header$
-
#include "LIGHTGUI_DataObject.h"
+#include "LIGHTGUI_DataModel.h"
+
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
-
-#include <CAM_DataModel.h>
-#include <CAM_Module.h>
+#include <QString>
/*!
- * Class: LIGHTGUI_DataObject
- * Description: LIGHT module's data object
- */
+ \class LIGHTGUI_DataObject
+ \brief LIGHT module data object.
+*/
-//=================================================================================
-// function : LIGHTGUI_DataObject()
-// purpose : default constructor
-//=================================================================================
-LIGHTGUI_DataObject::LIGHTGUI_DataObject ( SUIT_DataObject* parent )
-: LightApp_DataObject( parent ),
- CAM_DataObject( parent )
-{
-}
-
-//=================================================================================
-// function : LIGHTGUI_DataObject()
-// purpose : constructor
-//=================================================================================
-LIGHTGUI_DataObject::LIGHTGUI_DataObject ( const QString& line_text, SUIT_DataObject* parent )
-: LightApp_DataObject( parent ),
- myLineTxt( line_text ),
- CAM_DataObject( parent)
+/*!
+ \brief Constructor.
+ \param id line identifier
+ \param txt text line corresponding to the data object
+ \param parent parent data object
+*/
+LIGHTGUI_DataObject::LIGHTGUI_DataObject( const int id,
+ const QString& txt,
+ SUIT_DataObject* parent )
+: CAM_DataObject( parent ),
+ LightApp_DataObject( parent ),
+ myLineTxt( txt ),
+ myId( id )
{
}
-//=================================================================================
-// function : ~LIGHTGUI_DataObject()
-// purpose : destructor
-//=================================================================================
+/*!
+ \brief Destructor.
+*/
LIGHTGUI_DataObject::~LIGHTGUI_DataObject()
{
}
-//=================================================================================
-// function : entry()
-// purpose : Gets object ID. retval QString
-//=================================================================================
-QString LIGHTGUI_DataObject::entry() const
+/*!
+ \brief Get data object name.
+ \return data object name
+*/
+QString LIGHTGUI_DataObject::name() const
{
- QString aStr = QString("LIGHTGUI_%1").arg(lineNb());
- return aStr;
+ return myLineTxt.trimmed().isEmpty() ? QObject::tr( "LIGHT_PARAGRAPH" ) : myLineTxt;
}
-//=================================================================================
-// function : name()
-// purpose : gets an name of the object
-//=================================================================================
-QString LIGHTGUI_DataObject::name() const
+/*!
+ \brief Get data object entry.
+ \return data object entry
+*/
+QString LIGHTGUI_DataObject::entry() const
{
- return myLineTxt.stripWhiteSpace().isEmpty() ? QObject::tr( "LIGHT_PARAGRAPH" ) : myLineTxt ;
+ return LIGHTGUI_DataModel::entry( id() );
}
-//=================================================================================
-// function : icon()
-// purpose : gets an icon for the data object
-//=================================================================================
-QPixmap LIGHTGUI_DataObject::icon() const
+/*!
+ \brief Get data object icon.
+ \param index data column index
+ \return data object icon for the specified column
+*/
+QPixmap LIGHTGUI_DataObject::icon( const int index ) const
{
- static QPixmap pxp = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_PARAGRAPH" ), false );
- static QPixmap pxl = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_LINE" ), false );
- return myLineTxt.stripWhiteSpace().isEmpty() ? pxp : pxl;
+ if ( index == NameId ) {
+ // show icon only for the "Name" column
+ static QPixmap pxp = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_PARAGRAPH" ), false );
+ static QPixmap pxl = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_LINE" ), false );
+ return myLineTxt.trimmed().isEmpty() ? pxp : pxl;
+ }
+ return LightApp_DataObject::icon( index );
}
-//=================================================================================
-// function : toolTip()
-// purpose : gets a tooltip for the object (to be displayed in the Object Browser)
-//=================================================================================
-QString LIGHTGUI_DataObject::toolTip() const
+/*!
+ \brief Get data object tooltip.
+ \param index data column index
+ \return data object tooltip for the specified column
+*/
+QString LIGHTGUI_DataObject::toolTip( const int /*index*/ ) const
{
- return lineText().stripWhiteSpace().isEmpty() ?
+ // show the same tooltip for all columns
+ return lineText().trimmed().isEmpty() ?
QString( QObject::tr( "LIGHT_PARAGRAPH") + " %1" ).arg( parent()->childPos( this ) + 1 ) :
QString( QObject::tr( "LIGHT_LINE" ) + " %1: %2" ).arg( lineNb() ).arg( lineText() );
}
-//=================================================================================
-// function : lineText()
-// purpose : gets line text
-//=================================================================================
+/*!
+ \brief Get text line corresponding to the data object.
+ \return text line (empty lines means paragraph)
+ \sa setLineText()
+*/
QString LIGHTGUI_DataObject::lineText() const
{
return myLineTxt;
}
-//=================================================================================
-// function : setLineText()
-// purpose : sets line text
-//=================================================================================
-void LIGHTGUI_DataObject::setLineText( const QString& text )
+/*!
+ \brief Set text line corresponding to the data object.
+ \param txt text line (empty lines means paragraph)
+ \sa lineText()
+*/
+void LIGHTGUI_DataObject::setLineText( const QString& txt )
{
- myLineTxt = text;
+ myLineTxt = txt;
}
-//=================================================================================
-// function : lineNb()
-// purpose : gets the line number
-//=================================================================================
+/*!
+ \brief Get line number.
+ \return line number
+*/
int LIGHTGUI_DataObject::lineNb() const
{
if ( level() == 1 ) // root object
}
/*!
- * Class: LIGHTGUI_ModuleObject
- * Description: LIGHT module's root data object
- */
-
-//=================================================================================
-// function : LIGHTGUI_ModuleObject()
-// purpose : one more constructor
-//=================================================================================
-LIGHTGUI_ModuleObject::LIGHTGUI_ModuleObject ( CAM_DataModel* dm, SUIT_DataObject* parent )
-: LIGHTGUI_DataObject( parent ),
- LightApp_ModuleObject(dm, parent),
- CAM_DataObject( parent )
-{
-}
-
-//=================================================================================
-// function : name()
-// purpose : gets an name of the root object
-//=================================================================================
-QString LIGHTGUI_ModuleObject::name() const
-{
- return CAM_RootObject::name();
-}
-
-//=================================================================================
-// function : icon()
-// purpose : gets an icon for the root object
-//=================================================================================
-QPixmap LIGHTGUI_ModuleObject::icon() const
-{
- QPixmap px;
- if (dataModel()) {
- QString anIconName = dataModel()->module()->iconName();
- if (!anIconName.isEmpty())
- px = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", anIconName, false );
- }
- return px;
-}
-
-//=================================================================================
-// function : toolTip()
-// purpose : gets a tootip for the root object
-//=================================================================================
-QString LIGHTGUI_ModuleObject::toolTip() const
+ \brief Get line identifier.
+ \return line identifier
+*/
+int LIGHTGUI_DataObject::id() const
{
- return QObject::tr( "LIGHT_ROOT_TOOLTIP" );
+ return myId;
}