Skip to content
Permalink
Browse files
Attach layer metadata to QgsMapLayer
  • Loading branch information
nyalldawson committed May 3, 2017
1 parent 269bfe7 commit 3a965e6dbb438d34e5bd6d24428a447b9d2a9d52
Showing with 59 additions and 2 deletions.
  1. +25 −0 python/core/qgsmaplayer.sip
  2. +0 −2 src/core/metadata/qgslayermetadata.h
  3. +6 −0 src/core/qgsmaplayer.cpp
  4. +28 −0 src/core/qgsmaplayer.h
@@ -818,6 +818,23 @@ Return pointer to layer's undo stack
.. seealso:: setAutoRefreshInterval()
%End

virtual const QgsLayerMetadata &metadata() const;
%Docstring
Returns a reference to the layer's metadata store.
.. versionadded:: 3.0
\see setMetadata()
\see metadataChanged()
:rtype: QgsLayerMetadata
%End

virtual void setMetadata( const QgsLayerMetadata &metadata );
%Docstring
Sets the layer's metadata store.
.. versionadded:: 3.0
\see metadata()
\see metadataChanged()
%End

virtual QString htmlMetadata() const;
%Docstring
Obtain a formatted HTML string containing assorted metadata for this layer.
@@ -988,6 +1005,14 @@ Signal emitted when the blend mode is changed, through QgsMapLayer.setBlendMode(
Emitted when the auto refresh interval changes.
.. seealso:: setAutoRefreshInterval()
.. versionadded:: 3.0
%End

void metadataChanged();
%Docstring
Emitted when the layer's metadata is changed.
\see setMetadata()
\see metadata()
.. versionadded:: 3.0
%End

protected:
@@ -80,8 +80,6 @@ class CORE_EXPORT QgsLayerMetadata
QStringList mRights;
QString mEncoding;



};

#endif // QGSLAYERMETADATA_H
@@ -1621,6 +1621,12 @@ void QgsMapLayer::triggerRepaint( bool deferredUpdate )
emit repaintRequested( deferredUpdate );
}

void QgsMapLayer::setMetadata( const QgsLayerMetadata &metadata )
{
mMetadata = metadata;
emit metadataChanged();
}

QString QgsMapLayer::htmlMetadata() const
{
return QString();
@@ -34,6 +34,7 @@
#include "qgscoordinatereferencesystem.h"
#include "qgsrendercontext.h"
#include "qgsmaplayerdependency.h"
#include "metadata/qgslayermetadata.h"

class QgsDataProvider;
class QgsMapLayerLegend;
@@ -56,6 +57,7 @@ class CORE_EXPORT QgsMapLayer : public QObject

Q_PROPERTY( QString name READ name WRITE setName NOTIFY nameChanged )
Q_PROPERTY( int autoRefreshInterval READ autoRefreshInterval WRITE setAutoRefreshInterval NOTIFY autoRefreshIntervalChanged )
Q_PROPERTY( QgsLayerMetadata metadata READ metadata WRITE setMetadata NOTIFY metadataChanged )

#ifdef SIP_RUN
SIP_CONVERT_TO_SUBCLASS_CODE
@@ -732,6 +734,22 @@ class CORE_EXPORT QgsMapLayer : public QObject
*/
void setAutoRefreshEnabled( bool enabled );

/**
* Returns a reference to the layer's metadata store.
* \since QGIS 3.0
* \see setMetadata()
* \see metadataChanged()
*/
virtual const QgsLayerMetadata &metadata() const { return mMetadata; }

/**
* Sets the layer's \a metadata store.
* \since QGIS 3.0
* \see metadata()
* \see metadataChanged()
*/
virtual void setMetadata( const QgsLayerMetadata &metadata );

/**
* Obtain a formatted HTML string containing assorted metadata for this layer.
* \since QGIS 3.0
@@ -879,6 +897,14 @@ class CORE_EXPORT QgsMapLayer : public QObject
*/
void autoRefreshIntervalChanged( int interval );

/**
* Emitted when the layer's metadata is changed.
* \see setMetadata()
* \see metadata()
* \since QGIS 3.0
*/
void metadataChanged();

protected:
//! Set the extent
virtual void setExtent( const QgsRectangle &rect );
@@ -1019,6 +1045,8 @@ class CORE_EXPORT QgsMapLayer : public QObject
//! Timer for triggering automatic refreshes of the layer
QTimer mRefreshTimer;

QgsLayerMetadata mMetadata;

};

Q_DECLARE_METATYPE( QgsMapLayer * )

0 comments on commit 3a965e6

Please sign in to comment.