Skip to content

Commit

Permalink
Optimize annotation manager
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Dec 10, 2020
1 parent 43a1526 commit 825cf3d
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions src/core/annotations/qgsannotationmanager.cpp
Expand Up @@ -93,32 +93,36 @@ bool QgsAnnotationManager::readXml( const QDomElement &element, const QgsReadWri

QDomElement annotationsElem = element.firstChildElement( QStringLiteral( "Annotations" ) );

QDomNodeList annotationNodes = annotationsElem.elementsByTagName( QStringLiteral( "Annotation" ) );
for ( int i = 0; i < annotationNodes.size(); ++i )
QDomElement annotationElement = annotationsElem.firstChildElement( QStringLiteral( "Annotation" ) );
while ( ! annotationElement .isNull() )
{
createAnnotationFromXml( annotationNodes.at( i ).toElement(), context );
createAnnotationFromXml( annotationElement, context );
annotationElement = annotationElement.nextSiblingElement( QStringLiteral( "Annotation" ) );
}

// restore old (pre 3.0) project annotations
QDomNodeList oldItemList = element.elementsByTagName( QStringLiteral( "TextAnnotationItem" ) );
for ( int i = 0; i < oldItemList.size(); ++i )
if ( annotationsElem.isNull() )
{
createAnnotationFromXml( oldItemList.at( i ).toElement(), context );
}
oldItemList = element.elementsByTagName( QStringLiteral( "FormAnnotationItem" ) );
for ( int i = 0; i < oldItemList.size(); ++i )
{
createAnnotationFromXml( oldItemList.at( i ).toElement(), context );
}
oldItemList = element.elementsByTagName( QStringLiteral( "HtmlAnnotationItem" ) );
for ( int i = 0; i < oldItemList.size(); ++i )
{
createAnnotationFromXml( oldItemList.at( i ).toElement(), context );
}
oldItemList = element.elementsByTagName( QStringLiteral( "SVGAnnotationItem" ) );
for ( int i = 0; i < oldItemList.size(); ++i )
{
createAnnotationFromXml( oldItemList.at( i ).toElement(), context );
QDomNodeList oldItemList = element.elementsByTagName( QStringLiteral( "TextAnnotationItem" ) );
for ( int i = 0; i < oldItemList.size(); ++i )
{
createAnnotationFromXml( oldItemList.at( i ).toElement(), context );
}
oldItemList = element.elementsByTagName( QStringLiteral( "FormAnnotationItem" ) );
for ( int i = 0; i < oldItemList.size(); ++i )
{
createAnnotationFromXml( oldItemList.at( i ).toElement(), context );
}
oldItemList = element.elementsByTagName( QStringLiteral( "HtmlAnnotationItem" ) );
for ( int i = 0; i < oldItemList.size(); ++i )
{
createAnnotationFromXml( oldItemList.at( i ).toElement(), context );
}
oldItemList = element.elementsByTagName( QStringLiteral( "SVGAnnotationItem" ) );
for ( int i = 0; i < oldItemList.size(); ++i )
{
createAnnotationFromXml( oldItemList.at( i ).toElement(), context );
}
}

return result;
Expand Down

0 comments on commit 825cf3d

Please sign in to comment.