Skip to content

Commit 616aec1

Browse files
committedOct 6, 2017
Save/restore a few more layout item properties
1 parent 80e0e07 commit 616aec1

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed
 

‎src/core/layout/qgslayoutitem.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -649,28 +649,28 @@ bool QgsLayoutItem::writePropertiesToElement( QDomElement &element, QDomDocument
649649
element.setAttribute( QStringLiteral( "size" ), mItemSize.encodeSize() );
650650
element.setAttribute( QStringLiteral( "rotation" ), QString::number( rotation() ) );
651651

652-
//TODO
653-
/*
654-
composerItemElem.setAttribute( "zValue", QString::number( zValue() ) );
655-
composerItemElem.setAttribute( "visibility", isVisible() );
652+
element.setAttribute( "zValue", QString::number( zValue() ) );
653+
element.setAttribute( "visibility", isVisible() );
656654
//position lock for mouse moves/resizes
657-
if ( mItemPositionLocked )
655+
if ( mIsLocked )
658656
{
659-
composerItemElem.setAttribute( "positionLock", "true" );
657+
element.setAttribute( "positionLock", "true" );
660658
}
661659
else
662660
{
663-
composerItemElem.setAttribute( "positionLock", "false" );
661+
element.setAttribute( "positionLock", "false" );
664662
}
665-
*/
666663

664+
//TODO
665+
#if 0
667666
//blend mode
668667
// composerItemElem.setAttribute( "blendMode", QgsMapRenderer::getBlendModeEnum( mBlendMode ) );
669668

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

673672
// composerItemElem.setAttribute( "excludeFromExports", mExcludeFromExports );
673+
#endif
674674

675675
writeObjectPropertiesToElement( element, document, context );
676676
return true;
@@ -691,26 +691,30 @@ bool QgsLayoutItem::readPropertiesFromElement( const QDomElement &element, const
691691
/*
692692
// temporary for groups imported from templates
693693
mTemplateUuid = itemElem.attribute( "templateUuid" );
694+
*/
695+
694696
//position lock for mouse moves/resizes
695-
QString positionLock = itemElem.attribute( "positionLock" );
697+
QString positionLock = element.attribute( "positionLock" );
696698
if ( positionLock.compare( "true", Qt::CaseInsensitive ) == 0 )
697699
{
698-
setPositionLock( true );
700+
setLocked( true );
699701
}
700702
else
701703
{
702-
setPositionLock( false );
704+
setLocked( false );
703705
}
704706
//visibility
705-
setVisibility( itemElem.attribute( "visibility", "1" ) != "0" );
706-
setZValue( itemElem.attribute( "zValue" ).toDouble() );
707+
setVisible( element.attribute( "visibility", "1" ) != "0" );
708+
setZValue( element.attribute( "zValue" ).toDouble() );
709+
#if 0 //TODO
707710
//blend mode
708-
setBlendMode( QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) itemElem.attribute( "blendMode", "0" ).toUInt() ) );
711+
setBlendMode( QgsMapRenderer::getCompositionMode( ( QgsMapRenderer::BlendMode ) itemElem.attribute( "blendMode", "0" ).toUInt() ) );
709712
//transparency
710713
setTransparency( itemElem.attribute( "transparency", "0" ).toInt() );
711714
mExcludeFromExports = itemElem.attribute( "excludeFromExports", "0" ).toInt();
712715
mEvaluatedExcludeFromExports = mExcludeFromExports;
713-
*/
716+
#endif
717+
714718
return true;
715719
}
716720

‎tests/src/core/testqgslayoutitem.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,9 @@ void TestQgsLayoutItem::writeReadXmlProperties()
13211321
original->attemptMove( QgsLayoutPoint( 0.05, 0.09, QgsUnitTypes::LayoutMeters ) );
13221322
original->setItemRotation( 45.0 );
13231323
original->setId( QStringLiteral( "test" ) );
1324+
original->setLocked( true );
1325+
original->setZValue( 55 );
1326+
original->setVisible( false );
13241327

13251328
QgsLayoutItem *copy = createCopyViaXml( &l, original );
13261329

@@ -1334,6 +1337,9 @@ void TestQgsLayoutItem::writeReadXmlProperties()
13341337
QCOMPARE( copy->sizeWithUnits(), original->sizeWithUnits() );
13351338
QCOMPARE( copy->positionWithUnits(), original->positionWithUnits() );
13361339
QCOMPARE( copy->itemRotation(), original->itemRotation() );
1340+
QVERIFY( copy->isLocked() );
1341+
QCOMPARE( copy->zValue(), 55.0 );
1342+
QVERIFY( !copy->isVisible() );
13371343

13381344
delete copy;
13391345
delete original;

0 commit comments

Comments
 (0)
Please sign in to comment.