QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
28 : QSortFilterProxyModel( parent )
32 setSourceModel( mModel );
33 setDynamicSortFilter(
true );
34 setSortLocaleAware(
true );
35 setFilterCaseSensitivity( Qt::CaseInsensitive );
69 if (
const QgsVectorLayer *vl = qobject_cast<const QgsVectorLayer *>( layer ) )
94 if ( mLayerAllowlist == layers )
97 mLayerAllowlist = layers;
103 if ( mExceptList == exceptList )
106 mExceptList = exceptList;
119 const auto constIds = ids;
120 for (
const QString &
id : constIds )
133 const auto constMExceptList = mExceptList;
142 mExcludedProviders = providers;
151 if ( !mLayerAllowlist.isEmpty() && !mLayerAllowlist.contains( layer ) )
154 if ( mExceptList.contains( layer ) )
163 if ( !layer->
name().contains( mFilterString, Qt::CaseInsensitive ) )
171 mFilterString = filter;
177 if ( mFilters.testFlag(
All ) && mExceptList.isEmpty() && mLayerAllowlist.isEmpty() && mExcludedProviders.isEmpty() && mFilterString.isEmpty() )
180 const QModelIndex index = sourceModel()->index( source_row, 0, source_parent );
201 if ( leftAdditional && !rightAdditional )
203 else if ( rightAdditional && !leftAdditional )
207 const QString leftStr = sourceModel()->data( left ).toString();
208 const QString rightStr = sourceModel()->data( right ).toString();
209 return QString::localeAwareCompare( leftStr, rightStr ) < 0;
void setProject(QgsProject *project)
Sets the project from which map layers are shown.
void setExceptedLayerIds(const QStringList &ids)
Sets a blocklist of layers (by layer ID) to exclude from the model.
@ MeshLayer
Mesh layer. Added in QGIS 3.2.
QStringList exceptedLayerIds
@ VectorLayer
Vector layer.
@ AnnotationLayer
QgsAnnotationLayer.
void setFilterString(const QString &filter)
Sets a filter string, such that only layers with names matching the specified string will be shown.
static bool layerMatchesFilters(const QgsMapLayer *layer, const Filters &filters)
Returns if the layer matches the given filters.
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapLayerProxyModel * setFilters(QgsMapLayerProxyModel::Filters filters)
Sets filter flags which affect how layers are filtered within the model.
void setExcludedProviders(const QStringList &providers)
Sets a blocklist of data providers which should be excluded from the model.
QgsMapLayerProxyModel(QObject *parent=nullptr)
QgsMapLayerProxModel creates a proxy model with a QgsMapLayerModel as source model.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
bool acceptsLayer(QgsMapLayer *layer) const
Returns true if the proxy model accepts the specified map layer.
QString providerType() const
Returns the provider type (provider key) for this layer.
@ VectorTileLayer
QgsVectorTileLayer.
QgsMapLayerProxyModel::Filters filters
virtual Q_INVOKABLE QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widget...
void setLayerAllowlist(const QList< QgsMapLayer * > &layers)
Sets an allowlist of layers to include within the model.
void setProject(QgsProject *project)
Sets the QgsProject from which map layers are shown.
@ RasterLayer
Raster layer.
@ EmptyRole
True if index corresponds to the empty (not set) value.
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
@ PointCloudLayer
QgsPointCloudLayer.
Represents a vector layer which manages a vector based data sets.
Base class for all map layer types. This is the base class for all map layer types (vector,...
bool readOnly() const
Returns if this layer is read only.
@ VectorTileLayer
Vector tile layer. Added in QGIS 3.14.
Q_DECL_DEPRECATED void setLayerWhitelist(const QList< QgsMapLayer * > &layers)
Sets an allowlist of layers to include within the model.
@ AdditionalRole
True if index corresponds to an additional (non map layer) item.
@ PointCloudLayer
Point cloud layer. Added in QGIS 3.18.
void setExceptedLayerList(const QList< QgsMapLayer * > &exceptList)
Sets a blocklist of layers to exclude from the model.
@ PluginLayer
Plugin based layer.
The QgsMapLayerModel class is a model to display layers in widgets.