QGIS API Documentation 4.3.0-Master (0cfde48c85b)
Loading...
Searching...
No Matches
QgsMimeDataUtils::Uri Struct Reference

#include <qgsmimedatautils.h>

Public Member Functions

 Uri ()=default
 Constructs invalid URI.
 Uri (const QString &encData)
 Constructs URI from encoded data.
 Uri (QgsMapLayer *layer)
 Constructs a URI corresponding to the specified layer.
QString data () const
 Returns encoded representation of the object.
bool isValid () const
 Returns whether the object contains valid data.
Q_DECL_DEPRECATED QgsMapLayer * mapLayer () const
 Returns the layer from the active project corresponding to this uri (if possible), otherwise returns nullptr.
QgsMapLayer * mapLayer (QgsProject *project) const
 Returns the layer from project corresponding to this uri (if possible), otherwise returns nullptr.
Q_DECL_DEPRECATED QgsMeshLayer * meshLayer (bool &owner, QString &error) const
 Gets mesh layer from uri if possible, otherwise returns nullptr and error is set.
QgsMeshLayer * meshLayer (bool &owner, QString &error, QgsProject *project) const
 Gets mesh layer from uri if possible, otherwise returns nullptr and error is set.
Q_DECL_DEPRECATED QgsRasterLayer * rasterLayer (bool &owner, QString &error) const
 Gets raster layer from uri if possible, otherwise returns nullptr and error is set.
QgsRasterLayer * rasterLayer (bool &owner, QString &error, QgsProject *project) const
 Gets raster layer from uri if possible, otherwise returns nullptr and error is set.
Q_DECL_DEPRECATED QgsVectorLayer * vectorLayer (bool &owner, QString &error) const
 Gets vector layer from uri if possible, otherwise returns nullptr and error is set.
QgsVectorLayer * vectorLayer (bool &owner, QString &error, QgsProject *project) const
 Gets vector layer from uri if possible, otherwise returns nullptr and error is set.

Public Attributes

QString filePath
 Path to file, if uri is associated with a file.
QString layerId
 Layer ID, if uri is associated with a layer from a QgsProject.
QString layerType
 Type of URI.
QString name
 Human readable name to be used e.g. in layer tree.
QString pId
 Unique ID associated with application instance.
QString providerKey
 For "vector" / "raster" type: provider id.
QStringList supportedCrs
QStringList supportedFormats
QString uri
 Identifier of the data source recognized by its providerKey.
Qgis::WkbType wkbType = Qgis::WkbType::Unknown
 WKB type, if associated with a vector layer, or QgsWkbTypes::Unknown if not yet known.

Detailed Description

Definition at line 44 of file qgsmimedatautils.h.

Constructor & Destructor Documentation

◆ Uri() [1/3]

QgsMimeDataUtils::Uri::Uri ( )
default

Constructs invalid URI.

◆ Uri() [2/3]

QgsMimeDataUtils::Uri::Uri ( const QString & encData)
explicit

Constructs URI from encoded data.

Definition at line 32 of file qgsmimedatautils.cpp.

◆ Uri() [3/3]

QgsMimeDataUtils::Uri::Uri ( QgsMapLayer * layer)
explicit

Constructs a URI corresponding to the specified layer.

Since
QGIS 3.8

Definition at line 67 of file qgsmimedatautils.cpp.

Member Function Documentation

◆ data()

QString QgsMimeDataUtils::Uri::data ( ) const

Returns encoded representation of the object.

Definition at line 101 of file qgsmimedatautils.cpp.

◆ isValid()

bool QgsMimeDataUtils::Uri::isValid ( ) const
inline

Returns whether the object contains valid data.

Definition at line 61 of file qgsmimedatautils.h.

◆ mapLayer() [1/2]

QgsMapLayer * QgsMimeDataUtils::Uri::mapLayer ( ) const

Returns the layer from the active project corresponding to this uri (if possible), otherwise returns nullptr.

Unlike vectorLayer(), rasterLayer(), or meshLayer(), this method will not attempt to create a new layer corresponding to the URI.

Returns
map layer if found in the active project, otherwise nullptr
Since
QGIS 3.8
Deprecated
QGIS 4.4. Use mapLayer() with explicit project parameter instead.

Definition at line 193 of file qgsmimedatautils.cpp.

◆ mapLayer() [2/2]

QgsMapLayer * QgsMimeDataUtils::Uri::mapLayer ( QgsProject * project) const

Returns the layer from project corresponding to this uri (if possible), otherwise returns nullptr.

Unlike vectorLayer(), rasterLayer(), or meshLayer(), this method will not attempt to create a new layer corresponding to the URI.

Parameters
projectused to obtain the layer
Returns
map layer if found in the project, otherwise nullptr
Since
QGIS 4.4

Definition at line 198 of file qgsmimedatautils.cpp.

◆ meshLayer() [1/2]

QgsMeshLayer * QgsMimeDataUtils::Uri::meshLayer ( bool & owner,
QString & error ) const

Gets mesh layer from uri if possible, otherwise returns nullptr and error is set.

Parameters
ownerset to true if caller becomes owner
errorset to error message if cannot get mesh
Returns
mesh layer if successful, otherwise nullptr
Deprecated
QGIS 4.4. Use meshLayer() with explicit project parameter instead.

Definition at line 166 of file qgsmimedatautils.cpp.

◆ meshLayer() [2/2]

