21 #include "qgis_core.h"
60 #define QGSCLIPBOARD_MAPLAYER_MIME "application/qgis.maplayer"
88 Q_PROPERTY( QString name READ name WRITE setName NOTIFY nameChanged )
89 Q_PROPERTY(
int autoRefreshInterval READ autoRefreshInterval WRITE setAutoRefreshInterval NOTIFY autoRefreshIntervalChanged )
90 Q_PROPERTY(
QgsLayerMetadata metadata READ metadata WRITE setMetadata NOTIFY metadataChanged )
93 Q_PROPERTY(
bool isValid READ isValid NOTIFY isValidChanged )
94 Q_PROPERTY(
double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
98 QgsMapLayer * layer = qobject_cast<QgsMapLayer *>( sipCpp );
104 switch ( layer->type() )
107 sipType = sipType_QgsVectorLayer;
110 sipType = sipType_QgsRasterLayer;
113 sipType = sipType_QgsPluginLayer;
116 sipType = sipType_QgsMeshLayer;
119 sipType = sipType_QgsVectorTileLayer;
122 sipType = sipType_QgsAnnotationLayer;
125 sipType = sipType_QgsPointCloudLayer;
154 Identifiable = 1 << 0,
160 Q_DECLARE_FLAGS( LayerFlags, LayerFlag )
169 LayerConfiguration = 1 << 0,
171 Symbology3D = 1 << 2,
178 AttributeTable = 1 << 9,
180 CustomProperties = 1 << 11,
181 GeometryOptions = 1 << 12,
186 AllStyleCategories = LayerConfiguration | Symbology | Symbology3D | Labeling | Fields | Forms | Actions |
187 MapTips | Diagrams | AttributeTable | Rendering | CustomProperties | GeometryOptions | Relations | Temporal | Legend | Elevation,
189 Q_ENUM( StyleCategory )
190 Q_DECLARE_FLAGS( StyleCategories, StyleCategory )
191 Q_FLAG( StyleCategories )
228 QgsMapLayer::LayerFlags flags()
const;
237 void setFlags( QgsMapLayer::LayerFlags flags );
244 static QString extensionPropertyType(
PropertyType type );
254 void setName(
const QString &name );
260 QString name()
const;
279 void setShortName( const QString &shortName ) { mShortName = shortName; }
286 QString shortName()
const;
293 void setTitle(
const QString &title ) { mTitle = title; }
301 QString
title()
const {
return mTitle; }
309 void setAbstract(
const QString &
abstract ) { mAbstract =
abstract; }
317 QString
abstract()
const {
return mAbstract; }
344 void setDataUrl(
const QString &dataUrl ) { mDataUrl = dataUrl; }
472 void setBlendMode( QPainter::CompositionMode blendMode );
478 QPainter::CompositionMode blendMode()
const;
488 virtual void setOpacity(
double opacity );
498 virtual double opacity()
const;
522 bool isValid()
const;
530 QString publicSource()
const;
537 QString source()
const;
543 virtual QStringList subLayers()
const;
549 virtual void setLayerOrder(
const QStringList &layers );
556 virtual void setSubLayerVisibility(
const QString &name,
bool visible );
559 virtual bool isEditable()
const;
565 virtual bool isSpatial()
const;
576 virtual bool isTemporary()
const;
584 FlagDontResolveLayers = 1 << 0,
585 FlagTrustLayerMetadata = 1 << 1,
587 Q_DECLARE_FLAGS( ReadFlags, ReadFlag )
606 bool readLayerXml(
const QDomElement &layerElement,
QgsReadWriteContext &context, QgsMapLayer::ReadFlags flags = QgsMapLayer::ReadFlags() );
625 bool writeLayerXml( QDomElement &layerElement, QDomDocument &document,
const QgsReadWriteContext &context )
const;
631 virtual void resolveReferences(
QgsProject *project );
638 Q_INVOKABLE QStringList customPropertyKeys()
const;
645 Q_INVOKABLE
void setCustomProperty(
const QString &key,
const QVariant &value );
651 Q_INVOKABLE QVariant customProperty(
const QString &value,
const QVariant &defaultValue = QVariant() )
const;
670 void removeCustomProperty(
const QString &key );
701 static QString formatLayerName(
const QString &name );
710 virtual QString metadataUri()
const;
718 void exportNamedMetadata( QDomDocument &doc, QString &errorMsg )
const;
729 virtual QString saveDefaultMetadata(
bool &resultFlag
SIP_OUT );
745 QString saveNamedMetadata(
const QString &uri,
bool &resultFlag );
761 virtual QString loadNamedMetadata(
const QString &uri,
bool &resultFlag
SIP_OUT );
772 virtual QString loadDefaultMetadata(
bool &resultFlag );
782 bool loadNamedMetadataFromDatabase(
const QString &db,
const QString &uri, QString &qmd );
791 bool importNamedMetadata( QDomDocument &document, QString &errorMessage );
800 virtual QString styleURI()
const;
811 virtual QString loadDefaultStyle(
bool &resultFlag
SIP_OUT );
837 virtual bool loadNamedStyleFromDatabase(
const QString &db,
const QString &uri, QString &qml
SIP_OUT );
848 virtual bool importNamedStyle( QDomDocument &doc, QString &errorMsg
SIP_OUT,
869 virtual void exportSldStyle( QDomDocument &doc, QString &errorMsg )
const;
880 virtual QString saveDefaultStyle(
bool &resultFlag
SIP_OUT );
897 virtual QString saveNamedStyle(
const QString &uri,
bool &resultFlag
SIP_OUT, StyleCategories categories = AllStyleCategories );
907 virtual QString saveSldStyle(
const QString &uri,
bool &resultFlag )
const;
917 virtual QString loadSldStyle(
const QString &uri,
bool &resultFlag );
919 virtual bool readSld(
const QDomNode &node, QString &errorMessage )
920 { Q_UNUSED( node ) errorMessage = QStringLiteral(
"Layer type %1 not supported" ).arg(
static_cast<int>( type() ) );
return false; }
945 virtual bool readStyle(
const QDomNode &node, QString &errorMessage,
959 StyleCategories categories = AllStyleCategories )
const = 0;
973 virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context,
974 StyleCategories categories = AllStyleCategories )
const;
992 virtual void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options,
bool loadDefaultStyleFlag =
false );
997 QString providerType()
const;
1000 QUndoStack *undoStack();
1006 QUndoStack *undoStackStyles();
1068 bool isInScaleRange(
double scale )
const;
1080 double minimumScale()
const;
1092 double maximumScale()
const;
1102 bool hasScaleBasedVisibility()
const;
1110 bool hasAutoRefreshEnabled()
const;
1119 int autoRefreshInterval()
const;
1132 void setAutoRefreshInterval(
int interval );
1140 void setAutoRefreshEnabled(
bool enabled );
1162 virtual QString htmlMetadata()
const;
1165 virtual QDateTime timestamp()
const;
1174 virtual QSet<QgsMapLayerDependency> dependencies()
const;
1198 QString originalXmlProperties()
const;
1207 void setOriginalXmlProperties(
const QString &originalXmlProperties );
1213 static QString generateId(
const QString &layerName );
1251 void setMinimumScale(
double scale );
1262 void setMaximumScale(
double scale );
1271 void setScaleBasedVisibility(
bool enabled );
1281 void triggerRepaint(
bool deferredUpdate =
false );
1289 void trigger3DUpdate();
1295 void emitStyleChanged();
1305 virtual bool setDependencies(
const QSet<QgsMapLayerDependency> &layers );
1312 void setRefreshOnNotifyEnabled(
bool enabled );
1331 SIP_PYOBJECT __repr__();
1333 QString str = QStringLiteral(
"<QgsMapLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider() ? sipCpp->dataProvider()->name() : QStringLiteral(
"Invalid" ) );
1334 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
1504 void onNotified(
const QString &message );
1519 void setValid(
bool valid );
1531 virtual bool writeXml( QDomNode &layer_node, QDomDocument &document,
const QgsReadWriteContext &context )
const;
1544 virtual QString encodedSource(
const QString &source,
const QgsReadWriteContext &context )
const;
1558 virtual QString decodedSource(
const QString &source,
const QString &dataProvider,
const QgsReadWriteContext &context )
const;
1565 void readCustomProperties(
const QDomNode &layerNode,
const QString &keyStartsWith = QString() );
1568 void writeCustomProperties( QDomNode &layerNode, QDomDocument &doc )
const;
1571 void readStyleManager(
const QDomNode &layerNode );
1573 void writeStyleManager( QDomNode &layerNode, QDomDocument &doc )
const;
1579 void writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
1581 StyleCategories categories = AllStyleCategories )
const;
1587 void readCommonStyle(
const QDomElement &layerElement,
const QgsReadWriteContext &context,
1588 StyleCategories categories = AllStyleCategories );
1591 void setProviderType(
const QString &providerType );
1596 void connectNotify(
const char *signal )
override;
1609 bool mValid =
false;
1654 bool mIsRefreshOnNofifyEnabled =
false;
1663 QgsMapLayer::ReadFlags mReadFlags = QgsMapLayer::ReadFlags();
1670 bool mShouldValidateCrs =
true;
1677 double mLayerOpacity = 1.0;
1683 bool &resultFlag, StyleCategories categories = AllStyleCategories );
1685 bool &resultFlag, StyleCategories categories = AllStyleCategories );
1686 bool loadNamedPropertyFromDatabase(
const QString &db,
const QString &uri, QString &xml,
QgsMapLayer::PropertyType type );
1692 virtual bool isReadOnly()
const;
1706 LayerFlags mFlags = LayerFlags( Identifiable | Removable | Searchable );
1709 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1717 double mMinScale = 0;
1719 double mMaxScale = 100000000;
1721 bool mScaleBasedVisibility =
false;
1724 QUndoStack *mUndoStack =
nullptr;
1726 QUndoStack *mUndoStackStyles =
nullptr;
1738 QTimer *mRefreshTimer =
nullptr;
1750 QString mOriginalXmlProperties;
1753 bool mRepaintRequestedFired =
false;
Base class for all renderers that may to participate in 3D view.
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Abstract base class for spatial data provider implementations.
QgsErrorMessage represents single error message.
QgsError is container for error messages (report).
Base class for storage of map layer elevation properties.
The QgsMapLayerLegend class is abstract interface for implementations of legends for one map layer.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Management of styles for use with one map layer.
Base class for storage of map layer temporal properties.
Base class for all map layer types.
virtual bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const =0
Write the style for the layer into the docment provided.
QString legendUrlFormat() const
Returns the format for a URL based layer legend.
void dependenciesChanged()
Emitted when dependencies are changed.
void setError(const QgsError &error)
Sets error message.
void legendChanged()
Signal emitted when legend of the layer has changed.
void setAbstract(const QString &abstract)
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
void recalculateExtents() const
This is used to send a request that any mapcanvas using this layer update its extents.
void metadataChanged()
Emitted when the layer's metadata is changed.
void setLegendUrl(const QString &legendUrl)
Sets the URL for the layer's legend.
void request3DUpdate()
Signal emitted when a layer requires an update in any 3D maps.
void configChanged()
Emitted whenever the configuration is changed.
void autoRefreshIntervalChanged(int interval)
Emitted when the auto refresh interval changes.
Q_DECL_DEPRECATED bool hasDependencyCycle(const QSet< QgsMapLayerDependency > &) const
Checks whether a new set of dependencies will introduce a cycle this method is now deprecated and alw...
void isValidChanged()
Emitted when the validity of this layer changed.
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
QString mRefreshOnNofifyMessage
QString mLegendUrl
WMS legend.
QgsRectangle mExtent
Extent of the layer.
QString mLayerName
Name of the layer - used for display.
void setAttributionUrl(const QString &attribUrl)
Sets the attribution URL of the layer used by QGIS Server in GetCapabilities request.
void renderer3DChanged()
Signal emitted when 3D renderer associated with the layer has changed.
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
void statusChanged(const QString &status)
Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar)
void setDataUrl(const QString &dataUrl)
Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
QgsMapLayer(QgsMapLayer const &)=delete
QgsMapLayer cannot be copied.
void setKeywordList(const QString &keywords)
Sets the keyword list of the layer used by QGIS Server in GetCapabilities request.
void setAttribution(const QString &attrib)
Sets the attribution of the layer used by QGIS Server in GetCapabilities request.
bool isRefreshOnNotifyEnabled() const
Returns true if the refresh on provider nofification is enabled.
QSet< QgsMapLayerDependency > mDependencies
List of layers that may modify this layer on modification.
void setDataUrlFormat(const QString &dataUrlFormat)
Sets the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext)=0
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
QString mProviderKey
Data provider key (name of the data provider)
void styleChanged()
Signal emitted whenever a change affects the layer's style.
void rendererChanged()
Signal emitted when renderer is changed.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
void crsChanged()
Emit a signal that layer's CRS has been reset.
void dataSourceChanged()
Emitted whenever the layer's data source has been changed.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
QString metadataUrlFormat() const
Returns the metadata format of the layer used by QGIS Server in GetCapabilities request.
void setRefreshOnNofifyMessage(const QString &message)
Set the notification message that triggers repaint If refresh on notification is enabled,...
void opacityChanged(double opacity)
Emitted when the layer's opacity is changed, where opacity is a value between 0 (transparent) and 1 (...
void styleLoaded(QgsMapLayer::StyleCategories categories)
Emitted when a style has been loaded.
void dataChanged()
Data of layer changed.
QString mMetadataUrlFormat
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
void setMetadataUrlFormat(const QString &metaUrlFormat)
Sets the metadata format of the layer used by QGIS Server in GetCapabilities request.
void blendModeChanged(QPainter::CompositionMode blendMode)
Signal emitted when the blend mode is changed, through QgsMapLayer::setBlendMode()
bool readOnly() const
Returns if this layer is read only.
virtual bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)=0
Read the symbology for the current layer from the DOM node supplied.
QString metadataUrl() const
Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request.
QString mMetadataUrl
MetadataUrl of the layer.
LayerFlag
Flags for the map layer.
void appendError(const QgsErrorMessage &error)
Add error message.
QgsMapLayer & operator=(QgsMapLayer const &)=delete
QgsMapLayer cannot be copied.
QString mDataSource
Data source description string, varies by layer type.
QString refreshOnNotifyMessage() const
Returns the message that should be notified by the provider to triggerRepaint.
virtual bool readSld(const QDomNode &node, QString &errorMessage)
ReadFlag
Flags which control project read behavior.
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
QString mAbstract
Description of the layer.
void customPropertyChanged(const QString &key)
Emitted when a custom property of the layer has been changed or removed.
QString legendUrl() const
Returns the URL for the layer's legend.
void flagsChanged()
Emitted when layer's flags have been modified.
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
void setLegendUrlFormat(const QString &legendUrlFormat)
Sets the format for a URL based layer legend.
void beforeResolveReferences(QgsProject *project)
Emitted when all layers are loaded and references can be resolved, just before the references of this...
void setMetadataUrl(const QString &metaUrl)
Sets the metadata URL of the layer used by QGIS Server in GetCapabilities request.
void setMetadataUrlType(const QString &metaUrlType)
Set the metadata type of the layer used by QGIS Server in GetCapabilities request MetadataUrlType ind...
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)=0
Sets the coordinate transform context to transformContext.
virtual QgsMapLayerElevationProperties * elevationProperties()
Returns the layer's elevation properties.
void nameChanged()
Emitted when the name has been changed.
QString mDataUrl
DataUrl of the layer.
StyleCategory
Categories of style to distinguish appropriate sections for import/export.
virtual Q_INVOKABLE void reload()
Synchronises with changes in the datasource.
virtual QgsMapLayerTemporalProperties * temporalProperties()
Returns the layer's temporal properties.
QString mAttribution
Attribution of the layer.
QString metadataUrlType() const
Returns the metadata type of the layer used by QGIS Server in GetCapabilities request.
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
void setTitle(const QString &title)
Sets the title of the layer used by QGIS Server in GetCapabilities request.
PropertyType
Maplayer has a style and a metadata property.
Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML i...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
An interface for classes which can visit style entity (e.g.
QgsMapLayerType
Types of layers that can be added to a map.
@ PointCloudLayer
Added in 3.18.
@ VectorTileLayer
Added in 3.14.
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList
A list of weak pointers to QgsMapLayers.
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
const QgsCoordinateReferenceSystem & crs
Setting options for creating vector data providers.