Save/restore a few more layout item properties

This commit is contained in:
Nyall Dawson 2017-10-04 18:23:22 +10:00
parent 80e0e07202
commit 616aec1566
2 changed files with 25 additions and 15 deletions

View File

@ -649,21 +649,20 @@ bool QgsLayoutItem::writePropertiesToElement( QDomElement &element, QDomDocument
element.setAttribute( QStringLiteral( "size" ), mItemSize.encodeSize() );
element.setAttribute( QStringLiteral( "rotation" ), QString::number( rotation() ) );
//TODO
/*
composerItemElem.setAttribute( "zValue", QString::number( zValue() ) );
composerItemElem.setAttribute( "visibility", isVisible() );
element.setAttribute( "zValue", QString::number( zValue() ) );
element.setAttribute( "visibility", isVisible() );
//position lock for mouse moves/resizes
if ( mItemPositionLocked )
if ( mIsLocked )
{
composerItemElem.setAttribute( "positionLock", "true" );
element.setAttribute( "positionLock", "true" );
}
else
{
composerItemElem.setAttribute( "positionLock", "false" );
element.setAttribute( "positionLock", "false" );
}
*/
//TODO
#if 0
//blend mode
// composerItemElem.setAttribute( "blendMode", QgsMapRenderer::getBlendModeEnum( mBlendMode ) );
@ -671,6 +670,7 @@ bool QgsLayoutItem::writePropertiesToElement( QDomElement &element, QDomDocument
// composerItemElem.setAttribute( "transparency", QString::number( mTransparency ) );
// composerItemElem.setAttribute( "excludeFromExports", mExcludeFromExports );
#endif
writeObjectPropertiesToElement( element, document, context );
return true;
@ -691,26 +691,30 @@ bool QgsLayoutItem::readPropertiesFromElement( const QDomElement &element, const
/*
// temporary for groups imported from templates
mTemplateUuid = itemElem.attribute( "templateUuid" );
*/
//position lock for mouse moves/resizes
QString positionLock = itemElem.attribute( "positionLock" );
QString positionLock = element.attribute( "positionLock" );
if ( positionLock.compare( "true", Qt::CaseInsensitive ) == 0 )
{
setPositionLock( true );
setLocked( true );
}
else
{
setPositionLock( false );
setLocked( false );
}
//visibility
setVisibility( itemElem.attribute( "visibility", "1" ) != "0" );
setZValue( itemElem.attribute( "zValue" ).toDouble() );
setVisible( element.attribute( "visibility", "1" ) != "0" );
setZValue( element.attribute( "zValue" ).toDouble() );
#if 0 //TODO
//blend mode
setBlendMode( QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) itemElem.attribute( "blendMode", "0" ).toUInt() ) );
setBlendMode( QgsMapRenderer::getCompositionMode( ( QgsMapRenderer::BlendMode ) itemElem.attribute( "blendMode", "0" ).toUInt() ) );
//transparency
setTransparency( itemElem.attribute( "transparency", "0" ).toInt() );
mExcludeFromExports = itemElem.attribute( "excludeFromExports", "0" ).toInt();
mEvaluatedExcludeFromExports = mExcludeFromExports;
*/
#endif
return true;
}

View File

@ -1321,6 +1321,9 @@ void TestQgsLayoutItem::writeReadXmlProperties()
original->attemptMove( QgsLayoutPoint( 0.05, 0.09, QgsUnitTypes::LayoutMeters ) );
original->setItemRotation( 45.0 );
original->setId( QStringLiteral( "test" ) );
original->setLocked( true );
original->setZValue( 55 );
original->setVisible( false );
QgsLayoutItem *copy = createCopyViaXml( &l, original );
@ -1334,6 +1337,9 @@ void TestQgsLayoutItem::writeReadXmlProperties()
QCOMPARE( copy->sizeWithUnits(), original->sizeWithUnits() );
QCOMPARE( copy->positionWithUnits(), original->positionWithUnits() );
QCOMPARE( copy->itemRotation(), original->itemRotation() );
QVERIFY( copy->isLocked() );
QCOMPARE( copy->zValue(), 55.0 );
QVERIFY( !copy->isVisible() );
delete copy;
delete original;