Skip to content

Commit

Permalink
write/read xml temporal layout map
Browse files Browse the repository at this point in the history
  • Loading branch information
vcloarec authored and nyalldawson committed Apr 16, 2020
1 parent 9377ec4 commit dd9fec7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/3d/qgslayoutitem3dmap.cpp
Expand Up @@ -207,6 +207,16 @@ bool QgsLayoutItem3DMap::writePropertiesToElement( QDomElement &element, QDomDoc
QDomElement elemCameraPose = mCameraPose.writeXml( document );
element.appendChild( elemCameraPose );

//temporal settings
QDomElement elemTemporal = document.createElement( QStringLiteral( "temporal-settings" ) );
elemTemporal.setAttribute( QStringLiteral( "isTemporal" ), isTemporal() ? 0 : 1 );
if ( isTemporal() )
{
elemTemporal.setAttribute( QStringLiteral( "temporalRangeBegin" ), temporalRange().begin().toString( Qt::ISODate ) );
elemTemporal.setAttribute( QStringLiteral( "temporalRangeEnd" ), temporalRange().end().toString( Qt::ISODate ) );
}
element.appendChild( elemTemporal );

return true;
}

Expand All @@ -232,6 +242,16 @@ bool QgsLayoutItem3DMap::readPropertiesFromElement( const QDomElement &element,
if ( !elemCameraPose.isNull() )
mCameraPose.readXml( elemCameraPose );

//temporal settings
QDomElement elemTemporal = element.firstChildElement( QStringLiteral( "temporal-settings" ) );
setIsTemporal( elemTemporal.attribute( QStringLiteral( "isTemporal" ) ).toInt() );
if ( isTemporal() )
{
QDateTime begin = QDateTime::fromString( elemTemporal.attribute( QStringLiteral( "temporalRangeBegin" ) ), Qt::ISODate );
QDateTime end = QDateTime::fromString( elemTemporal.attribute( QStringLiteral( "temporalRangeBegin" ) ), Qt::ISODate );
setTemporalRange( QgsDateTimeRange( begin, end ) );
}

return true;
}

Expand Down
17 changes: 17 additions & 0 deletions src/core/layout/qgslayoutitemmap.cpp
Expand Up @@ -649,6 +649,14 @@ bool QgsLayoutItemMap::writePropertiesToElement( QDomElement &mapElem, QDomDocum
}
mapElem.appendChild( labelBlockingItemsElem );

//temporal settings
mapElem.setAttribute( QStringLiteral( "isTemporal" ), isTemporal() ? 0 : 1 );
if ( isTemporal() )
{
mapElem.setAttribute( QStringLiteral( "temporalRangeBegin" ), temporalRange().begin().toString( Qt::ISODate ) );
mapElem.setAttribute( QStringLiteral( "temporalRangeEnd" ), temporalRange().end().toString( Qt::ISODate ) );
}

return true;
}

Expand Down Expand Up @@ -805,6 +813,15 @@ bool QgsLayoutItemMap::readPropertiesFromElement( const QDomElement &itemElem, c

updateBoundingRect();

//temporal settings
setIsTemporal( itemElem.attribute( QStringLiteral( "isTemporal" ) ).toInt() );
if ( isTemporal() )
{
QDateTime begin = QDateTime::fromString( itemElem.attribute( QStringLiteral( "temporalRangeBegin" ) ), Qt::ISODate );
QDateTime end = QDateTime::fromString( itemElem.attribute( QStringLiteral( "temporalRangeBegin" ) ), Qt::ISODate );
setTemporalRange( QgsDateTimeRange( begin, end ) );
}

mUpdatesEnabled = true;
return true;
}
Expand Down

0 comments on commit dd9fec7

Please sign in to comment.