15#ifndef QGSMAPLAYERLISTUTILS_H
16#define QGSMAPLAYERLISTUTILS_H
36 QList<QgsMapLayer *> lst;
37 lst.reserve( layers.count() );
41 lst.append( layerPtr.data() );
49 lst.reserve( layers.count() );
57inline QList<QgsMapLayer *> _qgis_listRefToRaw(
const QList< QgsMapLayerRef > &layers )
59 QList<QgsMapLayer *> lst;
60 lst.reserve( layers.count() );
64 lst.append( layer.get() );
69inline QList< QgsMapLayerRef > _qgis_listRawToRef(
const QList<QgsMapLayer *> &layers )
71 QList< QgsMapLayerRef > lst;
72 lst.reserve( layers.count() );
80inline void _qgis_removeLayers( QList< QgsMapLayerRef > &list,
const QList< QgsMapLayer *> &layersToRemove )
82 QMutableListIterator<QgsMapLayerRef> it( list );
83 while ( it.hasNext() )
86 if ( layersToRemove.contains( ref.
get() ) )
94 lst.reserve( layers.count() );
98 lst << layerPtr->
id();
103inline static QgsMapLayer *_qgis_findLayer(
const QList< QgsMapLayer *> &layers,
const QString &identifier )
112 if ( !matchId && layer->id() == identifier )
117 if ( !matchName && layer->name() == identifier )
121 if ( !matchNameInsensitive && QString::compare( layer->name(), identifier, Qt::CaseInsensitive ) == 0 )
123 matchNameInsensitive = layer;
131 else if ( matchName )
135 else if ( matchNameInsensitive )
137 return matchNameInsensitive;
147 return qHash( key ? key->id() : QString() );
Base class for all map layer types.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
uint qHash(const QVariant &variant)
Hash for QVariant.
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList
A list of weak pointers to QgsMapLayers.
_LayerRef< QgsMapLayer > QgsMapLayerRef
TYPE * get() const
Returns a pointer to the layer, or nullptr if the reference has not yet been matched to a layer.