Class: QgsBrowserProxyModel

A QSortFilterProxyModel subclass for filtering and sorting browser model items.

Added in version 3.4.

Class Hierarchy

Inheritance diagram of qgis.core.QgsBrowserProxyModel

Base classes

QSortFilterProxyModel

QAbstractProxyModel

QAbstractItemModel

QObject

Methods

browserModel

Returns the underlying browser model.

caseSensitivity

Returns whether item filtering is case sensitive.

dataItem

Returns the data item at the specified proxy index, or None if no item exists at the index.

filterByLayerType

Returns True if the model is filtered by map layer type.

filterString

Returns the filter string used when filtering items in the model.

filterSyntax

Returns the filter syntax.

layerType

Returns the layer type to filter the model by.

setBrowserModel

Sets the underlying browser model.

setFilterByLayerType

Sets whether the model is filtered by map layer type.

setFilterCaseSensitivity

Sets whether item filtering should be case sensitive.

setFilterString

Sets the filter string to use when filtering items in the model.

setFilterSyntax

Sets the filter syntax.

setHiddenDataItemProviderKeyFilter

Sets a filter to hide data items based on QgsDataItem.providerKey() associated with the item.

setLayerType

Sets the layer type to filter the model by.

setShowLayers

Sets show layers to showLayers

setShownDataItemProviderKeyFilter

Sets a filter to show data items based on QgsDataItem.providerKey() associated with the item.

showLayers

Returns True if layers must be shown, this flag is True by default.

Attributes

Normal

RegularExpression

Wildcards

class qgis.core.QgsBrowserProxyModel[source]

Bases: QSortFilterProxyModel

__init__(parent: QObject | None = None)

Constructor for QgsBrowserProxyModel, with the specified parent object.

Parameters:

parent (Optional[QObject] = None)

class FilterSyntax

Bases: int

Normal = 0
RegularExpression = 2
Wildcards = 1
browserModel(self) QgsBrowserModel | None[source]

Returns the underlying browser model.

Return type:

Optional[QgsBrowserModel]

caseSensitivity(self) Qt.CaseSensitivity[source]

Returns whether item filtering is case sensitive.

Return type:

Qt.CaseSensitivity

dataItem(self, index: QModelIndex) QgsDataItem | None[source]

Returns the data item at the specified proxy index, or None if no item exists at the index.

Parameters:

index (QModelIndex)

Return type:

Optional[QgsDataItem]

filterByLayerType(self) bool[source]

Returns True if the model is filtered by map layer type.

See also

layerType()

Return type:

bool

filterString(self) str[source]

Returns the filter string used when filtering items in the model.

Return type:

str

filterSyntax(self) QgsBrowserProxyModel.FilterSyntax[source]

Returns the filter syntax.

Return type:

QgsBrowserProxyModel.FilterSyntax

layerType(self) Qgis.LayerType[source]

Returns the layer type to filter the model by. This is only used if filterByLayerType() is True.

See also

setLayerType()

Return type:

Qgis.LayerType

setBrowserModel(self, model: QgsBrowserModel | None)[source]

Sets the underlying browser model.

See also

browserModel()

Parameters:

model (Optional[QgsBrowserModel])

setFilterByLayerType(self, enabled: bool)[source]

Sets whether the model is filtered by map layer type.

See also

setLayerType()

Parameters:

enabled (bool)

setFilterCaseSensitivity(self, sensitivity: Qt.CaseSensitivity)[source]

Sets whether item filtering should be case sensitive.

Parameters:

sensitivity (Qt.CaseSensitivity)

setFilterString(self, filter: str | None)[source]

Sets the filter string to use when filtering items in the model.

See also

filterString()

Parameters:

filter (Optional[str])

setFilterSyntax(self, syntax: QgsBrowserProxyModel.FilterSyntax)[source]

Sets the filter syntax.

See also

filterSyntax()

Parameters:

syntax (QgsBrowserProxyModel.FilterSyntax)

setHiddenDataItemProviderKeyFilter(self, hiddenItemsFilter: Iterable[str | None])[source]

Sets a filter to hide data items based on QgsDataItem.providerKey() associated with the item.

By default browser model shows all items from all available data item providers and few special items (e.g. Favorites). To customize the behavior, set the filter to not load certain data items. The items that are not based on data item providers have prefix “special:”, for example “special:Favorites”, “special:Home”, “PostGIS”, “MSSQL”

All items created by the providers listed in filter are hidden from the layer tree. This filter is always evaluated.

Parameters:

hiddenItemsFilter (Iterable[Optional[str]]) – a list of data provider prefixes that will be hidden.

Added in version 3.12.

setLayerType(self, type: Qgis.LayerType)[source]

Sets the layer type to filter the model by. This is only used if filterByLayerType() is True.

See also

layerType()

Parameters:

type (Qgis.LayerType)

setShowLayers(self, showLayers: bool)[source]

Sets show layers to showLayers

See also

showLayers()

Added in version 3.14.

Parameters:

showLayers (bool)

setShownDataItemProviderKeyFilter(self, shownItemsFilter: Iterable[str | None])[source]

Sets a filter to show data items based on QgsDataItem.providerKey() associated with the item.

By default browser model shows all items from all available data item providers and few special items (e.g. Favorites). To customize the behavior, set the filter to load only certain data items. The items that are not based on data item providers have prefix “special:”, for example “special:Favorites”, “special:Home”, “PostGIS”, “MSSQL”

Only the items created by the providers listed in filter are shown in the layer tree. This filter is always evaluated.

Parameters:

shownItemsFilter (Iterable[Optional[str]]) – a list of data provider prefixes that will be hidden.

Added in version 3.14.

showLayers(self) bool[source]

Returns True if layers must be shown, this flag is True by default.

See also

setShowLayers()

Added in version 3.14.

Return type:

bool