mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Value Relation implementation
Values in the Value Relation widgets can be translated now - means changed. So the setting-change is made to get translated values over another layer.
This commit is contained in:
parent
c6b05b994b
commit
5ef079970d
@ -479,10 +479,18 @@ void QgsProject::registerTranslatableObjects( QgsTranslationContext *translation
|
||||
const QgsFields fields = vlayer->fields();
|
||||
for ( const QgsField &field : fields )
|
||||
{
|
||||
QString fieldName;
|
||||
if ( field.alias().isEmpty() )
|
||||
translationContext->registerTranslation( QStringLiteral( "project:layers:%1:fieldaliases" ).arg( vlayer->id() ), field.name() );
|
||||
fieldName = field.name();
|
||||
else
|
||||
translationContext->registerTranslation( QStringLiteral( "project:layers:%1:fieldaliases" ).arg( vlayer->id() ), field.alias() );
|
||||
fieldName = field.alias();
|
||||
|
||||
translationContext->registerTranslation( QStringLiteral( "project:layers:%1:fieldaliases" ).arg( vlayer->id() ), fieldName );
|
||||
|
||||
if ( field.editorWidgetSetup().type() == QStringLiteral( "ValueRelation" ) )
|
||||
{
|
||||
translationContext->registerTranslation( QStringLiteral( "project:layers:%1:fields:%2:valuerelationvalue" ).arg( vlayer->id(), field.name() ), field.editorWidgetSetup().config().value( QStringLiteral( "Value" ) ).toString() );
|
||||
}
|
||||
}
|
||||
|
||||
//register formcontainers
|
||||
|
@ -2035,6 +2035,10 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
|
||||
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 == 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() );
|
||||
}
|
||||
QgsEditorWidgetSetup setup = QgsEditorWidgetSetup( widgetType, optionsMap );
|
||||
mFieldWidgetSetups[fieldName] = setup;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ void TestQgsTranslateProject::cleanupTestCase()
|
||||
|
||||
//delete created ts file
|
||||
QString tsFileName( TEST_DATA_DIR );
|
||||
tsFileName = tsFileName + "/project_translation/points_translation_de.ts";
|
||||
tsFileName = tsFileName + "/project_translation/points_translation.ts";
|
||||
QFile tsFile( tsFileName );
|
||||
tsFile.remove();
|
||||
}
|
||||
@ -99,7 +99,7 @@ void TestQgsTranslateProject::createTsFile()
|
||||
|
||||
//check if ts file is created
|
||||
QString tsFileName( TEST_DATA_DIR );
|
||||
tsFileName = tsFileName + "/project_translation/points_translation_de.ts";
|
||||
tsFileName = tsFileName + "/project_translation/points_translation.ts";
|
||||
QFile tsFile( tsFileName );
|
||||
QVERIFY( tsFile.exists() );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user