QGIS API Documentation  3.20.0-Odense (decaadbb31)
Public Types | 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 Types

enum  Filter {
  RasterLayer = 1 , NoGeometry = 2 , PointLayer = 4 , LineLayer = 8 ,
  PolygonLayer = 16 , HasGeometry = PointLayer | LineLayer | PolygonLayer , VectorLayer = NoGeometry | HasGeometry , PluginLayer = 32 ,
  WritableLayer = 64 , MeshLayer = 128 , VectorTileLayer = 256 , PointCloudLayer = 512 ,
  All = RasterLayer | VectorLayer | PluginLayer | MeshLayer | VectorTileLayer | PointCloudLayer
}
 

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 Filters & 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...
 
QgsMapLayerProxyModelsetFilters (QgsMapLayerProxyModel::Filters 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...
 
QgsMapLayerModelsourceLayerModel () const
 layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel More...
 

Static Public Member Functions

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

Properties

QStringList exceptedLayerIds
 
QList< QgsMapLayer * > exceptedLayerList
 
QgsMapLayerProxyModel::Filters filters
 

Detailed Description

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

Since
QGIS 2.3

Definition at line 33 of file qgsmaplayerproxymodel.h.

Member Enumeration Documentation

◆ Filter

Enumerator
RasterLayer 
NoGeometry 
PointLayer 
LineLayer 
PolygonLayer 
HasGeometry 
VectorLayer 
PluginLayer 
WritableLayer 
MeshLayer 

QgsMeshLayer.

Since
QGIS 3.6
VectorTileLayer 

QgsVectorTileLayer.

Since
QGIS 3.14
PointCloudLayer 

QgsPointCloudLayer.

Since
QGIS 3.18
All 

Definition at line 42 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 27 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 140 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 123 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 160 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()
Since
QGIS 3.0

Definition at line 188 of file qgsmaplayerproxymodel.h.

◆ filterAcceptsRow()

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

Definition at line 169 of file qgsmaplayerproxymodel.cpp.

◆ filters()

const Filters& QgsMapLayerProxyModel::filters ( ) const
inline

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

See also
setFilters()
Since
QGIS 2.3

Definition at line 88 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 196 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 144 of file qgsmaplayerproxymodel.h.

◆ layerMatchesFilters()

bool QgsMapLayerProxyModel::layerMatchesFilters ( const QgsMapLayer layer,
const Filters &  filters 
)
static

Returns if the layer matches the given filters.

Since
QGIS 3.14

Definition at line 46 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 132 of file qgsmaplayerproxymodel.h.

◆ lessThan()

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

Definition at line 183 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 109 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 100 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()
Since
QGIS 3.0

Definition at line 134 of file qgsmaplayerproxymodel.cpp.

◆ setFilters()

QgsMapLayerProxyModel * QgsMapLayerProxyModel::setFilters ( QgsMapLayerProxyModel::Filters  filters)

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

See also
filters()
Since
QGIS 2.3

Definition at line 39 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 163 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 91 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 86 of file qgsmaplayerproxymodel.cpp.

◆ sourceLayerModel()

QgsMapLayerModel* QgsMapLayerProxyModel::sourceLayerModel ( ) const
inline

layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel

Definition at line 70 of file qgsmaplayerproxymodel.h.

Property Documentation

◆ exceptedLayerIds

QStringList QgsMapLayerProxyModel::exceptedLayerIds
readwrite

Definition at line 1 of file qgsmaplayerproxymodel.h.

◆ exceptedLayerList

QList<QgsMapLayer *> QgsMapLayerProxyModel::exceptedLayerList
readwrite

Definition at line 1 of file qgsmaplayerproxymodel.h.

◆ filters

QgsMapLayerProxyModel::Filters QgsMapLayerProxyModel::filters
readwrite

Definition at line 1 of file qgsmaplayerproxymodel.h.


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