QGIS API Documentation  3.9.0-Master (224899f119)
Public Member Functions | Public Attributes | List of all members
QgsMimeDataUtils::Uri Struct Reference

#include <qgsmimedatautils.h>

Public Member Functions

 Uri ()=default
 Constructs invalid URI. More...
 
 Uri (const QString &encData)
 Constructs URI from encoded data. More...
 
 Uri (QgsMapLayer *layer)
 Constructs a URI corresponding to the specified layer. More...
 
QString data () const
 Returns encoded representation of the object. More...
 
bool isValid () const
 Returns whether the object contains valid data. More...
 
QgsMapLayermapLayer () const
 Returns the layer from the active project corresponding to this uri (if possible), otherwise returns nullptr. More...
 
QgsMeshLayermeshLayer (bool &owner, QString &error) const
 Gets mesh layer from uri if possible, otherwise returns nullptr and error is set. More...
 
QgsRasterLayerrasterLayer (bool &owner, QString &error) const
 Gets raster layer from uri if possible, otherwise returns nullptr and error is set. More...
 
QgsVectorLayervectorLayer (bool &owner, QString &error) const
 Gets vector layer from uri if possible, otherwise returns nullptr and error is set. More...
 

Public Attributes

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

Detailed Description

Definition at line 40 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 31 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 102 of file qgsmimedatautils.cpp.

◆ isValid()

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

Returns whether the object contains valid data.

Since
QGIS 3.0

Definition at line 58 of file qgsmimedatautils.h.

◆ mapLayer()

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.

Since
QGIS 3.8

Definition at line 179 of file qgsmimedatautils.cpp.

◆ meshLayer()

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 raster

Definition at line 157 of file qgsmimedatautils.cpp.

◆ rasterLayer()

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

Definition at line 135 of file qgsmimedatautils.cpp.

◆ vectorLayer()

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

Definition at line 107 of file qgsmimedatautils.cpp.

Member Data Documentation

◆ layerId

QString QgsMimeDataUtils::Uri::layerId

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

Since
QGIS 3.8

Definition at line 130 of file qgsmimedatautils.h.

◆ layerType

QString QgsMimeDataUtils::Uri::layerType

Type of URI.

Recognized types include

  • "vector": vector layers
  • "raster": raster layers
  • "mesh": mesh layers
  • "plugin": plugin layers
  • "custom": custom types
  • "project": QGS/QGZ project file
  • "directory": directory path

Mime data from plugins may use additional custom layer types.

Definition at line 109 of file qgsmimedatautils.h.

◆ name

QString QgsMimeDataUtils::Uri::name

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

Definition at line 120 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 137 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 117 of file qgsmimedatautils.h.

◆ supportedCrs

QStringList QgsMimeDataUtils::Uri::supportedCrs

Definition at line 123 of file qgsmimedatautils.h.

◆ supportedFormats

QStringList QgsMimeDataUtils::Uri::supportedFormats

Definition at line 124 of file qgsmimedatautils.h.

◆ uri

QString QgsMimeDataUtils::Uri::uri

Identifier of the data source recognized by its providerKey.

Definition at line 122 of file qgsmimedatautils.h.

◆ wkbType

QgsWkbTypes::Type QgsMimeDataUtils::Uri::wkbType = QgsWkbTypes::Unknown

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

Since
QGIS 3.8

Definition at line 145 of file qgsmimedatautils.h.


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