Skip to content

Commit 270fe71

Browse files
author
jef
committed
new fix for #1162 restoring lost qml features
git-svn-id: http://svn.osgeo.org/qgis/trunk@9747 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e7f90b4 commit 270fe71

34 files changed

+552
-523
lines changed

python/core/qgsmaplayer.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public:
142142

143143
@returns true if successful
144144
*/
145-
bool writeXML(QDomNode & layer_node, QDomDocument & document);
145+
bool writeXML(QDomNode & layer_node, QDomDocument & document) const;
146146

147147
/** Read the symbology for the current layer from the Dom node supplied.
148148
* @param QDomNode node that will contain the symbology definition for this layer.

python/core/qgsrasterlayer.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ public:
489489
bool readXml( QDomNode & layer_node );
490490

491491
/** \brief Write the symbology for the layer into the docment provided */
492-
bool writeSymbology( QDomNode&, QDomDocument& doc, QString& errorMessage ) const;
492+
bool writeSymbology( QDomNode&, QDomDocument& doc, QString& errorMessage );
493493

494494
/** \brief Write layer specific state to project file Dom node */
495495
bool writeXml( QDomNode & layer_node, QDomDocument & doc );

python/core/qgssymbol.sip

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ class QgsSymbol
7070

7171
/**Writes the contents of the symbol to a configuration file
7272
@ return true in case of success*/
73-
virtual bool writeXML( QDomNode & item, QDomDocument & document ) const;
73+
virtual bool writeXML( QDomNode & item, QDomDocument & document, const QgsVectorLayer *vl ) const;
7474
/**Reads the contents of the symbol from a configuration file
7575
@ return true in case of success*/
76-
virtual bool readXML( QDomNode & symbol );
76+
virtual bool readXML( QDomNode & symbol, const QgsVectorLayer *vl );
7777
/**Returns if this symbol is point/ line or polygon*/
7878
QGis::GeometryType type() const;
7979

python/core/qgsvectorlayer.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public:
127127
* @param errorMessage reference to string that will be updated with any error messages
128128
* @return true in case of success.
129129
*/
130-
bool writeSymbology(QDomNode&, QDomDocument& doc, QString& errorMessage) const;
130+
bool writeSymbology(QDomNode&, QDomDocument& doc, QString& errorMessage);
131131

132132
/**
133133
* Number of features in the layer. This is necessary if features are

src/core/composer/qgscomposeritem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ bool QgsComposerItem::readSettings( void ) { return true; }
9292

9393
bool QgsComposerItem::removeSettings( void ) { return true; }
9494

95-
bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc )
95+
bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) const
9696
{
9797
if ( itemElem.isNull() )
9898
{

src/core/composer/qgscomposeritem.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ class CORE_EXPORT QgsComposerItem: public QGraphicsRectItem
8989
* @param node is Dom node corresponding to 'Composer' tag
9090
* @param temp write template file
9191
*/
92-
virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) = 0;
92+
virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const = 0;
9393

9494
/**Writes parameter that are not subclass specific in document. Usually called from writeXML methods of subclasses*/
95-
bool _writeXML( QDomElement& itemElem, QDomDocument& doc );
95+
bool _writeXML( QDomElement& itemElem, QDomDocument& doc ) const;
9696

9797
/** sets state from Dom document
9898
* @param itemElem is Dom node corresponding to item tag

src/core/composer/qgscomposeritemgroup.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void QgsComposerItemGroup::drawFrame( QPainter* p )
164164
}
165165
}
166166

167-
bool QgsComposerItemGroup::writeXML( QDomElement& elem, QDomDocument & doc )
167+
bool QgsComposerItemGroup::writeXML( QDomElement& elem, QDomDocument & doc ) const
168168
{
169169
return true; //soon...
170170
}

src/core/composer/qgscomposeritemgroup.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class CORE_EXPORT QgsComposerItemGroup: public QObject, public QgsComposerItem
4545
* @param elem is Dom element corresponding to 'Composer' tag
4646
* @param temp write template file
4747
*/
48-
bool writeXML( QDomElement& elem, QDomDocument & doc );
48+
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
4949

