Skip to content

Commit c092e6e

Browse files
author
mhugent
committedMay 29, 2010
Fix for zList sort problem and added call to composer item readXML in composer arrow
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13585 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

2 files changed

+25
-47
lines changed

2 files changed

+25
-47
lines changed
 

‎src/core/composer/qgscomposerarrow.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ bool QgsComposerArrow::writeXML( QDomElement& elem, QDomDocument & doc ) const
302302
composerArrowElem.appendChild( stopPointElem );
303303

304304
elem.appendChild( composerArrowElem );
305-
return true;
305+
return _writeXML( composerArrowElem, doc );
306306
}
307307

308308
bool QgsComposerArrow::readXML( const QDomElement& itemElem, const QDomDocument& doc )
@@ -325,6 +325,15 @@ bool QgsComposerArrow::readXML( const QDomElement& itemElem, const QDomDocument&
325325
mArrowColor = QColor( red, green, blue, alpha );
326326
}
327327

328+
//restore general composer item properties
329+
//needs to be before start point / stop point because setSceneRect()
330+
QDomNodeList composerItemList = itemElem.elementsByTagName( "ComposerItem" );
331+
if ( composerItemList.size() > 0 )
332+
{
333+
QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
334+
_readXML( composerItemElem, doc );
335+
}
336+
328337
//start point
329338
QDomNodeList startPointList = itemElem.elementsByTagName( "StartPoint" );
330339
if ( startPointList.size() > 0 )
@@ -343,15 +352,6 @@ bool QgsComposerArrow::readXML( const QDomElement& itemElem, const QDomDocument&
343352
mStopPoint.setY( stopPointElem.attribute( "y", "0.0" ).toDouble() );
344353
}
345354

346-
347-
//restore general composer item properties
348-
QDomNodeList composerItemList = itemElem.elementsByTagName( "ComposerItem" );
349-
if ( composerItemList.size() > 0 )
350-
{
351-
QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
352-
_readXML( composerItemElem, doc );
353-
}
354-
355355
adaptItemSceneRect();
356356
return true;
357357
}

‎src/core/composer/qgscomposition.cpp

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,11 @@ void QgsComposition::updateZValues()
537537

538538
void QgsComposition::sortZList()
539539
{
540+
if ( mItemZList.size() < 2 )
541+
{
542+
return;
543+
}
544+
540545
#ifdef QGISDEBUG
541546
//debug: list before sorting
542547
QgsDebugMsg( "before sorting" );
@@ -547,51 +552,24 @@ void QgsComposition::sortZList()
547552
}
548553
#endif
549554

550-
QMutableLinkedListIterator<QgsComposerItem*> it( mItemZList );
551-
int previousZ, afterZ; //z values of items before and after
552-
QgsComposerItem* previousItem;
553-
QgsComposerItem* afterItem;
555+
QLinkedList<QgsComposerItem*>::const_iterator lIt = mItemZList.constBegin();
556+
QLinkedList<QgsComposerItem*> sortedList;
554557

555-
while ( it.hasNext() )
558+
for ( ; lIt != mItemZList.constEnd(); ++lIt )
556559
{
557-
previousItem = it.next();
558-
if ( previousItem )
559-
{
560-
previousZ = previousItem->zValue();
561-
}
562-
else
563-
{
564-
previousZ = -1;
565-
}
566-
567-
if ( !it.hasNext() )
560+
QLinkedList<QgsComposerItem*>::iterator insertIt = sortedList.begin();
561+
for ( ; insertIt != sortedList.end(); ++insertIt )
568562
{
569-
break; //this is the end...
570-
}
571-
afterItem = it.peekNext();
572-
573-
if ( afterItem )
574-
{
575-
afterZ = afterItem->zValue();
576-
}
577-
else
578-
{
579-
afterZ = -1;
580-
}
581-
582-
if ( previousZ > afterZ )
583-
{
584-
//swap items
585-
if ( previousItem && afterItem )
563+
if (( *lIt )->zValue() < ( *insertIt )->zValue() )
586564
{
587-
it.remove();
588-
it.next();
589-
it.insert( previousItem );
590-
it.previous();
565+
break;
591566
}
592567
}
568+
sortedList.insert( insertIt, ( *lIt ) );
593569
}
594570

571+
mItemZList = sortedList;
572+
595573
#ifdef QGISDEBUG
596574
//debug: list after sorting
597575
//debug: list before sorting

0 commit comments

Comments
 (0)
Please sign in to comment.