1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : QAD_ObjectBrowserItem.cxx
25 // Author : Nicolas REJNERI
30 #include "QAD_ObjectBrowserItem.h"
33 #include <qlistview.h>
35 #include <qstringlist.h>
41 QAD_ObjectBrowserItem::QAD_ObjectBrowserItem( QListView *theParent )
42 : QListViewItem(theParent)
47 QAD_ObjectBrowserItem::QAD_ObjectBrowserItem( QListView* theParent, QAD_ObjectBrowserItem* after )
48 : QListViewItem(theParent, after)
53 QAD_ObjectBrowserItem::QAD_ObjectBrowserItem( QAD_ObjectBrowserItem *theParent )
54 : QListViewItem(theParent)
59 QAD_ObjectBrowserItem::QAD_ObjectBrowserItem( QAD_ObjectBrowserItem *theParent, QAD_ObjectBrowserItem* after )
60 : QListViewItem(theParent, after)
69 QAD_ObjectBrowserItem::~QAD_ObjectBrowserItem()
76 void QAD_ObjectBrowserItem::setType( int type )
85 void QAD_ObjectBrowserItem::setTextColor( const QColor& color )
92 Sets text highlight color
94 void QAD_ObjectBrowserItem::setTextHighlightColor(const QColor& color)
96 myTextHighlightColor = color;
102 QString QAD_ObjectBrowserItem::getName() const
104 return QListViewItem::text( 0 );
110 void QAD_ObjectBrowserItem::setName( const QString& name )
118 QString QAD_ObjectBrowserItem::getValue() const
120 return QListViewItem::text( 1 );
126 void QAD_ObjectBrowserItem::setValue( const QString& value )
134 QString QAD_ObjectBrowserItem::getEntry() const
136 return QListViewItem::text( 2 );
142 void QAD_ObjectBrowserItem::setEntry( const QString& entry )
150 QString QAD_ObjectBrowserItem::getIOR() const
152 return QListViewItem::text( 3 );
158 void QAD_ObjectBrowserItem::setIOR( const QString& IOR )
166 QString QAD_ObjectBrowserItem::getReference() const
168 return QListViewItem::text( 4 );
174 void QAD_ObjectBrowserItem::setReference( const QString& ref )
179 Returns true if this item is current (for UseCase browser - it is bold)
181 bool QAD_ObjectBrowserItem::isCurrent() const
186 Sets this item to be current (for UseCase browser - it is bold)
188 void QAD_ObjectBrowserItem::setCurrent( bool on )
195 Paints cell [ redefined ]
197 void QAD_ObjectBrowserItem::paintCell( QPainter* thePainter,
198 const QColorGroup& theColorGroup,
203 QColorGroup aColorGroup(theColorGroup);
204 QColor aColor = aColorGroup.text();
205 QColor aColorHighlight = aColorGroup.highlight();
211 aColorGroup.setColor(QColorGroup::Text, Qt::blue);
212 aColorGroup.setColor(QColorGroup::Highlight, Qt::blue);
217 aColorGroup.setColor(QColorGroup::Text, Qt::red);
218 aColorGroup.setColor(QColorGroup::Highlight, Qt::red);
223 aColorGroup.setColor(QColorGroup::Text, Qt::black);
224 aColorGroup.setColor(QColorGroup::Highlight, Qt::black);
229 if (myTextColor.isValid()) {
230 aColorGroup.setColor(QColorGroup::Text, myTextColor);
231 aColorGroup.setColor(QColorGroup::HighlightedText, myTextColor);
233 if (myTextHighlightColor.isValid())
234 aColorGroup.setColor(QColorGroup::Highlight, myTextHighlightColor);
235 if (myCurrent) { // UseCase's current entry
236 QFont font = thePainter->font();
238 thePainter->setFont(font);
241 QListViewItem::paintCell(thePainter,
246 aColorGroup.setColor(QColorGroup::Text, aColor);
247 aColorGroup.setColor(QColorGroup::Highlight, aColorHighlight);
251 Returns item's column text
252 Overrided to protect access outside
254 QString QAD_ObjectBrowserItem::text( int column ) const
256 return QListViewItem::text( column );
260 Compares two item to sort list view data by column
262 int QAD_ObjectBrowserItem::compare( QListViewItem* i, int col, bool ascending ) const
264 // Additional check is necessary for Entry or Reference entry (2 and 4) columns
265 if ( ( col == 2 || col == 4 ) && !key( col, ascending ).isEmpty() && !i->key( col, ascending ).isEmpty() ) {
266 QStringList mylist = QStringList::split( ":", key( col, ascending ), false );
267 QStringList ilist = QStringList::split( ":", i->key( col, ascending ), false );
268 if ( mylist.count() != ilist.count() || mylist.count() == 0 )
269 return ( mylist.count() < ilist.count() ) ? -1 : 1;
270 for ( int i = 0; i < mylist.count(); i++ ) {
271 if ( mylist[i].toInt() < ilist[i].toInt() )
273 else if ( mylist[i].toInt() > ilist[i].toInt() )
278 return QListViewItem::compare( i, col, ascending );