QGIS API Documentation 3.37.0-Master (fa0c88a90b0)
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. More...
 

Public Member Functions

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

Static Public Member Functions

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

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 22 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 142 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 125 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 171 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 41 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:
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 185 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 111 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 97 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 136 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:
since 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 34 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 165 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 88 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:
use setLayerAllowList()

Definition at line 83 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 106 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 34 of file qgsmaplayerproxymodel.h.

◆ exceptedLayerList

QList<QgsMapLayer *> QgsMapLayerProxyModel::exceptedLayerList
readwrite

Definition at line 34 of file qgsmaplayerproxymodel.h.

◆ filters

Qgis::LayerFilters QgsMapLayerProxyModel::filters
readwrite

Definition at line 34 of file qgsmaplayerproxymodel.h.


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