5050
/** sets state from Dom document
5151
* @param itemElem is Dom node corresponding to item tag

src/core/composer/qgscomposerlabel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ QFont QgsComposerLabel::font() const
8080
return mFont;
8181
}
8282

83-
bool QgsComposerLabel::writeXML( QDomElement& elem, QDomDocument & doc )
83+
bool QgsComposerLabel::writeXML( QDomElement& elem, QDomDocument & doc ) const
8484
{
8585
if ( elem.isNull() )
8686
{

src/core/composer/qgscomposerlabel.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class CORE_EXPORT QgsComposerLabel: public QgsComposerItem
4545
* @param node is Dom node corresponding to 'Composer' tag
4646
* @param temp write template file
4747
*/
48-
bool writeXML( QDomElement& elem, QDomDocument & doc );
48+
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
4949

5050
/** sets state from Dom document
5151
* @param node is Dom node corresponding to 'ComposerLabel' tag

src/core/composer/qgscomposerlegend.cpp

+35-35
Original file line numberDiff line numberDiff line change
@@ -95,38 +95,38 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
9595
//draw only visible layer items
9696
QgsMapRenderer* theMapRenderer = mComposition->mapRenderer();
9797
QStringList visibleLayerIds;
98-
if(theMapRenderer)
99-
{
100-
visibleLayerIds = theMapRenderer->layerSet();
101-
}
102-
98+
if ( theMapRenderer )
99+
{
100+
visibleLayerIds = theMapRenderer->layerSet();
101+
}
102+
103103

104104
for ( int i = 0; i < numLayerItems; ++i )
105105
{
106106
currentLayerItem = rootItem->child( i );
107107
if ( currentLayerItem )
108108
{
109109
QString currentLayerId = currentLayerItem->data().toString();
110-
if(visibleLayerIds.contains(currentLayerId))
111-
{
112-
//Let the user omit the layer title item by having an empty layer title string
113-
if(!currentLayerItem->text().isEmpty())
114-
{
115-
currentYCoordinate += mLayerSpace;
116-
currentYCoordinate += fontAscentMillimeters( mLayerFont );
117-
118-
//draw layer Item
119-
if ( painter )
120-
{
121-
drawText( painter, mBoxSpace, currentYCoordinate, currentLayerItem->text(), mLayerFont );
122-
}
123-
}
124-
125-
maxXCoord = std::max( maxXCoord, 2 * mBoxSpace + textWidthMillimeters( mLayerFont, currentLayerItem->text() ) );
126-
127-
//and child items
128-
drawLayerChildItems( painter, currentLayerItem, currentYCoordinate, maxXCoord );
129-
}
110+
if ( visibleLayerIds.contains( currentLayerId ) )
111+
{
112+
//Let the user omit the layer title item by having an empty layer title string
113+
if ( !currentLayerItem->text().isEmpty() )
114+
{
115+
currentYCoordinate += mLayerSpace;
116+
currentYCoordinate += fontAscentMillimeters( mLayerFont );
117+
118+
//draw layer Item
119+
if ( painter )
120+
{
121+
drawText( painter, mBoxSpace, currentYCoordinate, currentLayerItem->text(), mLayerFont );
122+
}
123+
}
124+
125+
maxXCoord = std::max( maxXCoord, 2 * mBoxSpace + textWidthMillimeters( mLayerFont, currentLayerItem->text() ) );
126+
127+
//and child items
128+
drawLayerChildItems( painter, currentLayerItem, currentYCoordinate, maxXCoord );
129+
}
130130
}
131131
}
132132

@@ -148,15 +148,15 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
148148
size.setWidth( maxXCoord );
149149

150150
//adjust box if width or height is to small
151-
if(painter && currentYCoordinate > rect().width())
152-
{
153-
setSceneRect( QRectF( transform().dx(), transform().dy(), rect().width(), currentYCoordinate));
154-
}
155-
if(painter && maxXCoord > rect().height())
156-
{
157-
setSceneRect( QRectF( transform().dx(), transform().dy(), maxXCoord, rect().height()));
158-
}
159-
151+
if ( painter && currentYCoordinate > rect().width() )
152+
{
153+
setSceneRect( QRectF( transform().dx(), transform().dy(), rect().width(), currentYCoordinate ) );
154+
}
155+
if ( painter && maxXCoord > rect().height() )
156+
{
157+
setSceneRect( QRectF( transform().dx(), transform().dy(), maxXCoord, rect().height() ) );
158+
}
159+
160160
return size;
161161
}
162162

@@ -402,7 +402,7 @@ void QgsComposerLegend::updateLegend()
402402
update();
403403
}
404404

405-
bool QgsComposerLegend::writeXML( QDomElement& elem, QDomDocument & doc )
405+
bool QgsComposerLegend::writeXML( QDomElement& elem, QDomDocument & doc ) const
406406
{
407407
if ( elem.isNull() )
408408
{

src/core/composer/qgscomposerlegend.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class CORE_EXPORT QgsComposerLegend: public QObject, public QgsComposerItem
8585
* @param elem is Dom element corresponding to 'Composer' tag
8686
* @param temp write template file
8787
*/
88-
bool writeXML( QDomElement& elem, QDomDocument & doc );
88+
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
8989

