|
39 | 39 | #include <iostream>
|
40 | 40 | #include <cmath>
|
41 | 41 |
|
42 |
| -int QgsComposerMap::mCurrentComposerId = 0; |
43 |
| - |
44 | 42 | QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int width, int height )
|
45 | 43 | : QgsComposerItem( x, y, width, height, composition ), mKeepLayerSet( false ), mGridEnabled( false ), mGridStyle( Solid ), \
|
46 | 44 | mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), \
|
47 | 45 | mGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ), mGridAnnotationDirection( Horizontal ), \
|
48 | 46 | mRotation( 0 ), mCrossLength( 3 )
|
49 | 47 | {
|
50 | 48 | mComposition = composition;
|
| 49 | + mId = mComposition->composerMapItems().size(); |
51 | 50 | mMapRenderer = mComposition->mapRenderer();
|
52 |
| - mId = mCurrentComposerId++; |
53 | 51 | mPreviewMode = QgsComposerMap::Rectangle;
|
54 | 52 | mCurrentRectangle = rect();
|
55 | 53 |
|
@@ -87,7 +85,7 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition )
|
87 | 85 |
|
88 | 86 | mComposition = composition;
|
89 | 87 | mMapRenderer = mComposition->mapRenderer();
|
90 |
| - mId = mCurrentComposerId++; |
| 88 | + mId = mComposition->composerMapItems().size(); |
91 | 89 | mPreviewMode = QgsComposerMap::Rectangle;
|
92 | 90 | mCurrentRectangle = rect();
|
93 | 91 |
|
@@ -560,6 +558,7 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const
|
560 | 558 | }
|
561 | 559 |
|
562 | 560 | QDomElement composerMapElem = doc.createElement( "ComposerMap" );
|
| 561 | + composerMapElem.setAttribute( "id", mId ); |
563 | 562 |
|
564 | 563 | //previewMode
|
565 | 564 | if ( mPreviewMode == Cache )
|
@@ -643,6 +642,11 @@ bool QgsComposerMap::readXML( const QDomElement& itemElem, const QDomDocument& d
|
643 | 642 | return false;
|
644 | 643 | }
|
645 | 644 |
|
| 645 | + QString idRead = itemElem.attribute( "id", "not found" ); |
| 646 | + if ( idRead != "not found" ) |
| 647 | + { |
| 648 | + mId = idRead.toInt(); |
| 649 | + } |
646 | 650 | mPreviewMode = Rectangle;
|
647 | 651 |
|
648 | 652 | //previewMode
|
|
0 commit comments