-// LIGHT : sample (no-corba-engine) SALOME module
+// Copyright (C) 2005-2023 OPEN CASCADE
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// You should have received a copy 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
//
-// You should have received a copy 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-// Author : Julia DOROVSKIKH
-// Date : 01/01/2005
-// $Header$
+// File : LIGHTGUI_DataObject.cxx
+// Author : Julia DOROVSKIKH
#include "LIGHTGUI_DataObject.h"
-#include <SUIT_Session.h>
+#include "LIGHTGUI_DataModel.h"
+
#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
/*!
- * 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 )
- : CAM_DataObject( parent )
-{
-}
+ This class presents an elementary unit of the data model.
+ It includes presentation methods like: name(), icon(), toolTip(), etc.
+*/
-//=================================================================================
-// function : LIGHTGUI_DataObject()
-// purpose : constructor
-//=================================================================================
-LIGHTGUI_DataObject::LIGHTGUI_DataObject ( const QString& line_text, SUIT_DataObject* parent )
- : CAM_DataObject( parent ),
- myLineTxt( line_text )
+/*!
+ \brief Constructor.
+ \param id line identifier
+ \param txt text line corresponding to the data object
+ \param parent parent data object
+
+ \note Due to virtual inheritance, the constructor explicitly
+ invokes constructor of all base classes
+*/
+LIGHTGUI_DataObject::LIGHTGUI_DataObject( const int id,
+ const QString& txt,
+ SUIT_DataObject* parent )
+: CAM_DataObject( parent ),
+ LightApp_DataObject( parent ),
+ myId( id ),
+ myLineTxt( txt )
{
}
-//=================================================================================
-// function : ~LIGHTGUI_DataObject()
-// purpose : destructor
-//=================================================================================
+/*!
+ \brief Destructor.
+*/
LIGHTGUI_DataObject::~LIGHTGUI_DataObject()
{
}
-//=================================================================================
-// function : name()
-// purpose : gets an name of the object
-//=================================================================================
+/*!
+ \brief Get data object name.
+ \return data object name
+*/
QString LIGHTGUI_DataObject::name() const
{
- return myLineTxt.stripWhiteSpace().isEmpty() ? QObject::tr( "LIGHT_PARAGRAPH" ) : myLineTxt ;
+ return myLineTxt.trimmed().isEmpty() ? QObject::tr( "LIGHT_PARAGRAPH" ) : myLineTxt;
}
-//=================================================================================
-// function : icon()
-// purpose : gets an icon for the data object
-//=================================================================================
-QPixmap LIGHTGUI_DataObject::icon() const
+/*!
+ \brief Get data object entry.
+ \return data object entry
+*/
+QString LIGHTGUI_DataObject::entry() 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;
+ return LIGHTGUI_DataModel::entry( id() );
}
-//=================================================================================
-// 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 icon.
+ \param index data column index
+ \return data object icon for the specified column
+*/
+QPixmap LIGHTGUI_DataObject::icon( const int index ) const
{
- return lineText().stripWhiteSpace().isEmpty() ?
+ 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 );
+}
+
+/*!
+ \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
+{
+ // 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 ),
- CAM_RootObject( dm, parent ),
- CAM_DataObject( parent )
-{
-}
-
-//=================================================================================
-// function : name()
-// purpose : gets an name of the root object
-//=================================================================================
-QString LIGHTGUI_ModuleObject::name() const
-{
- return QObject::tr( "LIGHT_LIGHT" );
-}
-
-//=================================================================================
-// function : icon()
-// purpose : gets an icon for the root object
-//=================================================================================
-QPixmap LIGHTGUI_ModuleObject::icon() const
-{
- static QPixmap px = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_LIGHT" ), 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;
}