9090
/** sets state from Dom document
9191
* @param itemElem is Dom node corresponding to item tag

src/core/composer/qgscomposermap.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ void QgsComposerMap::connectUpdateSlot()
466466
}
467467
}
468468

469-
bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc )
469+
bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const
470470
{
471471
if ( elem.isNull() )
472472
{
@@ -497,8 +497,11 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc )
497497
extentElem.setAttribute( "ymax", QString::number( mExtent.yMaximum() ) );
498498
composerMapElem.appendChild( extentElem );
499499

500+
#if 0
501+
// why is saving the map changing anything about the cache?
500502
mCacheUpdated = false;
501503
mNumCachedLayers = 0;
504+
#endif
502505

503506
elem.appendChild( composerMapElem );
504507
return _writeXML( composerMapElem, doc );

src/core/composer/qgscomposermap.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class CORE_EXPORT QgsComposerMap : /*public QWidget, private Ui::QgsComposerMapB
125125
* @param elem is Dom element corresponding to 'Composer' tag
126126
* @param temp write template file
127127
*/
128-
bool writeXML( QDomElement& elem, QDomDocument & doc );
128+
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
129129

130130
/** sets state from Dom document
131131
* @param itemElem is Dom node corresponding to 'ComposerMap' tag

src/core/composer/qgscomposerpicture.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ void QgsComposerPicture::setPictureFile( const QString& path )
137137
}
138138
}
139139

140-
if(mMode != Unknown) //make sure we start with a new QImage
141-
{
142-
setSceneRect(QRectF(transform().dx(), transform().dy(), rect().width(), rect().height()));
143-
}
140+
if ( mMode != Unknown ) //make sure we start with a new QImage
141+
{
142+
setSceneRect( QRectF( transform().dx(), transform().dy(), rect().width(), rect().height() ) );
143+
}
144144
emit settingsChanged();
145145
}
146146

@@ -202,7 +202,7 @@ QString QgsComposerPicture::pictureFile() const
202202
return mSourceFile.fileName();
203203
}
204204

205-
bool QgsComposerPicture::writeXML( QDomElement& elem, QDomDocument & doc )
205+
bool QgsComposerPicture::writeXML( QDomElement& elem, QDomDocument & doc ) const
206206
{
207207
if ( elem.isNull() )
208208
{

src/core/composer/qgscomposerpicture.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class CORE_EXPORT QgsComposerPicture: public QObject, public QgsComposerItem
5151
* @param node is Dom node corresponding to 'Composer' tag
5252
* @param temp write template file
5353
*/
54-
bool writeXML( QDomElement& elem, QDomDocument & doc );
54+
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
5555

