@@ -614,6 +614,9 @@ QString QgsMapLayer::loadNamedStyle( const QString theURI, bool &theResultFlag )
614
614
return myErrorMessage;
615
615
}
616
616
617
+ // also restore custom properties (for labeling-ng)
618
+ readCustomProperties ( myRoot, " labeling" );
619
+
617
620
return " " ;
618
621
}
619
622
@@ -653,6 +656,9 @@ QString QgsMapLayer::saveNamedStyle( const QString theURI, bool & theResultFlag
653
656
return tr ( " Could not save symbology because:\n %1" ).arg ( errorMsg );
654
657
}
655
658
659
+ // save customproperties (for labeling ng)
660
+ writeCustomProperties ( myRootNode, myDocument );
661
+
656
662
// check if the uri is a file or ends with .qml,
657
663
// which indicates that it should become one
658
664
// everything else goes to the database
@@ -804,7 +810,7 @@ void QgsMapLayer::removeCustomProperty( const QString& key )
804
810
mCustomProperties .remove ( key );
805
811
}
806
812
807
- void QgsMapLayer::readCustomProperties ( QDomNode & layerNode )
813
+ void QgsMapLayer::readCustomProperties ( QDomNode & layerNode, const QString& keyStartsWith )
808
814
{
809
815
QDomNode propsNode = layerNode.namedItem ( " customproperties" );
810
816
if ( propsNode.isNull () ) // no properties stored...
@@ -822,17 +828,20 @@ void QgsMapLayer::readCustomProperties( QDomNode & layerNode )
822
828
QDomElement propElement = propNode.toElement ();
823
829
824
830
QString key = propElement.attribute ( " key" );
825
- QString value = propElement.attribute ( " value" );
826
- mCustomProperties [key] = QVariant ( value );
831
+ if ( key.isEmpty () || key.startsWith ( keyStartsWith ) )
832
+ {
833
+ QString value = propElement.attribute ( " value" );
834
+ mCustomProperties [key] = QVariant ( value );
835
+ }
827
836
}
828
837
829
838
}
830
839
831
- void QgsMapLayer::writeCustomProperties ( QDomNode & layerNode, QDomDocument & doc )
840
+ void QgsMapLayer::writeCustomProperties ( QDomNode & layerNode, QDomDocument & doc ) const
832
841
{
833
842
QDomElement propsElement = doc.createElement ( " customproperties" );
834
843
835
- for ( QMap<QString, QVariant>::const_iterator it = mCustomProperties .begin (); it != mCustomProperties .end (); ++it )
844
+ for ( QMap<QString, QVariant>::const_iterator it = mCustomProperties .constBegin (); it != mCustomProperties .constEnd (); ++it )
836
845
{
837
846
QDomElement propElement = doc.createElement ( " property" );
838
847
propElement.setAttribute ( " key" , it.key () );
0 commit comments