QgsMeshLayer * QgsMimeDataUtils::Uri::meshLayer ( bool & owner,
QString & error,
QgsProject * project ) const

Gets mesh layer from uri if possible, otherwise returns nullptr and error is set.

Parameters
ownerset to true if caller becomes owner
errorset to error message if cannot get mesh
projectproject is used to obtain the layer
Returns
mesh layer if successful, otherwise nullptr
Since
QGIS 4.4

Definition at line 171 of file qgsmimedatautils.cpp.

◆ rasterLayer() [1/2]

QgsRasterLayer * QgsMimeDataUtils::Uri::rasterLayer ( bool & owner,
QString & error ) const

Gets raster layer from uri if possible, otherwise returns nullptr and error is set.

Parameters
ownerset to true if caller becomes owner
errorset to error message if cannot get raster
Returns
raster layer if successful, otherwise nullptr
Deprecated
QGIS 4.4. Use rasterLayer() with explicit project parameter instead.

Definition at line 139 of file qgsmimedatautils.cpp.

◆ rasterLayer() [2/2]

QgsRasterLayer * QgsMimeDataUtils::Uri::rasterLayer ( bool & owner,
QString & error,
QgsProject * project ) const

Gets raster layer from uri if possible, otherwise returns nullptr and error is set.

Parameters
ownerset to true if caller becomes owner
errorset to error message if cannot get raster
projectproject is used to obtain the layer
Returns
raster layer if successful, otherwise nullptr
Since
QGIS 4.4

Definition at line 144 of file qgsmimedatautils.cpp.

◆ vectorLayer() [1/2]

QgsVectorLayer * QgsMimeDataUtils::Uri::vectorLayer ( bool & owner,
QString & error ) const

Gets vector layer from uri if possible, otherwise returns nullptr and error is set.

Parameters
ownerset to true if caller becomes owner
errorset to error message if cannot get vector
Returns
vector layer if successful, otherwise nullptr
Deprecated
QGIS 4.4. Use vectorLayer() with explicit project parameter instead.

Definition at line 106 of file qgsmimedatautils.cpp.

◆ vectorLayer() [2/2]

QgsVectorLayer * QgsMimeDataUtils::Uri::vectorLayer ( bool & owner,
QString & error,
QgsProject * project ) const

Gets vector layer from uri if possible, otherwise returns nullptr and error is set.

Parameters
ownerset to true if caller becomes owner
errorset to error message if cannot get vector
projectproject is used to obtain the layer
Returns
vector layer if successful, otherwise nullptr
Since
QGIS 4.4

Definition at line 111 of file qgsmimedatautils.cpp.

Member Data Documentation

◆ filePath

QString QgsMimeDataUtils::Uri::filePath

Path to file, if uri is associated with a file.

Since
QGIS 3.22

Definition at line 234 of file qgsmimedatautils.h.

◆ layerId

QString QgsMimeDataUtils::Uri::layerId

Layer ID, if uri is associated with a layer from a QgsProject.

Since
QGIS 3.8

Definition at line 213 of file qgsmimedatautils.h.

◆ layerType

QString QgsMimeDataUtils::Uri::layerType

Type of URI.

Recognized types include

  • "vector": vector layers
  • "raster": raster layers
  • "mesh": mesh layers
  • "point-cloud": point cloud layers (spelled with a dash since QGIS 3.42.0. In prior versions, there was no dash)
  • "vector-tile": vector tile layers
  • "tiled-scene": tiled scene layers
  • "annotation": annotation layers
  • "group": group layers
  • "plugin": plugin layers
  • "custom": custom types
  • "project": QGS/QGZ project file
  • "directory": directory path

Note: use QgsMapLayerFactory::typeToString() to convert from a Qgis::LayerType to a string (except for "custom", "project" and "directory")

Mime data from plugins may use additional custom layer types.

Definition at line 192 of file qgsmimedatautils.h.

◆ name

QString QgsMimeDataUtils::Uri::name

Human readable name to be used e.g. in layer tree.

Definition at line 203 of file qgsmimedatautils.h.

◆ pId

QString QgsMimeDataUtils::Uri::pId

Unique ID associated with application instance.

Can be used to identify if mime data was created inside the current application instance or not.

Since
QGIS 3.8

Definition at line 220 of file qgsmimedatautils.h.

◆ providerKey

QString QgsMimeDataUtils::Uri::providerKey

For "vector" / "raster" type: provider id.

For "plugin" type: plugin layer type name. For "custom" type: key of its QgsCustomDropHandler For "project" and "directory" types: unused

Definition at line 200 of file qgsmimedatautils.h.

◆ supportedCrs

QStringList QgsMimeDataUtils::Uri::supportedCrs

Definition at line 206 of file qgsmimedatautils.h.

◆ supportedFormats

QStringList QgsMimeDataUtils::Uri::supportedFormats

Definition at line 207 of file qgsmimedatautils.h.

◆ uri

QString QgsMimeDataUtils::Uri::uri

Identifier of the data source recognized by its providerKey.

Definition at line 205 of file qgsmimedatautils.h.

◆ wkbType

Qgis::WkbType QgsMimeDataUtils::Uri::wkbType = Qgis::WkbType::Unknown

WKB type, if associated with a vector layer, or QgsWkbTypes::Unknown if not yet known.

Since
QGIS 3.8

Definition at line 228 of file qgsmimedatautils.h.


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