#include <stdio.h>
+namespace
+{
+ bool toStringList(const QVariant& value, QStringList& result)
+ {
+ bool ok = false;
+ if ( value.type() == QVariant::StringList )
+ {
+ result = value.toStringList();
+ ok = true;
+ }
+ else if ( value.type() == QVariant::List )
+ {
+ QList<QVariant> valueList = value.toList();
+ for ( QList<QVariant>::const_iterator it = valueList.begin(); it != valueList.end(); ++it )
+ {
+ if ( (*it).canConvert( QVariant::String ) )
+ result.append( (*it).toString() );
+ }
+ ok = true;
+ }
+ return ok;
+ }
+}
+
/*!
\class QtxPagePrefMgr
\brief GUI implementation of the QtxPreferenceMgr class: preferences manager.
QStringList QtxPagePrefSelectItem::strings() const
{
QStringList res;
- for ( uint i = 0; i < mySelector->count(); i++ )
+ for ( int i = 0; i < mySelector->count(); i++ )
res.append( mySelector->itemText( i ) );
return res;
}
QList<int> QtxPagePrefSelectItem::numbers() const
{
QList<int> res;
- for ( uint i = 0; i < mySelector->count(); i++ )
+ for ( int i = 0; i < mySelector->count(); i++ )
{
if ( mySelector->hasId( i ) )
res.append( mySelector->id( i ) );
QList<QIcon> QtxPagePrefSelectItem::icons() const
{
QList<QIcon> res;
- for ( uint i = 0; i < mySelector->count(); i++ )
+ for ( int i = 0; i < mySelector->count(); i++ )
res.append( mySelector->itemIcon( i ) );
return res;
}
*/
void QtxPagePrefSelectItem::setNumbers( const QList<int>& ids )
{
- uint i = 0;
+ int i = 0;
for ( QList<int>::const_iterator it = ids.begin(); it != ids.end(); ++it, i++ ) {
if ( i >= mySelector->count() )
mySelector->addItem(QString("") );
*/
void QtxPagePrefSelectItem::setIcons( const QList<QIcon>& icns )
{
- uint i = 0;
+ int i = 0;
for ( QList<QIcon>::const_iterator it = icns.begin(); it != icns.end() && i < mySelector->count(); ++it, i++ )
mySelector->setItemIcon( i, *it );
}
idx = mySelector->index( num );
else
{
- for ( uint i = 0; i < mySelector->count() && idx == -1; i++ )
+ for ( int i = 0; i < mySelector->count() && idx == -1; i++ )
{
if ( mySelector->itemText( i ) == txt )
idx = i;
*/
void QtxPagePrefSelectItem::setStrings( const QVariant& var )
{
- if ( var.type() != QVariant::StringList )
- return;
-
- setStrings( var.toStringList() );
+ QStringList values;
+ if ( toStringList( var, values ) )
+ setStrings( values );
}
/*!
}
else if ( name == "fonts" || name == "families" )
{
- if ( val.canConvert( QVariant::StringList ) )
- setFonts( val.toStringList() );
+ QStringList values;
+ if ( toStringList( val, values ) )
+ setFonts( values );
}
else if ( name == "sizes" )
{
setImageFormats( val.toString() );
}
else if ( name == "gradient_names" ) {
- if ( val.canConvert( QVariant::StringList ) )
- setGradients( val.toStringList() );
+ QStringList values;
+ if ( toStringList( val, values ) )
+ setGradients( values );
}
else if ( name == "gradient_ids" ) {
if ( val.canConvert( QVariant::List ) ) {