QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Public Slots | Public Member Functions | Static Public Member Functions | Properties | List of all members
QgsMapLayerProxyModel Class Reference

The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widgets. More...

#include <qgsmaplayerproxymodel.h>

Inheritance diagram for QgsMapLayerProxyModel:
Inheritance graph
[legend]

Public Slots

void setFilterString (const QString &filter)
 Sets a filter string, such that only layers with names matching the specified string will be shown.
 

Public Member Functions

 QgsMapLayerProxyModel (QObject *parent=nullptr)
 QgsMapLayerProxModel creates a proxy model with a QgsMapLayerModel as source model.
 
bool acceptsLayer (QgsMapLayer *layer) const
 Returns true if the proxy model accepts the specified map layer.
 
QStringList exceptedLayerIds () const
 Returns the blocklist of layer IDs which are excluded from the model.
 
QList< QgsMapLayer * > exceptedLayerList ()
 Returns the blocklist of layers which are excluded from the model.
 
QStringList excludedProviders () const
 Returns the blocklist of data providers which are excluded from the model.
 
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override
 
const Qgis::LayerFiltersfilters () const
 Returns the filter flags which affect how layers are filtered within the model.
 
QString filterString () const
 Returns the current filter string, if set.
 
QList< QgsMapLayer * > layerAllowlist ()
 Returns the list of layers which are excluded from the model.
 
Q_DECL_DEPRECATED QList< QgsMapLayer * > layerWhitelist ()
 Returns the list of layers which are excluded from the model.
 
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override
 
void setExceptedLayerIds (const QStringList &ids)
 Sets a blocklist of layers (by layer ID) to exclude from the model.
 
void setExceptedLayerList (const QList< QgsMapLayer * > &exceptList)
 Sets a blocklist of layers to exclude from the model.
 
void setExcludedProviders (const QStringList &providers)
 Sets a blocklist of data providers which should be excluded from the model.
 
Q_DECL_DEPRECATED void setFilters (int filters)
 Filters according to layer type and/or geometry type.
 
QgsMapLayerProxyModelsetFilters (Qgis::LayerFilters filters)
 Sets filter flags which affect how layers are filtered within the model.
 
void setLayerAllowlist (const QList< QgsMapLayer * > &layers)
 Sets an allowlist of layers to include within the model.
 
Q_DECL_DEPRECATED void setLayerWhitelist (const QList< QgsMapLayer * > &layers)
 Sets an allowlist of layers to include within the model.
 
void setProject (QgsProject *project)
 Sets the project from which map layers are shown.
 
QgsMapLayerModelsourceLayerModel () const
 layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel
 

Static Public Member Functions

static bool layerMatchesFilters (const QgsMapLayer *layer, const Qgis::LayerFilters &filters)
 Returns if the layer matches the given filters.
 

Properties

QStringList exceptedLayerIds
 
QList< QgsMapLayer * > exceptedLayerList
 
Qgis::LayerFilters filters
 

Detailed Description

The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widgets.

Definition at line 34 of file qgsmaplayerproxymodel.h.

Constructor & Destructor Documentation

◆ QgsMapLayerProxyModel()

QgsMapLayerProxyModel::QgsMapLayerProxyModel ( QObject *  parent = nullptr)
explicit

QgsMapLayerProxModel creates a proxy model with a QgsMapLayerModel as source model.

It can be used to filter the layers list in a widget.

Definition at line 23 of file qgsmaplayerproxymodel.cpp.

Member Function Documentation

◆ acceptsLayer()

bool QgsMapLayerProxyModel::acceptsLayer ( QgsMapLayer layer) const

Returns true if the proxy model accepts the specified map layer.

Since
QGIS 3.8

Definition at line 143 of file qgsmaplayerproxymodel.cpp.

◆ exceptedLayerIds()

QStringList QgsMapLayerProxyModel::exceptedLayerIds ( ) const

Returns the blocklist of layer IDs which are excluded from the model.

See also
setExceptedLayerIds()
exceptedLayerList()

Definition at line 126 of file qgsmaplayerproxymodel.cpp.

◆ exceptedLayerList()

QList< QgsMapLayer * > QgsMapLayerProxyModel::exceptedLayerList ( )
inline

Returns the blocklist of layers which are excluded from the model.

See also
setExceptedLayerList()
exceptedLayerIds()
layerAllowlist()

Definition at line 158 of file qgsmaplayerproxymodel.h.

◆ excludedProviders()

QStringList QgsMapLayerProxyModel::excludedProviders ( ) const
inline

Returns the blocklist of data providers which are excluded from the model.

See also
setExcludedProviders()

Definition at line 184 of file qgsmaplayerproxymodel.h.

◆ filterAcceptsRow()

bool QgsMapLayerProxyModel::filterAcceptsRow ( int  source_row,
const QModelIndex &  source_parent 
) const
override

Definition at line 172 of file qgsmaplayerproxymodel.cpp.

◆ filters()

const Qgis::LayerFilters & QgsMapLayerProxyModel::filters ( ) const
inline

Returns the filter flags which affect how layers are filtered within the model.

See also
setFilters()

Definition at line 77 of file qgsmaplayerproxymodel.h.

◆ filterString()

QString QgsMapLayerProxyModel::filterString ( ) const
inline

Returns the current filter string, if set.

See also
setFilterString()
Since
QGIS 3.4

Definition at line 192 of file qgsmaplayerproxymodel.h.

