2 // File : QAD_ObjectBrowserItem.cxx
3 // Created : Thu Jun 14 17:07:42 2001
4 // Author : Nicolas REJNERI
7 // Copyright : Open CASCADE
10 #include "QAD_ObjectBrowserItem.h"
13 #include <qlistview.h>
15 #include <qstringlist.h>
21 QAD_ObjectBrowserItem::QAD_ObjectBrowserItem( QListView *theParent )
22 : QListViewItem(theParent)
27 QAD_ObjectBrowserItem::QAD_ObjectBrowserItem( QListView* theParent, QAD_ObjectBrowserItem* after )
28 : QListViewItem(theParent, after)
33 QAD_ObjectBrowserItem::QAD_ObjectBrowserItem( QAD_ObjectBrowserItem *theParent )
34 : QListViewItem(theParent)
39 QAD_ObjectBrowserItem::QAD_ObjectBrowserItem( QAD_ObjectBrowserItem *theParent, QAD_ObjectBrowserItem* after )
40 : QListViewItem(theParent, after)
49 QAD_ObjectBrowserItem::~QAD_ObjectBrowserItem()
56 void QAD_ObjectBrowserItem::setType( int type )
65 void QAD_ObjectBrowserItem::setTextColor( const QColor& color )
72 Sets text highlight color
74 void QAD_ObjectBrowserItem::setTextHighlightColor(const QColor& color)
76 myTextHighlightColor = color;
82 QString QAD_ObjectBrowserItem::getName() const
84 return QListViewItem::text( 0 );
90 void QAD_ObjectBrowserItem::setName( const QString& name )
98 QString QAD_ObjectBrowserItem::getValue() const
100 return QListViewItem::text( 1 );
106 void QAD_ObjectBrowserItem::setValue( const QString& value )
114 QString QAD_ObjectBrowserItem::getEntry() const
116 return QListViewItem::text( 2 );
122 void QAD_ObjectBrowserItem::setEntry( const QString& entry )
130 QString QAD_ObjectBrowserItem::getIOR() const
132 return QListViewItem::text( 3 );
138 void QAD_ObjectBrowserItem::setIOR( const QString& IOR )
146 QString QAD_ObjectBrowserItem::getReference() const
148 return QListViewItem::text( 4 );
154 void QAD_ObjectBrowserItem::setReference( const QString& ref )
159 Returns true if this item is current (for UseCase browser - it is bold)
161 bool QAD_ObjectBrowserItem::isCurrent() const
166 Sets this item to be current (for UseCase browser - it is bold)
168 void QAD_ObjectBrowserItem::setCurrent( bool on )
175 Paints cell [ redefined ]
177 void QAD_ObjectBrowserItem::paintCell( QPainter* thePainter,
178 const QColorGroup& theColorGroup,
183 QColorGroup aColorGroup(theColorGroup);
184 QColor aColor = aColorGroup.text();
185 QColor aColorHighlight = aColorGroup.highlight();
191 aColorGroup.setColor(QColorGroup::Text, Qt::blue);
192 aColorGroup.setColor(QColorGroup::Highlight, Qt::blue);
197 aColorGroup.setColor(QColorGroup::Text, Qt::red);
198 aColorGroup.setColor(QColorGroup::Highlight, Qt::red);
203 aColorGroup.setColor(QColorGroup::Text, Qt::black);
204 aColorGroup.setColor(QColorGroup::Highlight, Qt::black);
209 if (myTextColor.isValid())
210 aColorGroup.setColor(QColorGroup::Text, myTextColor);
211 if (myTextHighlightColor.isValid())
212 aColorGroup.setColor(QColorGroup::Highlight, myTextHighlightColor);
213 if (myCurrent) { // UseCase's current entry
214 QFont font = thePainter->font();
216 thePainter->setFont(font);
219 QListViewItem::paintCell(thePainter,
224 aColorGroup.setColor(QColorGroup::Text, aColor);
225 aColorGroup.setColor(QColorGroup::Highlight, aColorHighlight);
229 Returns item's column text
230 Overrided to protect access outside
232 QString QAD_ObjectBrowserItem::text( int column ) const
234 return QListViewItem::text( column );
238 Compares two item to sort list view data by column
240 int QAD_ObjectBrowserItem::compare( QListViewItem* i, int col, bool ascending ) const
242 // Additional check is necessary for Entry or Reference entry (2 and 4) columns
243 if ( ( col == 2 || col == 4 ) && !key( col, ascending ).isEmpty() && !i->key( col, ascending ).isEmpty() ) {
244 QStringList mylist = QStringList::split( ":", key( col, ascending ), false );
245 QStringList ilist = QStringList::split( ":", i->key( col, ascending ), false );
246 if ( mylist.count() != ilist.count() || mylist.count() == 0 )
247 return ( mylist.count() < ilist.count() ) ? -1 : 1;
248 for ( int i = 0; i < mylist.count(); i++ ) {
249 if ( mylist[i].toInt() < ilist[i].toInt() )
251 else if ( mylist[i].toInt() > ilist[i].toInt() )
256 return QListViewItem::compare( i, col, ascending );