From c1e14baf2fe5bf63f75ca79b4ca6278690f0053a Mon Sep 17 00:00:00 2001 From: stv Date: Wed, 20 Dec 2006 15:44:36 +0000 Subject: [PATCH] no message --- src/QDS/QDS_ComboBox.cxx | 62 ++++++++++++++++++++++++++++++++++++---- src/QDS/QDS_ComboBox.h | 4 +++ 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/src/QDS/QDS_ComboBox.cxx b/src/QDS/QDS_ComboBox.cxx index fac69b6b4..478f7187b 100644 --- a/src/QDS/QDS_ComboBox.cxx +++ b/src/QDS/QDS_ComboBox.cxx @@ -206,15 +206,39 @@ void QDS_ComboBox::setState( const bool on, const QValueList& ids, const bo /*! Sets the user items into the combo box. */ -void QDS_ComboBox::setValues( const QValueList& ids, const QStringList& names ) +void QDS_ComboBox::setValues( const QValueList& ids, const QStringList& names, + const QValueList& pixes ) { initDatum(); - if ( ids.count() != names.count() ) + if ( ids.count() != names.count() || ids.count() != pixes.count() ) return; myUserIds = ids; myUserNames = names; + + QValueList::const_iterator it = ids.begin(); + QValueList::const_iterator itr = pixes.begin(); + for ( ; it != ids.end() && itr != pixes.end(); ++it, ++itr ) + { + if ( (*itr).isNull() ) + myUserIcons.remove( *it ); + else + myUserIcons.insert( *it, *itr ); + } + updateComboData(); +} + +/*! + Sets the user items into the combo box. +*/ +void QDS_ComboBox::setValues( const QValueList& ids, const QStringList& names ) +{ + QValueList pixList; + for ( int i = 0, n = names.count(); i < n; i++ ) + pixList.append( QPixmap() ); + + setValues( ids, names, pixList ); } /*! @@ -226,12 +250,23 @@ void QDS_ComboBox::setValues( const QStringList& names ) { initDatum(); - QValueList< int > ids; + QValueList ids; for ( int i = 0, n = names.count(); i < n; i++ ) ids.append( i ); setValues( ids, names ); } +/*! + Sets the user pixmap for specified item into the combo box. +*/ +void QDS_ComboBox::setIcon( const int id, const QPixmap& pix ) +{ + initDatum(); + + myUserIcons.insert( id, pix ); + updateComboBox(); +} + /*! Sets the active item as item with default id. If default not defined then first item will be used. @@ -346,10 +381,21 @@ QWidget* QDS_ComboBox::createControl( QWidget* parent ) return cb; } +/*! + Notify about unit system changes. +*/ void QDS_ComboBox::unitSystemChanged( const QString& system ) { QDS_Datum::unitSystemChanged( system ); + updateComboData(); +} + +/*! + Updates the internal data structures. +*/ +void QDS_ComboBox::updateComboData() +{ Handle(TColStd_HArray1OfInteger) anIds; Handle(TColStd_HArray1OfExtendedString) aValues, anIcons; @@ -486,8 +532,14 @@ void QDS_ComboBox::updateComboBox() myIndex.insert( id, idx++ ); if ( cb ) { - if ( myIcons.contains( id ) ) - cb->insertItem( myIcons[id], myValue[id] ); + QPixmap pix; + if ( myUserIcons.contains( id ) ) + pix = myUserIcons[id]; + else if ( myIcons.contains( id ) ) + pix = myIcons[id]; + + if ( !pix.isNull() ) + cb->insertItem( pix, myValue[id] ); else cb->insertItem( myValue[id] ); } diff --git a/src/QDS/QDS_ComboBox.h b/src/QDS/QDS_ComboBox.h index 9650f4c58..2e7c57256 100644 --- a/src/QDS/QDS_ComboBox.h +++ b/src/QDS/QDS_ComboBox.h @@ -35,8 +35,10 @@ public: bool state( const int ) const; void setState( const bool, const int, const bool = true ); void setState( const bool, const QValueList&, const bool = true ); + void setValues( const QValueList&, const QStringList&, const QValueList& ); void setValues( const QValueList&, const QStringList& ); void setValues( const QStringList& ); + void setIcon( const int, const QPixmap& ); virtual void reset(); @@ -67,6 +69,7 @@ private: int getIndex( const QString& ) const; void updateComboBox(); + void updateComboData(); private: typedef QMap IdIconsMap; @@ -83,6 +86,7 @@ private: QIntList myDataIds; QIntList myUserIds; QStringList myUserNames; + IdIconsMap myUserIcons; }; #ifdef WNT -- 2.39.2