Skip to content

Commit

Permalink
Move reading/writing of label style to qgsvectorlayer. Change argumen…
Browse files Browse the repository at this point in the history
…t in readCustomProperties to const. Fixes problem with mixed label settings between qgis server projects

git-svn-id: http://svn.osgeo.org/qgis/trunk@15235 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Feb 21, 2011
1 parent 4919e80 commit 42cca5c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 1 addition & 7 deletions src/core/qgsmaplayer.cpp
Expand Up @@ -626,9 +626,6 @@ QString QgsMapLayer::loadNamedStyle( const QString theURI, bool &theResultFlag )
return myErrorMessage;
}

//also restore custom properties (for labeling-ng)
readCustomProperties( myRoot, "labeling" );

return "";
}

Expand Down Expand Up @@ -668,9 +665,6 @@ QString QgsMapLayer::saveNamedStyle( const QString theURI, bool & theResultFlag
return tr( "Could not save symbology because:\n%1" ).arg( errorMsg );
}

//save customproperties (for labeling ng)
writeCustomProperties( myRootNode, myDocument );

// check if the uri is a file or ends with .qml,
// which indicates that it should become one
// everything else goes to the database
Expand Down Expand Up @@ -827,7 +821,7 @@ void QgsMapLayer::removeCustomProperty( const QString& key )
mCustomProperties.remove( key );
}

void QgsMapLayer::readCustomProperties( QDomNode & layerNode, const QString& keyStartsWith )
void QgsMapLayer::readCustomProperties( const QDomNode& layerNode, const QString& keyStartsWith )
{
QDomNode propsNode = layerNode.namedItem( "customproperties" );
if ( propsNode.isNull() ) // no properties stored...
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsmaplayer.h
Expand Up @@ -384,7 +384,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
/** Read custom properties from project file. Added in v1.4
@param layerNode note to read from
@param keyStartsWith reads only properties starting with the specified string (or all if the string is empty)*/
void readCustomProperties( QDomNode & layerNode, const QString& keyStartsWith = "" );
void readCustomProperties( const QDomNode& layerNode, const QString& keyStartsWith = "" );

/** Write custom properties to project file. Added in v1.4 */
void writeCustomProperties( QDomNode & layerNode, QDomDocument & doc ) const;
Expand Down
6 changes: 6 additions & 0 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -2914,6 +2914,9 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
mLabel->setMinScale( e.attribute( "minLabelScale", "1" ).toFloat() );
mLabel->setMaxScale( e.attribute( "maxLabelScale", "100000000" ).toFloat() );

//also restore custom properties (for labeling-ng)
readCustomProperties( node, "labeling" );

// Test if labeling is on or off
QDomNode labelnode = node.namedItem( "label" );
QDomElement element = labelnode.toElement();
Expand Down Expand Up @@ -3069,6 +3072,9 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
}
}

//save customproperties (for labeling ng)
writeCustomProperties( node, doc );

// add the display field
QDomElement dField = doc.createElement( "displayfield" );
QDomText dFieldText = doc.createTextNode( displayField() );
Expand Down

0 comments on commit 42cca5c

Please sign in to comment.