1 // Copyright (C) 2005-2008 OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // LIGHT : sample (no-corba-engine) SALOME module
20 // File : LIGHTGUI_DataObject.cxx
21 // Author : Julia DOROVSKIKH
23 #include "LIGHTGUI_DataObject.h"
24 #include "LIGHTGUI_DataModel.h"
26 #include <SUIT_Session.h>
27 #include <SUIT_ResourceMgr.h>
31 \class LIGHTGUI_DataObject
32 \brief LIGHT module data object.
37 \param id line identifier
38 \param txt text line corresponding to the data object
39 \param parent parent data object
41 LIGHTGUI_DataObject::LIGHTGUI_DataObject( const int id,
43 SUIT_DataObject* parent )
44 : CAM_DataObject( parent ),
45 LightApp_DataObject( parent ),
54 LIGHTGUI_DataObject::~LIGHTGUI_DataObject()
59 \brief Get data object name.
60 \return data object name
62 QString LIGHTGUI_DataObject::name() const
64 return myLineTxt.trimmed().isEmpty() ? QObject::tr( "LIGHT_PARAGRAPH" ) : myLineTxt;
68 \brief Get data object entry.
69 \return data object entry
71 QString LIGHTGUI_DataObject::entry() const
73 return LIGHTGUI_DataModel::entry( id() );
77 \brief Get data object icon.
78 \param index data column index
79 \return data object icon for the specified column
81 QPixmap LIGHTGUI_DataObject::icon( const int index ) const
83 if ( index == NameId ) {
84 // show icon only for the "Name" column
85 static QPixmap pxp = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_PARAGRAPH" ), false );
86 static QPixmap pxl = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_LINE" ), false );
87 return myLineTxt.trimmed().isEmpty() ? pxp : pxl;
89 return LightApp_DataObject::icon( index );
93 \brief Get data object tooltip.
94 \param index data column index
95 \return data object tooltip for the specified column
97 QString LIGHTGUI_DataObject::toolTip( const int /*index*/ ) const
99 // show the same tooltip for all columns
100 return lineText().trimmed().isEmpty() ?
101 QString( QObject::tr( "LIGHT_PARAGRAPH") + " %1" ).arg( parent()->childPos( this ) + 1 ) :
102 QString( QObject::tr( "LIGHT_LINE" ) + " %1: %2" ).arg( lineNb() ).arg( lineText() );
106 \brief Get text line corresponding to the data object.
107 \return text line (empty lines means paragraph)
110 QString LIGHTGUI_DataObject::lineText() const
116 \brief Set text line corresponding to the data object.
117 \param txt text line (empty lines means paragraph)
120 void LIGHTGUI_DataObject::setLineText( const QString& txt )
126 \brief Get line number.
129 int LIGHTGUI_DataObject::lineNb() const
131 if ( level() == 1 ) // root object
135 SUIT_DataObject* o = (SUIT_DataObject*)this;
136 if ( level() == 3 ) {
137 pos += parent()->childPos( this ) + 1;
140 o = o->prevBrother();
142 pos += o->childCount() + 1;
143 o = o->prevBrother();
150 \brief Get line identifier.
151 \return line identifier
153 int LIGHTGUI_DataObject::id() const