mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Added rasterLayer method
This commit is contained in:
parent
ef89a624a1
commit
ab2589bc03
@ -48,6 +48,14 @@ Returns encoded representation of the object
|
||||
:rtype: QgsVectorLayer
|
||||
%End
|
||||
|
||||
QgsRasterLayer *rasterLayer( bool &owner, QString &error ) const;
|
||||
%Docstring
|
||||
Get raster layer from uri if possible, otherwise returns 0 and error is set
|
||||
\param owner set to true if caller becomes owner
|
||||
\param error set to error message if cannot get raster
|
||||
:rtype: QgsRasterLayer
|
||||
%End
|
||||
|
||||
QString layerType;
|
||||
%Docstring
|
||||
Type of URI. Recognized types: "vector" / "raster" / "plugin" / "custom"
|
||||
|
@ -100,6 +100,18 @@ QgsVectorLayer *QgsMimeDataUtils::Uri::vectorLayer( bool &owner, QString &error
|
||||
return new QgsVectorLayer( uri, name, providerKey );
|
||||
}
|
||||
|
||||
QgsRasterLayer *QgsMimeDataUtils::Uri::rasterLayer( bool &owner, QString &error ) const
|
||||
{
|
||||
owner = false;
|
||||
if ( layerType != QLatin1String( "raster" ) )
|
||||
{
|
||||
error = QObject::tr( "%1: Not a raster layer." ).arg( name );
|
||||
return nullptr;
|
||||
}
|
||||
owner = true;
|
||||
return new QgsRasterLayer( uri, name, providerKey );
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
bool QgsMimeDataUtils::isUriList( const QMimeData *data )
|
||||
|
@ -23,6 +23,7 @@
|
||||
class QgsLayerItem;
|
||||
class QgsLayerTreeNode;
|
||||
class QgsVectorLayer;
|
||||
class QgsRasterLayer;
|
||||
|
||||
/** \ingroup core
|
||||
* \class QgsMimeDataUtils
|
||||
@ -51,6 +52,12 @@ class CORE_EXPORT QgsMimeDataUtils
|
||||
*/
|
||||
QgsVectorLayer *vectorLayer( bool &owner, QString &error ) const;
|
||||
|
||||
/** Get raster layer from uri if possible, otherwise returns 0 and error is set
|
||||
* \param owner set to true if caller becomes owner
|
||||
* \param error set to error message if cannot get raster
|
||||
*/
|
||||
QgsRasterLayer *rasterLayer( bool &owner, QString &error ) const;
|
||||
|
||||
//! Type of URI. Recognized types: "vector" / "raster" / "plugin" / "custom"
|
||||
QString layerType;
|
||||
//! For "vector" / "raster" type: provider id.
|
||||
|
Loading…
x
Reference in New Issue
Block a user