QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
Public Types | Public Slots | 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, All = RasterLayer | VectorLayer | PluginLayer | MeshLayer
}
 

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 blacklist of layer IDs which are excluded from the model. More...
 
QList< QgsMapLayer * > exceptedLayerList ()
 Returns the blacklist of layers which are excluded from the model. More...
 
QStringList excludedProviders () const
 Returns the blacklist 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 * > 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 blacklist of layers (by layer ID) to exclude from the model. More...
 
void setExceptedLayerList (const QList< QgsMapLayer *> &exceptList)
 Sets a blacklist of layers to exclude from the model. More...
 
void setExcludedProviders (const QStringList &providers)
 Sets a blacklist 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 setLayerWhitelist (const QList< QgsMapLayer *> &layers)
 Sets a whitelist of layers to include within the model. More...
 
QgsMapLayerModelsourceLayerModel () const
 layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel 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
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 95 of file qgsmaplayerproxymodel.cpp.

◆ exceptedLayerIds()

QStringList QgsMapLayerProxyModel::exceptedLayerIds ( ) const

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

See also
setExceptedLayerIds()
exceptedLayerList()

◆ exceptedLayerList()

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

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

See also
setExceptedLayerList()
exceptedLayerIds()
layerWhitelist()

Definition at line 127 of file qgsmaplayerproxymodel.h.

◆ excludedProviders()

QStringList QgsMapLayerProxyModel::excludedProviders ( ) const
inline

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

See also
setExcludedProviders()
Since
QGIS 3.0

Definition at line 155 of file qgsmaplayerproxymodel.h.

◆ filterAcceptsRow()

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

Definition at line 154 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 86 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 163 of file qgsmaplayerproxymodel.h.

◆ layerWhitelist()

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

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

An empty list indicates that no whitelisting should be performed.

See also
setLayerWhitelist()
exceptedLayerList()
Since
QGIS 3.4

Definition at line 111 of file qgsmaplayerproxymodel.h.

◆ lessThan()

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

Definition at line 168 of file qgsmaplayerproxymodel.cpp.

◆ setExceptedLayerIds()

void QgsMapLayerProxyModel::setExceptedLayerIds ( const QStringList &  ids)

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

See also
exceptedLayerIds()
setExceptedLayerList()

Definition at line 64 of file qgsmaplayerproxymodel.cpp.

◆ setExceptedLayerList()

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

Sets a blacklist of layers to exclude from the model.

See also
exceptedLayerList()
setExceptedLayerIds()
setLayerWhitelist()

Definition at line 55 of file qgsmaplayerproxymodel.cpp.

◆ setExcludedProviders()

void QgsMapLayerProxyModel::setExcludedProviders ( const QStringList &  providers)

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

See also
excludedProviders()
Since
QGIS 3.0

Definition at line 89 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 148 of file qgsmaplayerproxymodel.cpp.

◆ setLayerWhitelist()

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

Sets a whitelist of layers to include within the model.

Only layers from this list will be shown.

An empty list indicates that no whitelisting should be performed.

See also
layerWhitelist()
setExceptedLayerList()
Since
QGIS 3.4

Definition at line 46 of file qgsmaplayerproxymodel.cpp.

◆ sourceLayerModel()

QgsMapLayerModel* QgsMapLayerProxyModel::sourceLayerModel ( ) const
inline

layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel

Definition at line 68 of file qgsmaplayerproxymodel.h.

Property Documentation

◆ exceptedLayerIds

QStringList QgsMapLayerProxyModel::exceptedLayerIds
readwrite

Definition at line 39 of file qgsmaplayerproxymodel.h.

◆ exceptedLayerList

QList<QgsMapLayer *> QgsMapLayerProxyModel::exceptedLayerList
readwrite

Definition at line 38 of file qgsmaplayerproxymodel.h.

◆ filters

QgsMapLayerProxyModel::Filters QgsMapLayerProxyModel::filters
readwrite

Definition at line 37 of file qgsmaplayerproxymodel.h.


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