◆ layerAllowlist()

QList< QgsMapLayer * > QgsMapLayerProxyModel::layerAllowlist ( )
inline

Returns the list of layers which are excluded from the model.

An empty list indicates that no filtering by allowlist should be performed.

See also
setLayerAllowlist()
exceptedLayerList()
Since
QGIS 3.14

Definition at line 142 of file qgsmaplayerproxymodel.h.

◆ layerMatchesFilters()

bool QgsMapLayerProxyModel::layerMatchesFilters ( const QgsMapLayer layer,
const Qgis::LayerFilters filters 
)
static

Returns if the layer matches the given filters.

Since
QGIS 3.14

Definition at line 42 of file qgsmaplayerproxymodel.cpp.

◆ layerWhitelist()

Q_DECL_DEPRECATED QList< QgsMapLayer * > QgsMapLayerProxyModel::layerWhitelist ( )
inline

Returns the list of layers which are excluded from the model.

An empty list indicates that no filtering by allowlist should be performed.

See also
setLayerAllowlist()
exceptedLayerList()
Deprecated:
QGIS 3.40. Use layerAllowlist() instead.

Definition at line 130 of file qgsmaplayerproxymodel.h.

◆ lessThan()

bool QgsMapLayerProxyModel::lessThan ( const QModelIndex &  left,
const QModelIndex &  right 
) const
override

Definition at line 186 of file qgsmaplayerproxymodel.cpp.

◆ setExceptedLayerIds()

void QgsMapLayerProxyModel::setExceptedLayerIds ( const QStringList &  ids)

Sets a blocklist of layers (by layer ID) to exclude from the model.

See also
exceptedLayerIds()
setExceptedLayerList()

Definition at line 112 of file qgsmaplayerproxymodel.cpp.

◆ setExceptedLayerList()

void QgsMapLayerProxyModel::setExceptedLayerList ( const QList< QgsMapLayer * > &  exceptList)

Sets a blocklist of layers to exclude from the model.

See also
exceptedLayerList()
setExceptedLayerIds()
setLayerAllowlist()

Definition at line 98 of file qgsmaplayerproxymodel.cpp.

◆ setExcludedProviders()

void QgsMapLayerProxyModel::setExcludedProviders ( const QStringList &  providers)

Sets a blocklist of data providers which should be excluded from the model.

See also
excludedProviders()

Definition at line 137 of file qgsmaplayerproxymodel.cpp.

◆ setFilters() [1/2]

Q_DECL_DEPRECATED void QgsMapLayerProxyModel::setFilters ( int  filters)
inline

Filters according to layer type and/or geometry type.

Note
for API compatibility
Since
QGIS 3.34
Deprecated:
QGIS 3.34. Use the flag signature instead.

Definition at line 69 of file qgsmaplayerproxymodel.h.

◆ setFilters() [2/2]

QgsMapLayerProxyModel * QgsMapLayerProxyModel::setFilters ( Qgis::LayerFilters  filters)

Sets filter flags which affect how layers are filtered within the model.

See also
filters()

Definition at line 35 of file qgsmaplayerproxymodel.cpp.

◆ setFilterString

void QgsMapLayerProxyModel::setFilterString ( const QString &  filter)
slot

Sets a filter string, such that only layers with names matching the specified string will be shown.

See also
filterString()
Since
QGIS 3.4

Definition at line 166 of file qgsmaplayerproxymodel.cpp.

◆ setLayerAllowlist()

void QgsMapLayerProxyModel::setLayerAllowlist ( const QList< QgsMapLayer * > &  layers)

Sets an allowlist of layers to include within the model.

Only layers from this list will be shown.

An empty list indicates that no filter by allowlist should be performed.

See also
layerAllowlist()
setExceptedLayerList()
Since
QGIS 3.14

Definition at line 89 of file qgsmaplayerproxymodel.cpp.

◆ setLayerWhitelist()

void QgsMapLayerProxyModel::setLayerWhitelist ( const QList< QgsMapLayer * > &  layers)

Sets an allowlist of layers to include within the model.

Only layers from this list will be shown.

An empty list indicates that no filter by allowlist should be performed.

See also
layerAllowlist()
setExceptedLayerList()
Deprecated:
QGIS 3.40. Use setLayerAllowList().

Definition at line 84 of file qgsmaplayerproxymodel.cpp.

◆ setProject()

void QgsMapLayerProxyModel::setProject ( QgsProject project)

Sets the project from which map layers are shown.

If project is nullptr then QgsProject.instance() will be used.

Since
QGIS 3.24

Definition at line 107 of file qgsmaplayerproxymodel.cpp.

◆ sourceLayerModel()

QgsMapLayerModel * QgsMapLayerProxyModel::sourceLayerModel ( ) const
inline

layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel

Definition at line 53 of file qgsmaplayerproxymodel.h.

Property Documentation

◆ exceptedLayerIds

QStringList QgsMapLayerProxyModel::exceptedLayerIds
readwrite

Definition at line 40 of file qgsmaplayerproxymodel.h.

◆ exceptedLayerList

QList<QgsMapLayer *> QgsMapLayerProxyModel::exceptedLayerList
readwrite

Definition at line 39 of file qgsmaplayerproxymodel.h.

◆ filters

Qgis::LayerFilters QgsMapLayerProxyModel::filters
readwrite

Definition at line 38 of file qgsmaplayerproxymodel.h.


The documentation for this class was generated from the following files: