QgsLayerItem class

Item that represents a layer that can be opened with one of the providers.

Base classes

class QgsDataItem
Base class for all items in the model.

Public types

enum LayerType { NoType, Vector, Raster, Point, Line, Polygon, TableLayer, Database, Table, Plugin, Mesh }

Public static functions

static auto iconMesh() -> QIcon
Returns icon for mesh layer type.
static auto iconName(LayerType layerType) -> QString
Returns the icon name of the given layerType.
static auto layerTypeAsString(LayerType layerType) -> QString
Returns the string representation of the given layerType.
static auto typeFromMapLayer(QgsMapLayer* layer) -> LayerType
Returns the layer item type corresponding to a QgsMapLayer layer.

Public functions

auto comments() const -> QString virtual
Returns comments of the layer.
auto deleteLayer() -> bool virtual
Delete this layer item.
auto equal(const QgsDataItem* other) -> bool override
Returns true if this item is equal to another item (by testing item type and path).
auto hasDragEnabled() const -> bool override
Returns true if the item may be dragged.
auto layerName() const -> QString virtual
auto mapLayerType() const -> QgsMapLayer::LayerType
Returns QgsMapLayer::LayerType.
auto mimeUri() const -> QgsMimeDataUtils::Uri override
Returns mime URI for the data item.
auto providerKey() const -> QString
Returns provider key.
auto supportedCrs() const -> QStringList
Returns the supported CRS.
auto supportedFormats() const -> QStringList
Returns the supported formats.
auto uri() const -> QString
Returns layer uri or empty string if layer cannot be created.

Protected variables

LayerType mLayerType
The layer type.
QString mProviderKey
The provider key.
QStringList mSupportedCRS
The list of supported CRS.
QStringList mSupportFormats
The list of supported formats.
QString mUri
The URI.

Enum documentation

enum QgsLayerItem::LayerType

Enumerators
NoType
Vector
Raster
Point
Line
Polygon
TableLayer
Database
Table
Plugin

Added in 2.10.

Mesh

Added in 3.2.

Function documentation

static QString QgsLayerItem::iconName(LayerType layerType)

Returns the icon name of the given layerType.

static QString QgsLayerItem::layerTypeAsString(LayerType layerType)

Returns the string representation of the given layerType.

static LayerType QgsLayerItem::typeFromMapLayer(QgsMapLayer* layer)

Returns the layer item type corresponding to a QgsMapLayer layer.

QString QgsLayerItem::comments() const virtual

Returns comments of the layer.

bool QgsLayerItem::hasDragEnabled() const override

Returns true if the item may be dragged.

Default implementation returns false. A draggable item has to implement mimeUri() that will be used to pass data.

QString QgsLayerItem::layerName() const virtual

Returns the layer name

QgsMimeDataUtils::Uri QgsLayerItem::mimeUri() const override

Returns mime URI for the data item.

Items that return valid URI will be returned in mime data when dragging a selection from browser model.

QStringList QgsLayerItem::supportedCrs() const

Returns the supported CRS.

QStringList QgsLayerItem::supportedFormats() const

Returns the supported formats.