70#define QGSCLIPBOARD_MAPLAYER_MIME "application/qgis.maplayer"
100 QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( sipCpp );
106 switch ( layer->type() )
109 sipType = sipType_QgsVectorLayer;
112 sipType = sipType_QgsRasterLayer;
115 sipType = sipType_QgsPluginLayer;
118 sipType = sipType_QgsMeshLayer;
121 sipType = sipType_QgsVectorTileLayer;
124 sipType = sipType_QgsAnnotationLayer;
127 sipType = sipType_QgsPointCloudLayer;
130 sipType = sipType_QgsGroupLayer;
133 sipType = sipType_QgsTiledSceneLayer;
199 Q_ENUM( StyleCategory )
292 bool setId( const QString &
id );
304 QString
name() const;
457 Q_DECL_DEPRECATED
void setMetadataUrl(
const QString &metaUrl )
SIP_DEPRECATED;
478 Q_DECL_DEPRECATED
void setMetadataUrlType( const QString &metaUrlType )
SIP_DEPRECATED;
499 Q_DECL_DEPRECATED
void setMetadataUrlFormat( const QString &metaUrlFormat )
SIP_DEPRECATED;
510 Q_DECL_DEPRECATED QString metadataUrlFormat() const
SIP_DEPRECATED;
517 void setBlendMode( QPainter::CompositionMode blendMode );
523 QPainter::CompositionMode blendMode() const;
533 virtual
void setOpacity(
double opacity );
543 virtual
double opacity() const;
594 QString
publicSource(
bool hidePassword =
false )
const;
728 Q_INVOKABLE QVariant
customProperty(
const QString &value,
const QVariant &defaultValue = QVariant() )
const;
775 QmlGenerationFailed = 1 << 0,
776 SldGenerationFailed = 1 << 1,
777 DatabaseWriteFailed = 1 << 2,
779 Q_ENUM( SaveStyleResult )
807 bool useAsDefault, const QString &uiFileContent,
825 bool useAsDefault, const QString &uiFileContent,
842 virtual QString
loadNamedStyle( const QString &theURI,
bool &resultFlag
SIP_OUT,
bool loadFromLocalDb,
861 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
862 Q_ASSERT( metaEnum.isValid() );
863 if ( !metaEnum.isValid() )
865 QgsDebugError( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
871 if ( metaEnum.isValid() )
874 QByteArray ba =
customProperty( key, metaEnum.valueToKey(
static_cast<int>( defaultValue ) ) ).toString().toUtf8();
875 const char *vs = ba.data();
876 v =
static_cast<T
>( metaEnum.keyToValue( vs, &ok ) );
884 v =
static_cast<T
>(
customProperty( key,
static_cast<int>( defaultValue ) ).toInt( &ok ) );
885 if ( metaEnum.isValid() )
887 if ( !ok || !metaEnum.valueToKey(
static_cast<int>( v ) ) )
913 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
914 Q_ASSERT( metaEnum.isValid() );
915 if ( metaEnum.isValid() )
921 QgsDebugError( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
939 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
940 Q_ASSERT( metaEnum.isValid() );
941 if ( !metaEnum.isValid() )
943 QgsDebugError( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
949 if ( metaEnum.isValid() )
952 QByteArray ba =
customProperty( key, metaEnum.valueToKeys( defaultValue ) ).toString().toUtf8();
953 const char *vs = ba.data();
954 v =
static_cast<T
>( metaEnum.keysToValue( vs, &ok ) );
959 const int intValue =
customProperty( key,
static_cast<int>( defaultValue ) ).toInt( &ok );
960 if ( metaEnum.isValid() )
966 const QByteArray keys = metaEnum.valueToKeys( intValue );
967 const int intValueCheck = metaEnum.keysToValue( keys );
968 if ( intValue != intValueCheck )
1003 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
1004 Q_ASSERT( metaEnum.isValid() );
1005 if ( metaEnum.isValid() )
1011 QgsDebugError( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
1021 void removeCustomProperty(
const QString &key );
1128 static QString formatLayerName(
const QString &name );
1136 virtual QString metadataUri()
const;
1143 void exportNamedMetadata( QDomDocument &doc, QString &errorMsg )
const;
1153 virtual QString saveDefaultMetadata(
bool &resultFlag
SIP_OUT );
1168 QString saveNamedMetadata(
const QString &uri,
bool &resultFlag
SIP_OUT );
1186 virtual QString loadNamedMetadata(
const QString &uri,
bool &resultFlag
SIP_OUT );
1199 virtual QString loadDefaultMetadata(
bool &resultFlag
SIP_OUT );
1208 bool loadNamedMetadataFromDatabase(
const QString &db,
const QString &uri, QString &qmd );
1216 bool importNamedMetadata( QDomDocument &document, QString &errorMessage );
1226 virtual QString styleURI()
const;
1240 virtual QString loadDefaultStyle(
bool &resultFlag
SIP_OUT );
1270 virtual bool loadNamedStyleFromDatabase(
const QString &db,
const QString &uri, QString &qml
SIP_OUT );
1280 virtual bool importNamedStyle( QDomDocument &doc, QString &errorMsg
SIP_OUT,
1302 Q_DECL_DEPRECATED
virtual void exportSldStyle( QDomDocument &doc, QString &errorMsg )
const SIP_DEPRECATED;
1335 virtual QString saveDefaultStyle(
bool &resultFlag
SIP_OUT, StyleCategories categories );
1365 virtual QString saveNamedStyle(
const QString &uri,
bool &resultFlag
SIP_OUT, StyleCategories categories = AllStyleCategories );
1376 virtual QString saveSldStyle(
const QString &uri,
bool &resultFlag
SIP_OUT )
const;
1398 virtual QString loadSldStyle(
const QString &uri,
bool &resultFlag
SIP_OUT );
1400 virtual bool readSld(
const QDomNode &node, QString &errorMessage )
1401 { Q_UNUSED( node ) errorMessage = QStringLiteral(
"Layer type %1 not supported" ).arg(
static_cast<int>(
type() ) );
return false; }
1425 virtual bool readStyle(
const QDomNode &node, QString &errorMessage,
1486 void setDataSource(
const QString &dataSource,
const QString &baseName = QString(),
const QString &provider = QString(),
bool loadDefaultStyleFlag =
false );
1763 QString originalXmlProperties()
const;
1772 void setOriginalXmlProperties(
const QString &originalXmlProperties );
1778 static QString generateId(
const QString &layerName );
1851 virtual bool hasMapTips()
const;
1860 QString mapTipTemplate()
const;
1869 void setMapTipTemplate(
const QString &mapTipTemplate );
1877 void setMapTipsEnabled(
bool enabled );
1883 bool mapTipsEnabled()
const;
1905 void setMinimumScale(
double scale );
1916 void setMaximumScale(
double scale );
1925 void setScaleBasedVisibility(
bool enabled );
1935 void triggerRepaint(
bool deferredUpdate =
false );
1943 void trigger3DUpdate();
1948 void emitStyleChanged();
1957 virtual bool setDependencies(
const QSet<QgsMapLayerDependency> &layers );
1963 void setRefreshOnNotifyEnabled(
bool enabled );
1981 SIP_PYOBJECT __repr__();
1983 QString str = QStringLiteral(
"<QgsMapLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider() ? sipCpp->dataProvider()->name() : QStringLiteral(
"Invalid" ) );
1984 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
2228 void onNotified(
const QString &message );
2311 void readCustomProperties(
const QDomNode &layerNode,
const QString &keyStartsWith = QString() );
2340 void connectNotify(
const char *signal )
override;
2355 void invalidateWgs84Extent();
2472 bool rebuildCrs3D( QString *
error =
nullptr );
2478 virtual bool isReadOnly()
const;
2497 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
2505 double mMinScale = 0;
2507 double mMaxScale = 100000000;
2509 bool mScaleBasedVisibility =
false;
2514 std::unique_ptr< QgsMapLayerServerProperties > mServerProperties;
2517 QUndoStack *mUndoStack =
nullptr;
2519 QUndoStack *mUndoStackStyles =
nullptr;
2525 std::unique_ptr<QgsMapLayerLegend> mLegend;
2528 std::unique_ptr<QgsMapLayerStyleManager> mStyleManager;
2533 QTimer *mRefreshTimer =
nullptr;
2538 std::unique_ptr<QgsAbstract3DRenderer> m3DRenderer;
2554 QString mOriginalXmlProperties;
2557 bool mRepaintRequestedFired =
false;
2560 QString mLegendPlaceholderImage;
2563 QString mMapTipTemplate;
2566 bool mMapTipsEnabled =
true;
Provides global constants and enumerations for use throughout the application.
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
LayerType
Types of layers that can be added to a map.
@ Group
Composite group layer. Added in QGIS 3.24.
@ Plugin
Plugin based layer.
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Mesh
Mesh layer. Added in QGIS 3.2.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
QFlags< LoadStyleFlag > LoadStyleFlags
Flags for loading layer styles.
AutoRefreshMode
Map layer automatic refresh modes.
@ Disabled
Automatic refreshing is disabled.
Base class for all renderers that participate in 3D views.
Interface for classes which can generate elevation profiles.
A 3-dimensional box composed of x, y, z coordinates.
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.
Represents a single error message.
A container for error messages.
Models dependencies with or between map layers.
Base class for storage of map layer elevation properties.
An abstract interface for implementations of legends for one map layer.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Base class for storage of map layer selection properties.
Manages QGIS Server properties for a map layer.
Management of styles for use with one map layer.
Base class for storage of map layer temporal properties.
void crs3DChanged()
Emitted when the crs3D() of the layer has changed.
Q_DECL_DEPRECATED void setShortName(const QString &shortName)
Sets the short name of the layer used by QGIS Server to identify the layer.
virtual bool deleteStyleFromDatabase(const QString &styleId, QString &msgError)
Deletes a style from the database.
friend class TestQgsMapLayer
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any). To be called by subclasses.
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 document provided.
Q_DECL_DEPRECATED QString legendUrlFormat() const
Returns the format for a URL based layer legend.
QgsRectangle wgs84Extent(bool forceRecalculate=false) const
Returns the WGS84 extent (EPSG:4326) of the layer according to ReadFlag::FlagTrustLayerMetadata.
virtual bool isSpatial() const
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated w...
QgsAbstract3DRenderer * renderer3D() const
Returns 3D renderer associated with the layer.
virtual bool isTemporary() const
Returns true if the layer is considered a temporary layer.
bool setId(const QString &id)
Sets the layer's id.
void dependenciesChanged()
Emitted when dependencies are changed.
void setError(const QgsError &error)
Sets error message.
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
void legendChanged()
Signal emitted when legend of the layer has changed.
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists). To be called by subclasses.
QgsMapLayerLegend * legend() const
Can be nullptr.
QFlags< ReadFlag > ReadFlags
QFlags< LayerFlag > LayerFlags
Q_DECL_DEPRECATED void setAbstract(const QString &abstract)
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
void editingStopped()
Emitted when edited changes have been successfully written to the data provider.
virtual QgsAbstractProfileSource * profileSource()
Returns the layer's profile source if it has profile capabilities.
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.
virtual QgsRectangle extent() const
Returns the extent of the layer.
QString source() const
Returns the source for the layer.
Q_DECL_DEPRECATED 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.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
int mBlockStyleChangedSignal
If non-zero, the styleChanged signal should not be emitted.
SaveStyleResult
Results of saving styles to database.
QString providerType() const
Returns the provider type (provider key) for this layer.
virtual void setExtent3D(const QgsBox3D &box)
Sets the extent.
Qgis::AutoRefreshMode autoRefreshMode() const
Returns the layer's automatic refresh mode.
void configChanged()
Emitted whenever the configuration is changed.
void autoRefreshIntervalChanged(int interval)
Emitted when the auto refresh interval changes.
T customFlagProperty(const QString &key, const T &defaultValue)
Returns the property value for a property based on a flag.
virtual QSet< QgsMapLayerDependency > dependencies() const
Gets the list of dependencies.
void setCustomProperties(const QgsObjectCustomProperties &properties)
Set custom properties for layer.
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...
virtual QString loadNamedStyle(const QString &theURI, bool &resultFlag, bool loadFromLocalDb, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories, Qgis::LoadStyleFlags flags=Qgis::LoadStyleFlags())
Loads a named style from file/local db/datasource db.
virtual QString encodedSource(const QString &source, const QgsReadWriteContext &context) const
Called by writeLayerXML(), used by derived classes to encode provider's specific data source to proje...
void editingStarted()
Emitted when editing on this layer has started.
QgsCoordinateReferenceSystem crs3D
virtual void setSubLayerVisibility(const QString &name, bool visible)
Set the visibility of the given sublayer name.
void isValidChanged()
Emitted when the validity of this layer changed.
QgsCoordinateReferenceSystem crs
QString legendPlaceholderImage() const
Returns path to the placeholder image or an empty string if a generated legend is shown.
friend class QgsVectorLayer
virtual bool readXml(const QDomNode &layer_node, QgsReadWriteContext &context)
Called by readLayerXML(), used by children to read state specific to them from project files.
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the map layer.
Q_DECL_DEPRECATED QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
void writeCustomProperties(QDomNode &layerNode, QDomDocument &doc) const
Write custom properties to project file.
QString mRefreshOnNofifyMessage
virtual int listStylesInDatabase(QStringList &ids, QStringList &names, QStringList &descriptions, QString &msgError)
Lists all the style in db split into related to the layer and not related to.
void setDataSource(const QString &dataSource, const QString &baseName=QString(), const QString &provider=QString(), bool loadDefaultStyleFlag=false)
Updates the data source of the layer.
QString mLayerName
Name of the layer - used for display.
virtual bool writeXml(QDomNode &layer_node, QDomDocument &document, const QgsReadWriteContext &context) const
Called by writeLayerXML(), used by children to write state specific to them to project files.
void setCustomFlagProperty(const QString &key, const T &value)
Set the value of a property based on a flag.
Q_DECL_DEPRECATED bool hasAutoRefreshEnabled() const
Returns true if auto refresh is enabled for the layer.
void mapTipTemplateChanged()
Emitted when the map tip template changes.
QString crsHtmlMetadata() const
Returns a HTML fragment containing the layer's CRS metadata, for use in the htmlMetadata() method.
Q_DECL_DEPRECATED void setAttributionUrl(const QString &attribUrl)
Sets the attribution URL of the layer used by QGIS Server in GetCapabilities request.
QgsMapLayer::SaveStyleResults saveStyleToDatabaseV2(const QString &name, const QString &description, bool useAsDefault, const QString &uiFileContent, QString &msgError, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Saves QML and SLD representations of the layer's style to a table in the database.
Q_DECL_DEPRECATED void setAutoRefreshEnabled(bool enabled)
Sets whether auto refresh is enabled for the layer.
QgsLayerMetadata metadata
void renderer3DChanged()
Signal emitted when 3D renderer associated with the layer has changed.
Q_DECL_DEPRECATED QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request.
virtual QgsMapLayerSelectionProperties * selectionProperties()
Returns the layer's selection properties.
QgsMapLayer(Qgis::LayerType type=Qgis::LayerType::Vector, const QString &name=QString(), const QString &source=QString())
Constructor for QgsMapLayer.
Q_DECL_DEPRECATED QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a 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).
Q_DECL_DEPRECATED void setDataUrl(const QString &dataUrl)
Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
Q_DECL_DEPRECATED void setKeywordList(const QString &keywords)
Sets the keyword list of the layerused by QGIS Server in GetCapabilities request.
Q_DECL_DEPRECATED void setAttribution(const QString &attrib)
Sets the attribution of the layerused by QGIS Server in GetCapabilities request.
void setFlags(QgsMapLayer::LayerFlags flags)
Returns the flags for this layer.
bool isRefreshOnNotifyEnabled() const
Returns true if the refresh on provider nofification is enabled.
QString publicSource(bool hidePassword=false) const
Gets a version of the internal layer definition that has sensitive bits removed (for example,...
Q_DECL_DEPRECATED QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
QSet< QgsMapLayerDependency > mDependencies
List of layers that may modify this layer on modification.
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith=QString())
Read custom properties from project file.
virtual Qgis::MapLayerProperties properties() const
Returns the map layer properties of this layer.
virtual void setMetadata(const QgsLayerMetadata &metadata)
Sets the layer's metadata store.
virtual bool readStyle(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read the style for the current layer from the DOM node supplied.
virtual bool supportsEditing() const
Returns whether the layer supports editing or not.
Q_DECL_DEPRECATED void setDataUrlFormat(const QString &dataUrlFormat)
Sets the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
QFlags< StyleCategory > StyleCategories
virtual Q_DECL_DEPRECATED void saveStyleToDatabase(const QString &name, const QString &description, bool useAsDefault, const QString &uiFileContent, QString &msgError, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Saves QML and SLD representations of the layer's style to a table in the database.
const QgsMapLayerServerProperties * serverProperties() const
Returns QGIS Server Properties const for the map layer.
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
QString mProviderKey
Data provider key (name of the data provider).
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
void styleChanged()
Signal emitted whenever a change affects the layer's style.
virtual bool isEditable() const
Returns true if the layer can be edited.
QUndoStack * undoStack()
Returns pointer to layer's undo stack.
std::unique_ptr< QgsDataProvider > mPreloadedProvider
Optionally used when loading a project, it is released when the layer is effectively created.
void rendererChanged()
Signal emitted when renderer is changed.
Q_DECL_DEPRECATED QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
void crsChanged()
Emitted when the crs() of the layer has changed.
virtual QgsError error() const
Gets current status error.
bool writeLayerXml(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context) const
Stores state in DOM node.
void dataSourceChanged()
Emitted whenever the layer's data source has been changed.
void idChanged(const QString &id)
Emitted when the layer's ID has been changed.
Q_DECL_DEPRECATED QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
QgsMapLayer::LayerFlags flags
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
QgsMapLayerSelectionProperties * selectionProperties
void setRefreshOnNofifyMessage(const QString &message)
Set the notification message that triggers repaint If refresh on notification is enabled,...
QgsProviderMetadata * providerMetadata() const
Returns the layer data provider's metadata, it may be nullptr.
void opacityChanged(double opacity)
Emitted when the layer's opacity is changed, where opacity is a value between 0 (transparent) and 1 (...
virtual bool isModified() const
Returns true if the layer has been modified since last commit/save.
void styleLoaded(QgsMapLayer::StyleCategories categories)
Emitted when a style has been loaded.
virtual QString getStyleFromDatabase(const QString &styleId, QString &msgError)
Returns the named style corresponding to style id provided.
virtual QgsMapLayerTemporalProperties * temporalProperties()
Returns the layer's temporal properties.
QUndoStack * undoStackStyles()
Returns pointer to layer's style undo stack.
void dataChanged()
Data of layer changed.
virtual QStringList subLayers() const
Returns the sublayers of this layer.
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext)=0
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
virtual QString htmlMetadata() const
Obtain a formatted HTML string containing assorted metadata for this layer.
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
void verticalCrsChanged()
Emitted when the verticalCrs() of the layer has changed.
virtual QgsBox3D extent3D() const
Returns the 3D extent of the layer.
static QString extensionPropertyType(PropertyType type)
Returns the extension of a Property.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
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.
void setName(const QString &name)
Set the display name of the layer.
void setAutoRefreshInterval(int interval)
Sets the auto refresh interval (in milliseconds) for the layer.
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.
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
virtual void resolveReferences(QgsProject *project)
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
LayerFlag
Flags for the map layer.
@ Identifiable
If the layer is identifiable using the identify map tool and as a WMS layer.
@ Removable
If the layer can be removed from the project. The layer will not be removable from the legend menu en...
@ Searchable
Only for vector-layer, determines if the layer is used in the 'search all layers' locator.
@ Private
Determines if the layer is meant to be exposed to the GUI, i.e. visible in the layer legend tree.
void setLegendPlaceholderImage(const QString &imgPath)
Set placeholder image for legend.
void appendError(const QgsErrorMessage &error)
Add error message.
QString mDataSource
Data source description string, varies by layer type.
void setAutoRefreshMode(Qgis::AutoRefreshMode mode)
Sets the automatic refresh mode for the layer.
QString refreshOnNotifyMessage() const
Returns the message that should be notified by the provider to triggerRepaint.
virtual bool readSld(const QDomNode &node, QString &errorMessage)
void setMapTipsEnabled(bool enabled)
Enable or disable map tips for this layer.
ReadFlag
Flags which control project read behavior.
@ FlagReadExtentFromXml
Read extent from xml and skip get extent from provider.
@ FlagTrustLayerMetadata
Trust layer metadata. Improves layer load time by skipping expensive checks like primary key unicity,...
@ FlagForceReadOnly
Force open as read only.
@ FlagDontResolveLayers
Don't resolve layer paths or create data providers for layers.
void setValid(bool valid)
Sets whether layer is valid or not.
Q_DECL_DEPRECATED QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types.
void customPropertyChanged(const QString &key)
Emitted when a custom property of the layer has been changed or removed.
QgsMapLayer::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when restoring state from XML.
double minimumScale() const
Returns the minimum map scale (i.e.
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
Q_DECL_DEPRECATED 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...
Q_DECL_DEPRECATED 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 setMapTipTemplate(const QString &mapTipTemplate)
The mapTip is a pretty, html representation for feature information.
virtual QgsMapLayerElevationProperties * elevationProperties()
Returns the layer's elevation properties.
bool setVerticalCrs(const QgsCoordinateReferenceSystem &crs, QString *errorMessage=nullptr)
Sets the layer's vertical coordinate reference system.
Q_INVOKABLE QStringList customPropertyKeys() const
Returns list of all keys within custom properties.
QgsProject * project() const
Returns the parent project if this map layer is added to a project.
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)=0
Sets the coordinate transform context to transformContext.
bool readLayerXml(const QDomElement &layerElement, QgsReadWriteContext &context, QgsMapLayer::ReadFlags flags=QgsMapLayer::ReadFlags(), QgsDataProvider *preloadedProvider=nullptr)
Sets state from DOM document.
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
virtual QString decodedSource(const QString &source, const QString &dataProvider, const QgsReadWriteContext &context) const
Called by readLayerXML(), used by derived classes to decode provider's specific data source from proj...
void nameChanged()
Emitted when the name has been changed.
QgsCoordinateReferenceSystem verticalCrs
virtual bool writeStyle(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write just the symbology information for the layer into the document.
bool mIsRefreshOnNofifyEnabled
virtual Q_INVOKABLE QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
double mLayerOpacity
Layer opacity.
T customEnumProperty(const QString &key, const T &defaultValue)
Returns the property value for a property based on an enum.
bool mValid
Indicates if the layer is valid and can be drawn.
StyleCategory
Categories of style to distinguish appropriate sections for import/export.
@ GeometryOptions
Geometry validation configuration.
@ AttributeTable
Attribute table settings: choice and order of columns, conditional styling.
@ AllVisualStyleCategories
All categories dealing with map canvas rendering.
@ LayerConfiguration
General configuration: identifiable, removable, searchable, display expression, read-only.
@ Temporal
Temporal properties.
@ Rendering
Rendering: scale visibility, simplify method, opacity.
@ Elevation
Elevation settings.
@ Symbology3D
3D symbology
@ CustomProperties
Custom properties (by plugins for instance).
@ Fields
Aliases, widgets, WMS/WFS, expressions, constraints, virtual fields.
@ AllAttributeCategories
All categories dealing with attributes and attribute form.
void layerModified()
Emitted when modifications has been done on layer.
virtual Q_INVOKABLE void reload()
Synchronises with changes in the datasource.
virtual QDateTime timestamp() const
Time stamp of data source in the moment when data/metadata were loaded by provider.
void setProviderType(const QString &providerType)
Sets the providerType (provider key).
friend class TestQgsProject
void mapTipsEnabledChanged()
Emitted when map tips are enabled or disabled for the layer.
QFlags< SaveStyleResult > SaveStyleResults
Results of saving styles to database.
void setRenderer3D(QgsAbstract3DRenderer *renderer)
Sets 3D renderer for the layer.
QString customPropertyHtmlMetadata() const
Returns an HTML fragment containing custom property information, for use in the htmlMetadata() method...
const QgsObjectCustomProperties & customProperties() const
Read all custom properties from layer.
QString generalHtmlMetadata() const
Returns an HTML fragment containing general metadata information, for use in the htmlMetadata() metho...
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write style data common to all layer types.
void setCustomEnumProperty(const QString &key, const T &value)
Set the value of a property based on an enum.
double maximumScale() const
Returns the maximum map scale (i.e.
Q_DECL_DEPRECATED QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
virtual void setLayerOrder(const QStringList &layers)
Reorders the previously selected sublayers of this layer from bottom to top.
Q_DECL_DEPRECATED 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.
bool mShouldValidateCrs
true if the layer's CRS should be validated and invalid CRSes are not permitted.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML i...
An interface for classes which can visit various object entity (e.g.
A QgsObjectEntityVisitorInterface context object.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
A container for the context for various read/write operations on objects.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
Holds SLD export options and other information related to SLD export of a QGIS layer style.
An interface for classes which can visit style entity (e.g.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_ENUM_BASETYPE(type)
#define QgsDebugError(str)
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList
A list of weak pointers to QgsMapLayers.
Setting options for creating vector data providers.