Class: QgsProviderSublayerModel

class qgis.core.QgsProviderSublayerModel

Bases: PyQt5.QtCore.QAbstractItemModel

A model for representing the sublayers present in a URI.

QgsProviderSublayerModel is designed to present a tree view of the sublayers available for a URI, including any vector, raster or mesh sublayers present.

Additionally, QgsProviderSublayerModel can include some non-sublayer items, e.g. in order to represent other content available for a URI, such as embedded project items. The non-sublayer items can be added by calling addNonLayerItem().

Added in version 3.22.

QgsProviderSublayerModel(parent: QObject = None) Constructor for QgsProviderSublayerModel, with the specified parent object.

Enums

Column

Bases: enum.IntEnum

Role

Bases: enum.IntEnum

Methods

addNonLayerItem

Adds a non-layer item (e.g. an embedded QGIS project item) to the model.

beginInsertColumns

beginInsertRows

beginMoveColumns

beginMoveRows

beginRemoveColumns

beginRemoveRows

beginResetModel

changePersistentIndex

changePersistentIndexList

childEvent

columnCount

param parent:

connectNotify

createIndex

customEvent

data

param index:

decodeData

disconnectNotify

encodeData

endInsertColumns

endInsertRows

endMoveColumns

endMoveRows

endRemoveColumns

endRemoveRows

endResetModel

flags

param index:

headerData

param section:

index

param row:

indexToNonLayerItem

Returns the non layer item corresponding to the given index.

indexToSublayer

Returns the sublayer corresponding to the given index.

isSignalConnected

parent

param index:

persistentIndexList

receivers

resetInternalData

rowCount

param parent:

sender

senderSignalIndex

setSublayerDetails

Sets the sublayer details to show in the model.

sublayerDetails

Returns the sublayer details shown in the model.

timerEvent

class Column(value)

Bases: enum.IntEnum

Model columns

  • Name: Layer name

  • Description: Layer description

Description = 1
Name = 0
class NonLayerItem

Bases: sip.wrapper

Contains details for a non-sublayer item to include in a QgsProviderSublayerModel.

Added in version 3.22.

description(self) str

Returns the item’s description.

See also

setDescription()

Return type:

str

icon(self) QIcon

Returns the item’s icon.

See also

setIcon()

Return type:

QIcon

name(self) str

Returns the item’s name.

See also

setName()

Return type:

str

setDescription(self, description: str)

Sets the item’s description.

See also

setDescription()

Parameters:

description (str)

setIcon(self, icon: QIcon)

Sets the item’s icon.

See also

setIcon()

Parameters:

icon (QIcon)

setName(self, name: str)

Sets the item’s name.

See also

setName()

Parameters:

name (str)

setType(self, type: str)

Sets the item’s type.

See also

type()

Parameters:

type (str)

setUri(self, uri: str)

Set the item’s uri.

See also

setUri()

Parameters:

uri (str)

type(self) str

Returns the item’s type.

See also

setType()

Return type:

str

uri(self) str

Returns the item’s URI.

See also

setUri()

Return type:

str

class Role(value)

Bases: enum.IntEnum

Custom model roles

  • ProviderKey: Provider key

  • LayerType: Layer type

  • Uri: Layer URI

  • Name: Layer name

  • Description: Layer description

  • Path: Layer path

  • FeatureCount: Feature count (for vector sublayers)

  • WkbType: WKB geometry type (for vector sublayers)

  • GeometryColumnName: Geometry column name (for vector sublayers)

  • LayerNumber: Layer number

  • IsNonLayerItem: True if item is a non-sublayer item (e.g. an embedded project)

  • NonLayerItemType: Item type (for non-sublayer items)

  • Flags: Sublayer flags

Description = 261
FeatureCount = 263
Flags = 269
GeometryColumnName = 265
IsNonLayerItem = 267
LayerNumber = 266
LayerType = 258
Name = 260
NonLayerItemType = 268
Path = 262
ProviderKey = 257
Uri = 259
WkbType = 264
addNonLayerItem(self, item: QgsProviderSublayerModel.NonLayerItem)

Adds a non-layer item (e.g. an embedded QGIS project item) to the model.

Parameters:

item (QgsProviderSublayerModel.NonLayerItem)

beginInsertColumns(self, QModelIndex, int, int)
beginInsertRows(self, QModelIndex, int, int)
beginMoveColumns(self, QModelIndex, int, int, QModelIndex, int) bool
beginMoveRows(self, QModelIndex, int, int, QModelIndex, int) bool
beginRemoveColumns(self, QModelIndex, int, int)
beginRemoveRows(self, QModelIndex, int, int)
beginResetModel(self)
changePersistentIndex(self, QModelIndex, QModelIndex)
changePersistentIndexList(self, Iterable[QModelIndex], Iterable[QModelIndex])
childEvent(self, QChildEvent)
columnCount(self, parent: QModelIndex = QModelIndex()) int
Parameters:

parent (QModelIndex = QModelIndex())

Return type:

int

connectNotify(self, QMetaMethod)
createIndex(self, int, int, object: object = 0) QModelIndex
customEvent(self, QEvent)
data(self, index: QModelIndex, role: int) Any
Parameters:
  • index (QModelIndex)

  • role (int)

Return type:

Any

decodeData(self, int, int, QModelIndex, QDataStream) bool
disconnectNotify(self, QMetaMethod)
encodeData(self, Iterable[QModelIndex], QDataStream)
endInsertColumns(self)
endInsertRows(self)
endMoveColumns(self)
endMoveRows(self)
endRemoveColumns(self)
endRemoveRows(self)
endResetModel(self)
flags(self, index: QModelIndex) Qt.ItemFlags
Parameters:

index (QModelIndex)

Return type:

Qt.ItemFlags

headerData(self, section: int, orientation: Qt.Orientation, role: int = Qt.DisplayRole) Any
Parameters:
  • section (int)

  • orientation (Qt.Orientation)

  • role (int = Qt.DisplayRole)

Return type:

Any

index(self, row: int, column: int, parent: QModelIndex = QModelIndex()) QModelIndex
Parameters:
  • row (int)

  • column (int)

  • parent (QModelIndex = QModelIndex())

Return type:

QModelIndex

indexToNonLayerItem(self, index: QModelIndex) QgsProviderSublayerModel.NonLayerItem

Returns the non layer item corresponding to the given index.

Parameters:

index (QModelIndex)

Return type:

QgsProviderSublayerModel.NonLayerItem

indexToSublayer(self, index: QModelIndex) QgsProviderSublayerDetails

Returns the sublayer corresponding to the given index.

Parameters:

index (QModelIndex)

Return type:

QgsProviderSublayerDetails

isSignalConnected(self, QMetaMethod) bool
parent(self, index: QModelIndex) QModelIndex
Parameters:

index (QModelIndex)

Return type:

QModelIndex

persistentIndexList(self) List[QModelIndex]
receivers(self, PYQT_SIGNAL) int
resetInternalData(self)
rowCount(self, parent: QModelIndex) int
Parameters:

parent (QModelIndex)

Return type:

int

sender(self) QObject
senderSignalIndex(self) int
setSublayerDetails(self, details: Iterable[QgsProviderSublayerDetails])

Sets the sublayer details to show in the model.

Parameters:

details (Iterable[QgsProviderSublayerDetails])

sublayerDetails(self) List[QgsProviderSublayerDetails]

Returns the sublayer details shown in the model.

Return type:

List[QgsProviderSublayerDetails]

timerEvent(self, QTimerEvent)