26 : QSortFilterProxyModel( parent )
31 setSourceModel( mModel );
32 setDynamicSortFilter(
true );
33 setSortLocaleAware(
true );
34 setFilterCaseSensitivity( Qt::CaseInsensitive );
47 if ( mExceptList == exceptList )
50 mExceptList = exceptList;
58 Q_FOREACH (
const QString &
id, ids )
79 mExcludedProviders = providers;
85 if ( mFilters.testFlag(
All ) && mExceptList.isEmpty() && mExcludedProviders.isEmpty() )
88 QModelIndex index = sourceModel()->index( source_row, 0, source_parent );
98 if ( mExceptList.contains( layer ) )
114 bool detectGeometry = mFilters.testFlag(
NoGeometry ) ||
121 if (
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer *>( layer ) )
123 if ( mFilters.testFlag(
HasGeometry ) && vl->isSpatial() )
151 if ( leftAdditional && !rightAdditional )
153 else if ( rightAdditional && !leftAdditional )
157 QString leftStr = sourceModel()->data( left ).toString();
158 QString rightStr = sourceModel()->data( right ).toString();
159 return QString::localeAwareCompare( leftStr, rightStr ) < 0;
QgsMapLayerProxyModel(QObject *parent=nullptr)
QgsMapLayerProxModel creates a proxy model with a QgsMapLayerModel as source model.
Base class for all map layer types.
virtual QgsDataProvider * dataProvider()
Returns the layer's data provider.
QStringList exceptedLayerIds() const
Gets the list of maplayer ids which are excluded from the list.
void setExceptedLayerIds(const QStringList &ids)
Sets the list of maplayer ids which are excluded from the list.
QgsMapLayer::LayerType type() const
Returns the type of the layer.
virtual QString name() const =0
Returns a provider name.
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
True if index corresponds to an additional (non map layer) item.
void setExceptedLayerList(const QList< QgsMapLayer *> &exceptList)
offer the possibility to except some layers to be listed
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
The QgsMapLayerModel class is a model to display layers in widgets.
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widget...
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
void setExcludedProviders(const QStringList &providers)
Sets a list of data providers which should be excluded from the model.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapLayerProxyModel * setFilters(QgsMapLayerProxyModel::Filters filters)
setFilters set flags that affect how layers are filtered
const Filters & filters() const
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
bool readOnly() const
Returns if this layer is read only.
Represents a vector layer which manages a vector based data sets.
True if index corresponds to the empty (not set) value.