Skip to content
Permalink
Browse files

Start with empty ValueMap configuration

  • Loading branch information
m-kuhn committed Dec 20, 2016
1 parent d6cc6bd commit 590a51ee8de4a38e19de04377ba0e5e56f840bfc
@@ -37,7 +37,9 @@ QString QgsValueMapFieldKit::representValue( QgsVectorLayer* layer, int fieldInd
else
valueInternalText = value.toString();

return config.key( valueInternalText, QVariant( QStringLiteral( "(%1)" ).arg( layer->fields().at( fieldIndex ).displayString( value ) ) ).toString() );
QVariantMap map = config.value( QStringLiteral( "map" ) ).toMap();

return map.key( valueInternalText, QVariant( QStringLiteral( "(%1)" ).arg( layer->fields().at( fieldIndex ).displayString( value ) ) ).toString() );
}

QVariant QgsValueMapFieldKit::sortValue( QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const
@@ -39,7 +39,7 @@ QgsValueMapConfigDlg::QgsValueMapConfigDlg( QgsVectorLayer* vl, int fieldIdx, QW

QVariantMap QgsValueMapConfigDlg::config()
{
QVariantMap cfg;
QVariantMap values;
QSettings settings;

//store data to map
@@ -57,14 +57,16 @@ QVariantMap QgsValueMapConfigDlg::config()

if ( !vi || vi->text().isNull() )
{
cfg.insert( ks, ks );
values.insert( ks, ks );
}
else
{
cfg.insert( vi->text(), ks );
values.insert( vi->text(), ks );
}
}

QVariantMap cfg;
cfg.insert( QStringLiteral( "map" ), values );
return cfg;
}

@@ -77,7 +79,8 @@ void QgsValueMapConfigDlg::setConfig( const QVariantMap& config )
}

int row = 0;
for ( QVariantMap::ConstIterator mit = config.begin(); mit != config.end(); mit++, row++ )
QVariantMap values = config.value( QStringLiteral( "map" ) ).toMap();
for ( QVariantMap::ConstIterator mit = values.begin(); mit != values.end(); mit++, row++ )
{
if ( mit.value().isNull() )
setRow( row, mit.key(), QString() );
@@ -58,10 +58,10 @@ void QgsValueMapWidgetWrapper::initWidget( QWidget* editor )

if ( mComboBox )
{
const QVariantMap cfg = config();
QVariantMap::ConstIterator it = cfg.constBegin();
const QVariantMap map = config().value( QStringLiteral( "map" ) ).toMap();
QVariantMap::ConstIterator it = map.constBegin();

while ( it != cfg.constEnd() )
while ( it != map.constEnd() )
{
mComboBox->addItem( it.key(), it.value() );
++it;

0 comments on commit 590a51e

Please sign in to comment.
You can’t perform that action at this time.