QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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, All = RasterLayer | VectorLayer | PluginLayer
}
 

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...
 
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

Enumerator
RasterLayer 
NoGeometry 
PointLayer 
LineLayer 
PolygonLayer 
HasGeometry 
VectorLayer 
PluginLayer 
WritableLayer 
All 

Definition at line 42 of file qgsmaplayerproxymodel.h.

Constructor & Destructor Documentation

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 25 of file qgsmaplayerproxymodel.cpp.

Member Function Documentation

QStringList QgsMapLayerProxyModel::exceptedLayerIds ( ) const

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

See also
setExceptedLayerIds()
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 126 of file qgsmaplayerproxymodel.h.

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 154 of file qgsmaplayerproxymodel.h.

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

Definition at line 97 of file qgsmaplayerproxymodel.cpp.

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 85 of file qgsmaplayerproxymodel.h.

QString QgsMapLayerProxyModel::filterString ( ) const
inline

Returns the current filter string, if set.

See also
setFilterString()
Since
QGIS 3.4

Definition at line 162 of file qgsmaplayerproxymodel.h.

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 110 of file qgsmaplayerproxymodel.h.

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

Definition at line 159 of file qgsmaplayerproxymodel.cpp.

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 62 of file qgsmaplayerproxymodel.cpp.

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 53 of file qgsmaplayerproxymodel.cpp.

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 85 of file qgsmaplayerproxymodel.cpp.

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 37 of file qgsmaplayerproxymodel.cpp.

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 91 of file qgsmaplayerproxymodel.cpp.

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 44 of file qgsmaplayerproxymodel.cpp.

QgsMapLayerModel* QgsMapLayerProxyModel::sourceLayerModel ( ) const
inline

layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel

Definition at line 67 of file qgsmaplayerproxymodel.h.

Property Documentation

QStringList QgsMapLayerProxyModel::exceptedLayerIds
readwrite

Definition at line 39 of file qgsmaplayerproxymodel.h.

QList<QgsMapLayer *> QgsMapLayerProxyModel::exceptedLayerList
readwrite

Definition at line 38 of file qgsmaplayerproxymodel.h.

QgsMapLayerProxyModel::Filters QgsMapLayerProxyModel::filters
readwrite

Definition at line 37 of file qgsmaplayerproxymodel.h.


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