-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Project Translation considers descriptions of Value Map Widget #60744
base: master
Are you sure you want to change the base?
Changes from all commits
5d63c80
864543b
529d85b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2674,17 +2674,34 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes | |
if ( categories.testFlag( Fields ) ) | ||
mFieldConfigurationFlags[fieldName] = qgsFlagKeysToValue( fieldConfigElement.attribute( QStringLiteral( "configurationFlags" ) ), Qgis::FieldConfigurationFlag::NoFlag ); | ||
|
||
// Load editor widget configuration | ||
// load editor widget configuration | ||
if ( categories.testFlag( Forms ) ) | ||
{ | ||
const QString widgetType = fieldWidgetElement.attribute( QStringLiteral( "type" ) ); | ||
const QDomElement cfgElem = fieldConfigElement.elementsByTagName( QStringLiteral( "config" ) ).at( 0 ).toElement(); | ||
const QDomElement optionsElem = cfgElem.childNodes().at( 0 ).toElement(); | ||
QVariantMap optionsMap = QgsXmlUtils::readVariant( optionsElem ).toMap(); | ||
if ( widgetType == QLatin1String( "ValueRelation" ) ) | ||
// translate widged configuration strings | ||
if ( widgetType == QStringLiteral( "ValueRelation" ) ) | ||
{ | ||
optionsMap[ QStringLiteral( "Value" ) ] = context.projectTranslator()->translate( QStringLiteral( "project:layers:%1:fields:%2:valuerelationvalue" ).arg( layerNode.namedItem( QStringLiteral( "id" ) ).toElement().text(), fieldName ), optionsMap[ QStringLiteral( "Value" ) ].toString() ); | ||
} | ||
if ( widgetType == QStringLiteral( "ValueMap" ) ) | ||
{ | ||
QList<QVariant> translatedValueList; | ||
if ( optionsMap[ QStringLiteral( "map" ) ].canConvert<QVariantList>() ) | ||
{ | ||
const QList<QVariant> valueList = optionsMap[ QStringLiteral( "map" )].toList(); | ||
for ( int i = 0, row = 0; i < valueList.count(); i++, row++ ) | ||
{ | ||
QMap<QString, QVariant> translatedValueMap; | ||
QString translatedKey = context.projectTranslator()->translate( QStringLiteral( "project:layers:%1:fields:%2:valuemapdescriptions" ).arg( layerNode.namedItem( QStringLiteral( "id" ) ).toElement().text(), fieldName ), valueList[i].toMap().constBegin().key() ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so there's a map in the list? and only one entry in this map with key/value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. It changed from map to single-entry-map in list when the order-option was introduced. Why it's a single-entry-map and not e.g. pair I don't recall but I guess due to backwards compatibility... |
||
translatedValueMap.insert( translatedKey, valueList[i].toMap().constBegin().value() ); | ||
translatedValueList.append( translatedValueMap ); | ||
} | ||
optionsMap.insert( QStringLiteral( "map" ), translatedValueList ); | ||
} | ||
} | ||
QgsEditorWidgetSetup setup = QgsEditorWidgetSetup( widgetType, optionsMap ); | ||
mFieldWidgetSetups[fieldName] = setup; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.