From 63323d731a1337a9fd0d8331e93df691ccb2fec9 Mon Sep 17 00:00:00 2001 From: dmv Date: Tue, 3 Nov 2009 13:59:08 +0000 Subject: [PATCH] 0020012: EDF 831 GEOM : API for points representation in 3D viewer --- src/Qtx/QtxPagePrefMgr.cxx | 74 +++++++++++++++++++++++++++++++++++++- src/Qtx/QtxPagePrefMgr.h | 3 ++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/Qtx/QtxPagePrefMgr.cxx b/src/Qtx/QtxPagePrefMgr.cxx index 4d333f884..2512207dc 100644 --- a/src/Qtx/QtxPagePrefMgr.cxx +++ b/src/Qtx/QtxPagePrefMgr.cxx @@ -2322,6 +2322,22 @@ QList QtxPagePrefSelectItem::numbers() const return res; } +/*! + \brief Get the list of the graphic identifiers from the selection widget. + \return list of pixmaps + \sa icons(), setIcons() +*/ +QList QtxPagePrefSelectItem::icons() const +{ + QList res; + for ( uint i = 0; i < mySelector->count(); i++ ) + { + if ( mySelector->hasId( i ) ) + res.append( mySelector->itemIcon ( i ) ); + } + return res; +} + /*! \brief Set the list of the values to the selection widget. \param lst new list of values @@ -2341,8 +2357,24 @@ void QtxPagePrefSelectItem::setStrings( const QStringList& lst ) void QtxPagePrefSelectItem::setNumbers( const QList& ids ) { uint i = 0; - for ( QList::const_iterator it = ids.begin(); it != ids.end() && i < mySelector->count(); ++it, i++ ) + for ( QList::const_iterator it = ids.begin(); it != ids.end(); ++it, i++ ) { + if ( i >= mySelector->count() ) + mySelector->addItem(QString("") ); + mySelector->setId( i, *it ); + } +} + +/*! + \brief Set the list of the graphic identifiers to the selection widget. + \param pix new list of Icons + \sa icons(), setIcons() +*/ +void QtxPagePrefSelectItem::setIcons( const QList& icons ) +{ + uint i = 0; + for ( QList::const_iterator it = icons.begin(); it != icons.end() && i < mySelector->count(); ++it, i++ ) + mySelector->setItemIcon( i, *it ); } /*! @@ -2421,6 +2453,14 @@ QVariant QtxPagePrefSelectItem::optionValue( const QString& name ) const for ( QList::const_iterator it = nums.begin(); it != nums.end(); ++it ) lst.append( *it ); return lst; + } else if ( name == "icons" ) + { + QList lst; + QList ico; + ico = icons(); + for ( QList::const_iterator it = ico.begin(); it != ico.end(); ++it ) + lst.append( *it ); + return lst; } else return QtxPageNamedPrefItem::optionValue( name ); @@ -2443,6 +2483,8 @@ void QtxPagePrefSelectItem::setOptionValue( const QString& name, const QVariant& setStrings( val ); else if ( name == "numbers" || name == "ids" || name == "indexes" ) setNumbers( val ); + else if ( name == "icons" ) + setIcons( val ); else QtxPageNamedPrefItem::setOptionValue( name, val ); } @@ -2480,6 +2522,36 @@ void QtxPagePrefSelectItem::setNumbers( const QVariant& var ) setNumbers( lst ); } +/*! + \brief Set the list of the graphic identifiers from the resource manager. + \param var new icons list + \internal +*/ +void QtxPagePrefSelectItem::setIcons( const QVariant& var ) +{ + if ( var.type() != QVariant::List ) + return; + + QList lst; + QList varList = var.toList(); + int index=1; + for ( QList::const_iterator it = varList.begin(); it != varList.end(); ++it ) + { + index++; + if ( (*it).canConvert() ) { + printf("\nQIcon Item Appended!!!"); + QIcon icon = (*it).value(); + lst.append( icon ); + } else if ( (*it).canConvert() ) { + printf("\nQPixmap Item Appended!!!"); + QPixmap pix = (*it).value(); + QIcon icon (pix); + lst.append( icon ); + } + } + setIcons( lst ); +} + /*! \brief Update selector widget. */ diff --git a/src/Qtx/QtxPagePrefMgr.h b/src/Qtx/QtxPagePrefMgr.h index 28fada6dc..8fd99e324 100644 --- a/src/Qtx/QtxPagePrefMgr.h +++ b/src/Qtx/QtxPagePrefMgr.h @@ -434,9 +434,11 @@ public: QStringList strings() const; QList numbers() const; + QList icons() const; void setStrings( const QStringList& ); void setNumbers( const QList& ); + void setIcons( const QList& ); virtual void store(); virtual void retrieve(); @@ -449,6 +451,7 @@ private: void updateSelector(); void setStrings( const QVariant& ); void setNumbers( const QVariant& ); + void setIcons( const QVariant& ); private: int myType; -- 2.39.2