Skip to content

Commit

Permalink
Save/restore a few more layout item properties
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 6, 2017
1 parent 80e0e07 commit 616aec1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/core/layout/qgslayoutitem.cpp
Expand Up @@ -649,28 +649,28 @@ 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 ) );

//transparency
// composerItemElem.setAttribute( "transparency", QString::number( mTransparency ) );

// composerItemElem.setAttribute( "excludeFromExports", mExcludeFromExports );
#endif

writeObjectPropertiesToElement( element, document, context );
return true;
Expand All @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/src/core/testqgslayoutitem.cpp
Expand Up @@ -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 );

Expand All @@ -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;
Expand Down

0 comments on commit 616aec1

Please sign in to comment.