1 // Copyright (C) 2005-2013 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
20 // LIGHT : sample (no-corba-engine) SALOME module
21 // File : LIGHTGUI_DataObject.cxx
22 // Author : Julia DOROVSKIKH
24 #include "LIGHTGUI_DataObject.h"
25 #include "LIGHTGUI_DataModel.h"
27 #include <SUIT_Session.h>
28 #include <SUIT_ResourceMgr.h>
32 \class LIGHTGUI_DataObject
33 \brief LIGHT module data object.
38 \param id line identifier
39 \param txt text line corresponding to the data object
40 \param parent parent data object
42 LIGHTGUI_DataObject::LIGHTGUI_DataObject( const int id,
44 SUIT_DataObject* parent )
45 : CAM_DataObject( parent ),
46 LightApp_DataObject( parent ),
55 LIGHTGUI_DataObject::~LIGHTGUI_DataObject()
60 \brief Get data object name.
61 \return data object name
63 QString LIGHTGUI_DataObject::name() const
65 return myLineTxt.trimmed().isEmpty() ? QObject::tr( "LIGHT_PARAGRAPH" ) : myLineTxt;
69 \brief Get data object entry.
70 \return data object entry
72 QString LIGHTGUI_DataObject::entry() const
74 return LIGHTGUI_DataModel::entry( id() );
78 \brief Get data object icon.
79 \param index data column index
80 \return data object icon for the specified column
82 QPixmap LIGHTGUI_DataObject::icon( const int index ) const
84 if ( index == NameId ) {
85 // show icon only for the "Name" column
86 static QPixmap pxp = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_PARAGRAPH" ), false );
87 static QPixmap pxl = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_LINE" ), false );
88 return myLineTxt.trimmed().isEmpty() ? pxp : pxl;
90 return LightApp_DataObject::icon( index );
94 \brief Get data object tooltip.
95 \param index data column index
96 \return data object tooltip for the specified column
98 QString LIGHTGUI_DataObject::toolTip( const int /*index*/ ) const
100 // show the same tooltip for all columns
101 return lineText().trimmed().isEmpty() ?
102 QString( QObject::tr( "LIGHT_PARAGRAPH") + " %1" ).arg( parent()->childPos( this ) + 1 ) :
103 QString( QObject::tr( "LIGHT_LINE" ) + " %1: %2" ).arg( lineNb() ).arg( lineText() );
107 \brief Get text line corresponding to the data object.
108 \return text line (empty lines means paragraph)
111 QString LIGHTGUI_DataObject::lineText() const
117 \brief Set text line corresponding to the data object.
118 \param txt text line (empty lines means paragraph)
121 void LIGHTGUI_DataObject::setLineText( const QString& txt )
127 \brief Get line number.
130 int LIGHTGUI_DataObject::lineNb() const
132 if ( level() == 1 ) // root object
136 SUIT_DataObject* o = (SUIT_DataObject*)this;
137 if ( level() == 3 ) {
138 pos += parent()->childPos( this ) + 1;
141 o = o->prevBrother();
143 pos += o->childCount() + 1;
144 o = o->prevBrother();
151 \brief Get line identifier.
152 \return line identifier
154 int LIGHTGUI_DataObject::id() const