QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
21 #include "qgis_core.h"
59 #define QGSCLIPBOARD_MAPLAYER_MIME "application/qgis.maplayer"
86 Q_PROPERTY( QString name READ name WRITE setName NOTIFY nameChanged )
87 Q_PROPERTY(
int autoRefreshInterval READ autoRefreshInterval WRITE setAutoRefreshInterval NOTIFY autoRefreshIntervalChanged )
88 Q_PROPERTY(
QgsLayerMetadata metadata READ metadata WRITE setMetadata NOTIFY metadataChanged )
91 Q_PROPERTY(
bool isValid READ isValid NOTIFY isValidChanged )
95 QgsMapLayer * layer = qobject_cast<QgsMapLayer *>( sipCpp );
101 switch ( layer->type() )
104 sipType = sipType_QgsVectorLayer;
107 sipType = sipType_QgsRasterLayer;
110 sipType = sipType_QgsPluginLayer;
113 sipType = sipType_QgsMeshLayer;
116 sipType = sipType_QgsVectorTileLayer;
119 sipType = sipType_QgsAnnotationLayer;
148 Identifiable = 1 << 0,
153 Q_DECLARE_FLAGS( LayerFlags, LayerFlag )
162 LayerConfiguration = 1 << 0,
164 Symbology3D = 1 << 2,
171 AttributeTable = 1 << 9,
173 CustomProperties = 1 << 11,
174 GeometryOptions = 1 << 12,
178 AllStyleCategories = LayerConfiguration | Symbology | Symbology3D | Labeling | Fields | Forms | Actions |
179 MapTips | Diagrams | AttributeTable | Rendering | CustomProperties | GeometryOptions | Relations | Temporal | Legend,
181 Q_ENUM( StyleCategory )
182 Q_DECLARE_FLAGS( StyleCategories, StyleCategory )
183 Q_FLAG( StyleCategories )
220 QgsMapLayer::LayerFlags flags()
const;
229 void setFlags( QgsMapLayer::LayerFlags flags );
236 static QString extensionPropertyType(
PropertyType type );
246 void setName(
const QString &name );
252 QString name()
const;
271 void setShortName( const QString &shortName ) { mShortName = shortName; }
278 QString shortName()
const;
285 void setTitle(
const QString &title ) { mTitle = title; }
293 QString
title()
const {
return mTitle; }
301 void setAbstract(
const QString &
abstract ) { mAbstract =
abstract; }
309 QString
abstract()
const {
return mAbstract; }
336 void setDataUrl(
const QString &dataUrl ) { mDataUrl = dataUrl; }
464 void setBlendMode( QPainter::CompositionMode blendMode );
470 QPainter::CompositionMode blendMode()
const;
494 bool isValid()
const;
502 QString publicSource()
const;
509 QString source()
const;
515 virtual QStringList subLayers()
const;
521 virtual void setLayerOrder(
const QStringList &layers );
528 virtual void setSubLayerVisibility(
const QString &name,
bool visible );
531 virtual bool isEditable()
const;
537 virtual bool isSpatial()
const;
548 virtual bool isTemporary()
const;
556 FlagDontResolveLayers = 1 << 0,
557 FlagTrustLayerMetadata = 1 << 1,
559 Q_DECLARE_FLAGS( ReadFlags, ReadFlag )
578 bool readLayerXml(
const QDomElement &layerElement,
QgsReadWriteContext &context, QgsMapLayer::ReadFlags flags = QgsMapLayer::ReadFlags() );
597 bool writeLayerXml( QDomElement &layerElement, QDomDocument &document,
const QgsReadWriteContext &context )
const;
603 virtual void resolveReferences(
QgsProject *project );
610 Q_INVOKABLE QStringList customPropertyKeys()
const;
617 Q_INVOKABLE
void setCustomProperty(
const QString &key,
const QVariant &value );
623 Q_INVOKABLE QVariant customProperty(
const QString &value,
const QVariant &defaultValue = QVariant() )
const;
642 void removeCustomProperty(
const QString &key );
673 static QString formatLayerName(
const QString &name );
682 virtual QString metadataUri()
const;
690 void exportNamedMetadata( QDomDocument &doc, QString &errorMsg )
const;
701 virtual QString saveDefaultMetadata(
bool &resultFlag
SIP_OUT );
717 QString saveNamedMetadata(
const QString &uri,
bool &resultFlag );
733 virtual QString loadNamedMetadata(
const QString &uri,
bool &resultFlag
SIP_OUT );
744 virtual QString loadDefaultMetadata(
bool &resultFlag );
754 bool loadNamedMetadataFromDatabase(
const QString &db,
const QString &uri, QString &qmd );
763 bool importNamedMetadata( QDomDocument &document, QString &errorMessage );
772 virtual QString styleURI()
const;
783 virtual QString loadDefaultStyle(
bool &resultFlag
SIP_OUT );
809 virtual bool loadNamedStyleFromDatabase(
const QString &db,
const QString &uri, QString &qml
SIP_OUT );
820 virtual bool importNamedStyle( QDomDocument &doc, QString &errorMsg
SIP_OUT,
841 virtual void exportSldStyle( QDomDocument &doc, QString &errorMsg )
const;
852 virtual QString saveDefaultStyle(
bool &resultFlag
SIP_OUT );
869 virtual QString saveNamedStyle(
const QString &uri,
bool &resultFlag
SIP_OUT, StyleCategories categories = AllStyleCategories );
879 virtual QString saveSldStyle(
const QString &uri,
bool &resultFlag )
const;
889 virtual QString loadSldStyle(
const QString &uri,
bool &resultFlag );
891 virtual bool readSld(
const QDomNode &node, QString &errorMessage )
892 { Q_UNUSED( node ) errorMessage = QStringLiteral(
"Layer type %1 not supported" ).arg(
static_cast<int>( type() ) );
return false; }
917 virtual bool readStyle(
const QDomNode &node, QString &errorMessage,
931 StyleCategories categories = AllStyleCategories )
const = 0;
945 virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context,
946 StyleCategories categories = AllStyleCategories )
const;
964 virtual void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options,
bool loadDefaultStyleFlag =
false );
969 QString providerType()
const;
972 QUndoStack *undoStack();
978 QUndoStack *undoStackStyles();
983 void setLegendUrl(
const QString &legendUrl ) { mLegendUrl = legendUrl; }
1040 bool isInScaleRange(
double scale )
const;
1052 double minimumScale()
const;
1064 double maximumScale()
const;
1074 bool hasScaleBasedVisibility()
const;
1082 bool hasAutoRefreshEnabled()
const;
1091 int autoRefreshInterval()
const;
1104 void setAutoRefreshInterval(
int interval );
1112 void setAutoRefreshEnabled(
bool enabled );
1134 virtual QString htmlMetadata()
const;
1137 virtual QDateTime timestamp()
const;
1146 virtual QSet<QgsMapLayerDependency> dependencies()
const;
1170 QString originalXmlProperties()
const;
1179 void setOriginalXmlProperties(
const QString &originalXmlProperties );
1185 static QString generateId(
const QString &layerName );
1216 void setMinimumScale(
double scale );
1227 void setMaximumScale(
double scale );
1236 void setScaleBasedVisibility(
bool enabled );
1246 void triggerRepaint(
bool deferredUpdate =
false );
1252 void emitStyleChanged();
1262 virtual bool setDependencies(
const QSet<QgsMapLayerDependency> &layers );
1269 void setRefreshOnNotifyEnabled(
bool enabled );
1288 SIP_PYOBJECT __repr__();
1290 QString str = QStringLiteral(
"<QgsMapLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider() ? sipCpp->dataProvider()->name() : QStringLiteral(
"Invalid" ) );
1291 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
1430 void onNotifiedTriggerRepaint(
const QString &message );
1445 void setValid(
bool valid );
1457 virtual bool writeXml( QDomNode &layer_node, QDomDocument &document,
const QgsReadWriteContext &context )
const;
1470 virtual QString encodedSource(
const QString &source,
const QgsReadWriteContext &context )
const;
1484 virtual QString decodedSource(
const QString &source,
const QString &dataProvider,
const QgsReadWriteContext &context )
const;
1491 void readCustomProperties(
const QDomNode &layerNode,
const QString &keyStartsWith = QString() );
1494 void writeCustomProperties( QDomNode &layerNode, QDomDocument &doc )
const;
1497 void readStyleManager(
const QDomNode &layerNode );
1499 void writeStyleManager( QDomNode &layerNode, QDomDocument &doc )
const;
1505 void writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
1507 StyleCategories categories = AllStyleCategories )
const;
1513 void readCommonStyle(
const QDomElement &layerElement,
const QgsReadWriteContext &context,
1514 StyleCategories categories = AllStyleCategories );
1517 void setProviderType(
const QString &providerType );
1521 void connectNotify(
const char *signal )
override;
1535 bool mValid =
false;
1580 bool mIsRefreshOnNofifyEnabled =
false;
1589 QgsMapLayer::ReadFlags mReadFlags = QgsMapLayer::ReadFlags();
1596 bool mShouldValidateCrs =
true;
1602 bool &resultFlag, StyleCategories categories = AllStyleCategories );
1604 bool &resultFlag, StyleCategories categories = AllStyleCategories );
1605 bool loadNamedPropertyFromDatabase(
const QString &db,
const QString &uri, QString &xml,
QgsMapLayer::PropertyType type );
1611 virtual bool isReadOnly()
const;
1625 LayerFlags mFlags = LayerFlags( Identifiable | Removable | Searchable );
1628 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1636 double mMinScale = 0;
1638 double mMaxScale = 100000000;
1640 bool mScaleBasedVisibility =
false;
1643 QUndoStack *mUndoStack =
nullptr;
1645 QUndoStack *mUndoStackStyles =
nullptr;
1657 QTimer *mRefreshTimer =
nullptr;
1669 QString mOriginalXmlProperties;
1672 bool mRepaintRequestedFired =
false;
void setError(const QgsError &error)
Sets error message.
void setAbstract(const QString &abstract)
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
void flagsChanged()
Emitted when layer's flags have been modified.
void dependenciesChanged()
Emitted when dependencies are changed.
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
Contains information about the context in which a coordinate transform is executed.
QString refreshOnNotifyMessage() const
Returns the message that should be notified by the provider to triggerRepaint.
void setMetadataUrl(const QString &metaUrl)
Sets the metadata URL of the layer used by QGIS Server in GetCapabilities request.
void configChanged()
Emitted whenever the configuration is changed.
QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList
A list of weak pointers to QgsMapLayers.
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
Setting options for creating vector data providers.
The class is used as a container of context for various read/write operations on other objects.
Abstract base class for spatial data provider implementations.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
Base class for all renderers that may to participate in 3D view.
const QgsCoordinateReferenceSystem & crs
bool isRefreshOnNotifyEnabled() const
Returns true if the refresh on provider nofification is enabled.
QgsMapLayerType
Types of layers that can be added to a map.
void setMetadataUrlType(const QString &metaUrlType)
Set the metadata type of the layer used by QGIS Server in GetCapabilities request MetadataUrlType ind...
QgsError is container for error messages (report).
The QgsMapLayerLegend class is abstract interface for implementations of legends for one map layer.
void statusChanged(const QString &status)
Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar)
Contains information about the context of a rendering operation.
An interface for classes which can visit style entity (e.g.
PropertyType
Maplayer has a style and a metadata property.
virtual void reload()
Synchronises with changes in the datasource.
ReadFlag
Flags which control project read behavior.
void crsChanged()
Emit a signal that layer's CRS has been reset.
A rectangle specified with double values.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
QString mProviderKey
Data provider key (name of the data provider)
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Base class for utility classes that encapsulate information necessary for rendering of map layers.
void setLegendUrlFormat(const QString &legendUrlFormat)
Sets the format for a URL based layer legend.
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
QString mLayerName
Name of the layer - used for display.
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
void dataSourceChanged()
Emitted whenever the layer's data source has been changed.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Management of styles for use with one map layer.
QgsRectangle mExtent
Extent of the layer.
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
QgsMapLayer & operator=(QgsMapLayer const &)=delete
QgsMapLayer cannot be copied.
virtual bool readSld(const QDomNode &node, QString &errorMessage)
QString legendUrlFormat() const
Returns the format for a URL based layer legend.
QString mMetadataUrl
MetadataUrl of the layer.
QString metadataUrlFormat() const
Returns the metadata format of the layer used by QGIS Server in GetCapabilities request.
void styleChanged()
Signal emitted whenever a change affects the layer's style.
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
QString mAttribution
Attribution of the layer.
QSet< QgsMapLayerDependency > mDependencies
List of layers that may modify this layer on modification.
void blendModeChanged(QPainter::CompositionMode blendMode)
Signal emitted when the blend mode is changed, through QgsMapLayer::setBlendMode()
void isValidChanged()
Emitted when the validity of this layer changed.
void nameChanged()
Emitted when the name has been changed.
virtual QgsMapLayerTemporalProperties * temporalProperties()
Returns the layer's temporal properties.
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.
QString mDataUrl
DataUrl of the layer.
QString mMetadataUrlFormat
void setKeywordList(const QString &keywords)
Sets the keyword list of the layer used by QGIS Server in GetCapabilities request.
QString title() const
Returns the title 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.
Base class for storage of map layer temporal properties.
QString mDataSource
Data source description string, varies by layer type.
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
QgsErrorMessage represents single error message.
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)=0
Sets the coordinate transform context to transformContext.
void rendererChanged()
Signal emitted when renderer is changed.
This class represents a coordinate reference system (CRS).
void beforeResolveReferences(QgsProject *project)
Emitted when all layers are loaded and references can be resolved, just before the references of this...
void legendChanged()
Signal emitted when legend of the layer has changed.
void setMetadataUrlFormat(const QString &metaUrlFormat)
Sets the metadata format of the layer used by QGIS Server in GetCapabilities request.
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.
void setAttributionUrl(const QString &attribUrl)
Sets the attribution URL of the layer used by QGIS Server in GetCapabilities request.
QString legendUrl() const
Returns the URL for the layer's legend.
void dataChanged()
Data of layer changed.
void appendError(const QgsErrorMessage &error)
Add error message.
LayerFlag
Flags for the map layer.
QString mAbstract
Description of the layer.
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.
void setRefreshOnNofifyMessage(const QString &message)
Set the notification message that triggers repaint If refresh on notification is enabled,...
void setDataUrlFormat(const QString &dataUrlFormat)
Sets the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML i...
Base class for all map layer types.
void setLegendUrl(const QString &legendUrl)
Sets the URL for the layer's legend.
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...
bool readOnly() const
Returns if this layer is read only.
void recalculateExtents() const
This is used to send a request that any mapcanvas using this layer update its extents.
@ VectorTileLayer
Added in 3.14.
QString metadataUrl() const
Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request.
StyleCategory
Categories of style to distinguish appropriate sections for import/export.
QgsMapLayer(QgsMapLayer const &)=delete
QgsMapLayer cannot be copied.
void styleLoaded(QgsMapLayer::StyleCategories categories)
Emitted when a style has been loaded.
void setAttribution(const QString &attrib)
Sets the attribution of the layer used by QGIS Server in GetCapabilities request.
QString mRefreshOnNofifyMessage
QString mLegendUrl
WMS legend.
void setDataUrl(const QString &dataUrl)
Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
QString metadataUrlType() const
Returns the metadata type of the layer used by QGIS Server in GetCapabilities request.
void renderer3DChanged()
Signal emitted when 3D renderer associated with the layer has changed.
void autoRefreshIntervalChanged(int interval)
Emitted when the auto refresh interval changes.
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext)=0
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
void metadataChanged()
Emitted when the layer's metadata is changed.