79 return mLayerMetadata;
84 mLayerMetadata = metadata;
94 :
QgsDataItem(
Qgis::BrowserItemType::Layer, parent, name, path, providerKey )
96 , mLayerType( layerType )
106 return Qgis::LayerType::Raster;
109 return Qgis::LayerType::Mesh;
112 return Qgis::LayerType::VectorTile;
115 return Qgis::LayerType::Plugin;
118 return Qgis::LayerType::PointCloud;
128 return Qgis::LayerType::Vector;
131 return Qgis::LayerType::Vector;
136 switch ( layer->
type() )
138 case Qgis::LayerType::Vector:
140 switch ( qobject_cast< QgsVectorLayer * >( layer )->geometryType() )
142 case Qgis::GeometryType::Point:
145 case Qgis::GeometryType::Line:
148 case Qgis::GeometryType::Polygon:
151 case Qgis::GeometryType::Null:
154 case Qgis::GeometryType::Unknown:
161 case Qgis::LayerType::Raster:
163 case Qgis::LayerType::Plugin:
165 case Qgis::LayerType::Mesh:
167 case Qgis::LayerType::PointCloud:
169 case Qgis::LayerType::VectorTile:
171 case Qgis::LayerType::Annotation:
172 case Qgis::LayerType::Group:
188 return QStringLiteral(
"/mIconPointLayer.svg" );
190 return QStringLiteral(
"/mIconLineLayer.svg" );
192 return QStringLiteral(
"/mIconPolygonLayer.svg" );
194 return QStringLiteral(
"/mIconGeometryCollectionLayer.svg" );
197 return QStringLiteral(
"/mIconTableLayer.svg" );
199 return QStringLiteral(
"/mIconRaster.svg" );
201 return QStringLiteral(
"/mIconMeshLayer.svg" );
203 return QStringLiteral(
"/mIconPointCloudLayer.svg" );
205 return QStringLiteral(
"/mIconVectorTileLayer.svg" );
210 return QStringLiteral(
"/mIconLayer.png" );;
228 const QgsLayerItem *o = qobject_cast<const QgsLayerItem *>( other );
241 case Qgis::LayerType::Vector:
242 u.
layerType = QStringLiteral(
"vector" );
270 case Qgis::LayerType::Raster:
271 u.
layerType = QStringLiteral(
"raster" );
273 case Qgis::LayerType::Mesh:
276 case Qgis::LayerType::VectorTile:
277 u.
layerType = QStringLiteral(
"vector-tile" );
279 case Qgis::LayerType::PointCloud:
280 u.
layerType = QStringLiteral(
"pointcloud" );
282 case Qgis::LayerType::Plugin:
283 u.
layerType = QStringLiteral(
"plugin" );
285 case Qgis::LayerType::Group:
288 case Qgis::LayerType::Annotation:
289 u.
layerType = QStringLiteral(
"annotation" );
The Qgis class provides global constants for use throughout the application.
@ ItemRepresentsFile
Item's path() directly represents a file on disk (since QGIS 3.22)
BrowserLayerType
Browser item layer types.
@ Point
Vector point layer.
@ Plugin
Plugin based layer.
@ Polygon
Vector polygon layer.
@ Vector
Generic vector layer.
@ VectorTile
Vector tile layer.
@ TableLayer
Vector non-spatial layer.
@ Database
Database layer.
@ PointCloud
Point cloud layer.
LayerType
Types of layers that can be added to a map.
WkbType
The WKB type describes the number of dimensions a geometry has.
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
Base class for all items in the model.
virtual QgsAbstractDatabaseProviderConnection * databaseConnection() const
For data items that represent a DB connection or one of its children, this method returns a connectio...
Qgis::BrowserItemType type() const
QgsDataItem * parent() const
Gets item parent.
virtual Qgis::BrowserItemCapabilities capabilities2() const
Returns the capabilities for the data item.
static QIcon iconLine()
Returns an icon representing line geometries.
static QIcon iconPolygon()
Returns an icon representing polygon geometries.
static QIcon iconForWkbType(Qgis::WkbType type)
Returns the icon for a vector layer whose geometry type is provided.
static QIcon iconDefaultLayer()
Returns a default icon for layers, which aren't the standard raster/vector/... types.
static QIcon iconPointCloud()
Returns an icon representing point cloud layers.
static QIcon iconPoint()
Returns an icon representing point geometries.
static QIcon iconTable()
Returns an icon representing non-spatial layers (tables).
static QIcon iconRaster()
Returns an icon representing raster layers.
static QIcon iconMesh()
Returns an icon representing mesh layers.
static QIcon iconVectorTile()
Returns an icon representing vector tile layers.
Item that represents a layer that can be opened with one of the providers.
QStringList supportedFormats() const
Returns the supported formats.
QString uri() const
Returns layer uri or empty string if layer cannot be created.
static Qgis::BrowserLayerType typeFromMapLayer(QgsMapLayer *layer)
Returns the layer item type corresponding to a QgsMapLayer layer.
virtual Q_DECL_DEPRECATED bool deleteLayer()
Delete this layer item Use QgsDataItemGuiProvider::deleteLayer instead.
QStringList supportedCrs() const
Returns the supported CRS.
static QString layerTypeAsString(Qgis::BrowserLayerType layerType)
Returns the string representation of the given layerType.
static QIcon iconDefault()
QgsAbstractDatabaseProviderConnection * databaseConnection() const override
For data items that represent a DB connection or one of its children, this method returns a connectio...
QString providerKey() const
Returns provider key.
static QIcon iconRaster()
static QIcon iconMesh()
Returns icon for mesh layer type.
QgsLayerItem(QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, Qgis::BrowserLayerType layerType, const QString &providerKey)
Constructor for QgsLayerItem.
Qgis::BrowserLayerType mLayerType
The layer type.
static QIcon iconForWkbType(Qgis::WkbType type)
Returns the icon for a vector layer whose geometry type is provided.
Qgis::LayerType mapLayerType() const
Returns the associated map layer type.
static QIcon iconPolygon()
QgsMimeDataUtils::UriList mimeUris() const override
Returns mime URIs for the data item, most data providers will only return a single URI but some data ...
void setLayerMetadata(const QgsLayerMetadata &metadata)
Set layer's metadata.
static QIcon iconPointCloud()
Returns icon for point cloud layer.
static QIcon iconVectorTile()
Returns icon for vector tile layer.
const QgsLayerMetadata & layerMetadata() const
Returns layer's metadata, it may be a default constructed metadata if metadata is not explicitly set.
virtual QString layerName() const
bool equal(const QgsDataItem *other) override
Returns true if this item is equal to another item (by testing item type and path).
static QString iconName(Qgis::BrowserLayerType layerType)
Returns the icon name of the given layerType.
Base class for all map layer types.
QList< QgsMimeDataUtils::Uri > UriList
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
#define BUILTIN_UNREACHABLE
Qgis::WkbType wkbType
WKB type, if associated with a vector layer, or QgsWkbTypes::Unknown if not yet known.
QString filePath
Path to file, if uri is associated with a file.
QString uri
Identifier of the data source recognized by its providerKey.
QString name
Human readable name to be used e.g. in layer tree.
QString providerKey
For "vector" / "raster" type: provider id.
QStringList supportedFormats
QString layerType
Type of URI.