mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-11 00:04:27 -04:00
Read / write labeling-ng to qml files
git-svn-id: http://svn.osgeo.org/qgis/trunk@14830 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
9d8d09bfd3
commit
1ca1199827
@ -614,6 +614,9 @@ QString QgsMapLayer::loadNamedStyle( const QString theURI, bool &theResultFlag )
|
||||
return myErrorMessage;
|
||||
}
|
||||
|
||||
//also restore custom properties (for labeling-ng)
|
||||
readCustomProperties( myRoot, "labeling" );
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -653,6 +656,9 @@ 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
|
||||
@ -804,7 +810,7 @@ void QgsMapLayer::removeCustomProperty( const QString& key )
|
||||
mCustomProperties.remove( key );
|
||||
}
|
||||
|
||||
void QgsMapLayer::readCustomProperties( QDomNode & layerNode )
|
||||
void QgsMapLayer::readCustomProperties( QDomNode & layerNode, const QString& keyStartsWith )
|
||||
{
|
||||
QDomNode propsNode = layerNode.namedItem( "customproperties" );
|
||||
if ( propsNode.isNull() ) // no properties stored...
|
||||
@ -822,17 +828,20 @@ void QgsMapLayer::readCustomProperties( QDomNode & layerNode )
|
||||
QDomElement propElement = propNode.toElement();
|
||||
|
||||
QString key = propElement.attribute( "key" );
|
||||
QString value = propElement.attribute( "value" );
|
||||
mCustomProperties[key] = QVariant( value );
|
||||
if ( key.isEmpty() || key.startsWith( keyStartsWith ) )
|
||||
{
|
||||
QString value = propElement.attribute( "value" );
|
||||
mCustomProperties[key] = QVariant( value );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QgsMapLayer::writeCustomProperties( QDomNode & layerNode, QDomDocument & doc )
|
||||
void QgsMapLayer::writeCustomProperties( QDomNode & layerNode, QDomDocument & doc ) const
|
||||
{
|
||||
QDomElement propsElement = doc.createElement( "customproperties" );
|
||||
|
||||
for ( QMap<QString, QVariant>::const_iterator it = mCustomProperties.begin(); it != mCustomProperties.end(); ++it )
|
||||
for ( QMap<QString, QVariant>::const_iterator it = mCustomProperties.constBegin(); it != mCustomProperties.constEnd(); ++it )
|
||||
{
|
||||
QDomElement propElement = doc.createElement( "property" );
|
||||
propElement.setAttribute( "key", it.key() );
|
||||
|
@ -373,11 +373,12 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
virtual bool writeXml( QDomNode & layer_node, QDomDocument & document );
|
||||
|
||||
|
||||
/** Read custom properties from project file. Added in v1.4 */
|
||||
void readCustomProperties( QDomNode & layerNode );
|
||||
/** Read custom properties from project file. Added in v1.4
|
||||
@param keyStartsWith reads only properties starting with the specified string (or all if the string is empty)*/
|
||||
void readCustomProperties( QDomNode & layerNode, const QString& keyStartsWith = "" );
|
||||
|
||||
/** Write custom properties to project file. Added in v1.4 */
|
||||
void writeCustomProperties( QDomNode & layerNode, QDomDocument & doc );
|
||||
void writeCustomProperties( QDomNode & layerNode, QDomDocument & doc ) const;
|
||||
|
||||
/** debugging member - invoked when a connect() is made to this object */
|
||||
void connectNotify( const char * signal );
|
||||
|
Loading…
x
Reference in New Issue
Block a user