Skip to content
Permalink
Browse files

reading of all the custom properties to e.g. copy them to the offline…

… project
  • Loading branch information
signedav authored and nyalldawson committed Mar 16, 2020
1 parent ac40ed4 commit 81317996be62c94c9b166514f4afa03b2974aac4
@@ -608,6 +608,15 @@ Read a custom property from layer. Properties are stored in a map and saved in p
Set custom properties for layer. Current properties are dropped.

.. versionadded:: 3.0
%End

const QgsObjectCustomProperties &customProperties() const;
%Docstring
Read all custom properties from layer. Properties are stored in a map and saved in project file.

.. seealso:: :py:func:`setCustomProperties`

.. versionadded:: 3.14
%End

void removeCustomProperty( const QString &key );
@@ -1699,6 +1699,11 @@ void QgsMapLayer::setCustomProperties( const QgsObjectCustomProperties &properti
mCustomProperties = properties;
}

const QgsObjectCustomProperties &QgsMapLayer::customProperties() const
{
return mCustomProperties;
}

QVariant QgsMapLayer::customProperty( const QString &value, const QVariant &defaultValue ) const
{
return mCustomProperties.value( value, defaultValue );
@@ -614,6 +614,13 @@ class CORE_EXPORT QgsMapLayer : public QObject
*/
void setCustomProperties( const QgsObjectCustomProperties &properties );

/**
* Read all custom properties from layer. Properties are stored in a map and saved in project file.
* \see setCustomProperties
* \since QGIS 3.14
*/
const QgsObjectCustomProperties &customProperties() const;

/**
* Remove a custom property from layer. Properties are stored in a map and saved in project file.
* \see setCustomProperty()
@@ -848,6 +848,9 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
showWarning( newLayer->commitErrors().join( QStringLiteral( "\n" ) ) );
}

// copy the custom properties from original layer
newLayer->setCustomProperties( layer->customProperties() );

// mark as offline layer
newLayer->setCustomProperty( CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE, true );

0 comments on commit 8131799

Please sign in to comment.
You can’t perform that action at this time.