5656
/** sets state from Dom document
5757
* @param itemElem is Dom node corresponding to item tag

src/core/composer/qgscomposerscalebar.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void QgsComposerScaleBar::setFont( const QFont& font )
264264
update();
265265
}
266266

267-
bool QgsComposerScaleBar::writeXML( QDomElement& elem, QDomDocument & doc )
267+
bool QgsComposerScaleBar::writeXML( QDomElement& elem, QDomDocument & doc ) const
268268
{
269269
if ( elem.isNull() )
270270
{

src/core/composer/qgscomposerscalebar.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class CORE_EXPORT QgsComposerScaleBar: public QObject, public QgsComposerItem
106106
* @param elem is Dom element corresponding to 'Composer' tag
107107
* @param temp write template file
108108
*/
109-
bool writeXML( QDomElement& elem, QDomDocument & doc );
109+
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
110110

111111
/** sets state from Dom document
112112
* @param itemElem is Dom node corresponding to item tag

src/core/composer/qgslegendmodel.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ QStandardItem* QgsLegendModel::itemFromSymbol( QgsSymbol* s )
479479
return currentSymbolItem;
480480
}
481481

482-
bool QgsLegendModel::writeXML( QDomElement& composerLegendElem, QDomDocument& doc )
482+
bool QgsLegendModel::writeXML( QDomElement& composerLegendElem, QDomDocument& doc ) const
483483
{
484484
if ( composerLegendElem.isNull() )
485485
{
@@ -518,7 +518,7 @@ bool QgsLegendModel::writeXML( QDomElement& composerLegendElem, QDomDocument& do
518518
{
519519
QDomElement vectorClassElem = doc.createElement( "VectorClassificationItem" );
520520
vectorClassElem.setAttribute( "text", currentClassificationItem->text() );
521-
symbol->writeXML( vectorClassElem, doc );
521+
symbol->writeXML( vectorClassElem, doc, 0 );
522522
newLayerItem.appendChild( vectorClassElem );
523523
continue;
524524
}
@@ -601,7 +601,7 @@ bool QgsLegendModel::readXML( const QDomElement& legendModelElem, const QDomDocu
601601
{
602602
QgsSymbol* symbol = new QgsSymbol( vectorLayer->geometryType() );
603603
QDomNode symbolNode = symbolNodeList.at( 0 );
604-
symbol->readXML( symbolNode );
604+
symbol->readXML( symbolNode, vectorLayer );
605605
childItem->setData( QVariant::fromValue(( void* )symbol ) );
606606

607607
//add icon

src/core/composer/qgslegendmodel.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class CORE_EXPORT QgsLegendModel: public QStandardItemModel
4949
void updateVectorClassificationItem( QStandardItem* classificationItem, QgsSymbol* symbol, QString itemText );
5050
void updateRasterClassificationItem( QStandardItem* classificationItem );
5151

52-
bool writeXML( QDomElement& composerLegendElem, QDomDocument& doc );
52+
bool writeXML( QDomElement& composerLegendElem, QDomDocument& doc ) const;
5353
bool readXML( const QDomElement& legendModelElem, const QDomDocument& doc );
5454

5555
public slots:

src/core/qgsattributeaction.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ bool QgsAttributeAction::writeXML( QDomNode& layer_node, QDomDocument& doc ) con
135135
return true;
136136
}
137137

138-
bool QgsAttributeAction::readXML( QDomNode& layer_node )
138+
bool QgsAttributeAction::readXML( const QDomNode& layer_node )
139139
{
140+
mActions.clear();
141+
140142
QDomNode aaNode = layer_node.namedItem( "attributeactions" );
141143

142144
if ( !aaNode.isNull() )

src/core/qgsattributeaction.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class CORE_EXPORT QgsAttributeAction
121121
bool writeXML( QDomNode& layer_node, QDomDocument& doc ) const;
122122

123123
//! Reads the actions in in XML format
124-
bool readXML( QDomNode& layer_node );
124+
bool readXML( const QDomNode& layer_node );
125125

126126
private:
127127

0 commit comments

Comments
 (0)