QGIS API Documentation  3.24.2-Tisler (13c1a02865)
Static Public Member Functions | List of all members
QgsMapLayerUtils Class Reference

Contains utility functions for working with map layers. More...

#include <qgsmaplayerutils.h>

Static Public Member Functions

static QgsRectangle combinedExtent (const QList< QgsMapLayer * > &layers, const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &transformContext)
 Returns the combined extent of a list of layers. More...
 
static QgsAbstractDatabaseProviderConnectiondatabaseConnection (const QgsMapLayer *layer)
 Creates and returns the (possibly nullptr) database connection for a layer. More...
 
static bool layerSourceMatchesPath (const QgsMapLayer *layer, const QString &path)
 Returns true if the source of the specified layer matches the given path. More...
 
static bool updateLayerSourcePath (QgsMapLayer *layer, const QString &newPath)
 Updates a layer's data source, replacing its data source with a path referring to newPath. More...
 

Detailed Description

Contains utility functions for working with map layers.

Since
QGIS 3.20

Definition at line 35 of file qgsmaplayerutils.h.

Member Function Documentation

◆ combinedExtent()

QgsRectangle QgsMapLayerUtils::combinedExtent ( const QList< QgsMapLayer * > &  layers,
const QgsCoordinateReferenceSystem crs,
const QgsCoordinateTransformContext transformContext 
)
static

Returns the combined extent of a list of layers.

The crs argument specifies the desired coordinate reference system for the combined extent.

Definition at line 30 of file qgsmaplayerutils.cpp.

◆ databaseConnection()

QgsAbstractDatabaseProviderConnection * QgsMapLayerUtils::databaseConnection ( const QgsMapLayer layer)
static

Creates and returns the (possibly nullptr) database connection for a layer.

Ownership is transferred to the caller.

Since
QGIS 3.22

Definition at line 92 of file qgsmaplayerutils.cpp.

◆ layerSourceMatchesPath()

bool QgsMapLayerUtils::layerSourceMatchesPath ( const QgsMapLayer layer,
const QString &  path 
)
static

Returns true if the source of the specified layer matches the given path.

This method can be used to test whether a layer is associated with a file path.

Since
QGIS 3.22

Definition at line 117 of file qgsmaplayerutils.cpp.

◆ updateLayerSourcePath()

bool QgsMapLayerUtils::updateLayerSourcePath ( QgsMapLayer layer,
const QString &  newPath 
)
static

Updates a layer's data source, replacing its data source with a path referring to newPath.

Returns true if the layer was updated, or false if the layer was not updated (e.g. it uses a data provider which does not specify paths in a layer URI.

Since
QGIS 3.22

Definition at line 126 of file qgsmaplayerutils.cpp.


The documentation for this class was generated from the following files: