[layouts] Fix loss of composition variables when converting 2.x compositions

This commit is contained in:
Nyall Dawson 2019-01-16 16:21:32 +10:00
parent cabcce1fcd
commit 83340d0dfb
3 changed files with 17 additions and 1 deletions

View File

@ -126,6 +126,8 @@ std::unique_ptr< QgsPrintLayout > QgsCompositionConverter::createLayoutFromCompo
std::unique_ptr< QgsPrintLayout > layout = qgis::make_unique< QgsPrintLayout >( project );
layout->undoStack()->blockCommands( true );
layout->mCustomProperties.readXml( composerElement );
// Guides
layout->guides().setVisible( composerElement.attribute( QStringLiteral( "guidesVisible" ), QStringLiteral( "1" ) ).toInt() != 0 );

View File

@ -558,6 +558,11 @@ void TestQgsCompositionConverter::convertComposition()
QCOMPARE( layout->name(), QStringLiteral( "composer title" ) );
QCOMPARE( layout->renderContext().dpi(), 305.0 );
QStringList variableNames = layout->customProperty( QStringLiteral( "variableNames" ) ).toStringList();
QStringList variableValues = layout->customProperty( QStringLiteral( "variableValues" ) ).toStringList();
QCOMPARE( variableNames, QStringList() << QStringLiteral( "variable1" ) << QStringLiteral( "variable2" ) );
QCOMPARE( variableValues, QStringList() << QStringLiteral( "100" ) << QStringLiteral( "200" ) );
// Check guides
QCOMPARE( layout->guides().rowCount( QModelIndex() ), 8 );

View File

@ -583,7 +583,16 @@
</ComposerFrame>
<customproperties/>
</ComposerAttributeTableV2>
<customproperties/>
<customproperties>
<property key="variableNames">
<value>variable1</value>
<value>variable2</value>
</property>
<property key="variableValues">
<value>100</value>
<value>200</value>
</property>
</customproperties>
</Composition>
</Composer>
<Composer title="composer atlas" visible="0">