QgsMapLayerProxyModel class
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widgets.
Contents
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 }
Constructors, destructors, conversion operators
- QgsMapLayerProxyModel(QObject* parent = nullptr) explicit
- QgsMapLayerProxModel creates a proxy model with a QgsMapLayerModel as source model.
Public functions
- auto exceptedLayerIds() const -> QStringList
- Returns the blacklist of layer IDs which are excluded from the model.
- auto exceptedLayerList() -> QList<QgsMapLayer*>
- Returns the blacklist of layers which are excluded from the model.
- auto excludedProviders() const -> QStringList
- Returns the blacklist of data providers which are excluded from the model.
- auto filters() const -> const Filters&
- Returns the filter flags which affect how layers are filtered within the model.
- auto filterString() const -> QString
- Returns the current filter string, if set.
- auto layerWhitelist() -> QList<QgsMapLayer*>
- Returns the list of layers which are excluded from the model.
- void setExceptedLayerIds(const QStringList& ids)
- Sets a blacklist of layers (by layer ID) to exclude from the model.
- void setExceptedLayerList(const QList<QgsMapLayer*>& exceptList)
- Sets a blacklist of layers to exclude from the model.
- void setExcludedProviders(const QStringList& providers)
- Sets a blacklist of data providers which should be excluded from the model.
- auto setFilters(QgsMapLayerProxyModel::Filters filters) -> QgsMapLayerProxyModel*
- Sets filter flags which affect how layers are filtered within the model.
- void setLayerWhitelist(const QList<QgsMapLayer*>& layers)
- Sets a whitelist of layers to include within the model.
- auto sourceLayerModel() const -> QgsMapLayerModel*
- layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel
Public slots
- void setFilterString(const QString& filter)
- Sets a filter string, such that only layers with names matching the specified string will be shown.
Enum documentation
enum QgsMapLayerProxyModel:: Filter
| Enumerators | |
|---|---|
| RasterLayer | |
| NoGeometry | |
| PointLayer | |
| LineLayer | |
| PolygonLayer | |
| HasGeometry | |
| VectorLayer | |
| PluginLayer | |
| WritableLayer | |
| MeshLayer | |
| All |
Function 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.
QStringList QgsMapLayerProxyModel:: exceptedLayerIds() const
Returns the blacklist of layer IDs which are excluded from the model.
QList<QgsMapLayer*> QgsMapLayerProxyModel:: exceptedLayerList()
Returns the blacklist of layers which are excluded from the model.
QStringList QgsMapLayerProxyModel:: excludedProviders() const
Returns the blacklist of data providers which are excluded from the model.
const Filters& QgsMapLayerProxyModel:: filters() const
Returns the filter flags which affect how layers are filtered within the model.
QString QgsMapLayerProxyModel:: filterString() const
Returns the current filter string, if set.
QList<QgsMapLayer*> QgsMapLayerProxyModel:: layerWhitelist()
Returns the list of layers which are excluded from the model.
An empty list indicates that no whitelisting should be performed.
void QgsMapLayerProxyModel:: setExceptedLayerIds(const QStringList& ids)
Sets a blacklist of layers (by layer ID) to exclude from the model.
void QgsMapLayerProxyModel:: setExceptedLayerList(const QList<QgsMapLayer*>& exceptList)
Sets a blacklist of layers to exclude from the model.
void QgsMapLayerProxyModel:: setExcludedProviders(const QStringList& providers)
Sets a blacklist of data providers which should be excluded from the model.
QgsMapLayerProxyModel* QgsMapLayerProxyModel:: setFilters(QgsMapLayerProxyModel::Filters filters)
Sets filter flags which affect how layers are filtered within the model.
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.
void QgsMapLayerProxyModel:: setFilterString(const QString& filter) public slot
Sets a filter string, such that only layers with names matching the specified string will be shown.