Skip to content
Permalink
Browse files
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
  • Loading branch information
mhugent committed May 29, 2010
1 parent b86f859 commit c092e6e5ea1bbade89a3c52f400780d1e71e4f5d
Showing with 25 additions and 47 deletions.
  1. +10 −10 src/core/composer/qgscomposerarrow.cpp
  2. +15 −37 src/core/composer/qgscomposition.cpp
@@ -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;
}
@@ -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 )
{
previousZ = previousItem->zValue();
}
else
{
previousZ = -1;
}

if ( !it.hasNext() )
QLinkedList<QgsComposerItem*>::iterator insertIt = sortedList.begin();
for ( ; insertIt != sortedList.end(); ++insertIt )
{
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

0 comments on commit c092e6e

Please sign in to comment.