Fix for zList sort problem and added call to composer item readXML in composer arrow

git-svn-id: http://svn.osgeo.org/qgis/trunk@13585 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2010-05-29 08:08:39 +00:00
parent ce769ad090
commit 98f68b04e3
2 changed files with 25 additions and 47 deletions

View File

@ -302,7 +302,7 @@ bool QgsComposerArrow::writeXML( QDomElement& elem, QDomDocument & doc ) const
composerArrowElem.appendChild( stopPointElem );
elem.appendChild( composerArrowElem );
return true;
return _writeXML( composerArrowElem, doc );
}
bool QgsComposerArrow::readXML( const QDomElement& itemElem, const QDomDocument& doc )
@ -325,6 +325,15 @@ bool QgsComposerArrow::readXML( const QDomElement& itemElem, const QDomDocument&
mArrowColor = QColor( red, green, blue, alpha );
}
//restore general composer item properties
//needs to be before start point / stop point because setSceneRect()
QDomNodeList composerItemList = itemElem.elementsByTagName( "ComposerItem" );
if ( composerItemList.size() > 0 )
{
QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
_readXML( composerItemElem, doc );
}
//start point
QDomNodeList startPointList = itemElem.elementsByTagName( "StartPoint" );
if ( startPointList.size() > 0 )
@ -343,15 +352,6 @@ bool QgsComposerArrow::readXML( const QDomElement& itemElem, const QDomDocument&
mStopPoint.setY( stopPointElem.attribute( "y", "0.0" ).toDouble() );
}
//restore general composer item properties
QDomNodeList composerItemList = itemElem.elementsByTagName( "ComposerItem" );
if ( composerItemList.size() > 0 )
{
QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
_readXML( composerItemElem, doc );
}
adaptItemSceneRect();
return true;
}

View File

@ -537,6 +537,11 @@ void QgsComposition::updateZValues()
void QgsComposition::sortZList()
{
if ( mItemZList.size() < 2 )
{
return;
}
#ifdef QGISDEBUG
//debug: list before sorting
QgsDebugMsg( "before sorting" );
@ -547,51 +552,24 @@ void QgsComposition::sortZList()
}
#endif
QMutableLinkedListIterator<QgsComposerItem*> it( mItemZList );
int previousZ, afterZ; //z values of items before and after
QgsComposerItem* previousItem;
QgsComposerItem* afterItem;
QLinkedList<QgsComposerItem*>::const_iterator lIt = mItemZList.constBegin();
QLinkedList<QgsComposerItem*> sortedList;
while ( it.hasNext() )
for ( ; lIt != mItemZList.constEnd(); ++lIt )
{
previousItem = it.next();
if ( previousItem )
QLinkedList<QgsComposerItem*>::iterator insertIt = sortedList.begin();
for ( ; insertIt != sortedList.end(); ++insertIt )
{
previousZ = previousItem->zValue();
}
else
{
previousZ = -1;
}
if ( !it.hasNext() )
{
break; //this is the end...
}
afterItem = it.peekNext();
if ( afterItem )
{
afterZ = afterItem->zValue();
}
else
{
afterZ = -1;
}
if ( previousZ > afterZ )
{
//swap items
if ( previousItem && afterItem )
if (( *lIt )->zValue() < ( *insertIt )->zValue() )
{
it.remove();
it.next();
it.insert( previousItem );
it.previous();
break;
}
}
sortedList.insert( insertIt, ( *lIt ) );
}
mItemZList = sortedList;
#ifdef QGISDEBUG
//debug: list after sorting
//debug: list before sorting