Skip to content

Commit

Permalink
Use consequently QList<QVariant> instead of QVariantList in this cont…
Browse files Browse the repository at this point in the history
…ext so it's easier to read and understand
  • Loading branch information
signedav committed Feb 26, 2025
1 parent dcab021 commit 8a98242
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/core/project/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,11 +685,14 @@ void QgsProject::registerTranslatableObjects( QgsTranslationContext *translation
}
if ( field.editorWidgetSetup().type() == QStringLiteral( "ValueMap" ) )
{
const QList<QVariant> valueList = field.editorWidgetSetup().config().value( QStringLiteral( "map" ) ).toList();

for ( int i = 0, row = 0; i < valueList.count(); i++, row++ )
if ( field.editorWidgetSetup().config().value( QStringLiteral( "map" ) ).canConvert<QList<QVariant>>() )
{
translationContext->registerTranslation( QStringLiteral( "project:layers:%1:fields:%2:valuemapdescriptions" ).arg( vlayer->id(), field.name() ), valueList[i].toMap().constBegin().key() );
const QList<QVariant> valueList = field.editorWidgetSetup().config().value( QStringLiteral( "map" ) ).toList();

for ( int i = 0, row = 0; i < valueList.count(); i++, row++ )
{
translationContext->registerTranslation( QStringLiteral( "project:layers:%1:fields:%2:valuemapdescriptions" ).arg( vlayer->id(), field.name() ), valueList[i].toMap().constBegin().key() );
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/vector/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2688,9 +2688,9 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
}
if ( widgetType == QStringLiteral( "ValueMap" ) )
{
QList<QVariant> translatedValueList;
if ( optionsMap[ QStringLiteral( "map" ) ].canConvert<QVariantList>() )
if ( optionsMap[ QStringLiteral( "map" ) ].canConvert<QList<QVariant>>() )
{
QList<QVariant> translatedValueList;
const QList<QVariant> valueList = optionsMap[ QStringLiteral( "map" )].toList();
for ( int i = 0, row = 0; i < valueList.count(); i++, row++ )
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/vector/qgsattributesformproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,7 @@ void QgsAttributesFormProperties::pasteWidgetConfiguration()
}
if ( widgetType == QStringLiteral( "ValueMap" ) )
{
if ( optionsMap[QStringLiteral( "map" )].canConvert<QVariantList>() )
if ( optionsMap[QStringLiteral( "map" )].canConvert<QList<QVariant>>() )
{
QList<QVariant> translatedValueList;
const QList<QVariant> valueList = optionsMap[QStringLiteral( "map" )].toList();
Expand Down

0 comments on commit 8a98242

Please sign in to comment.