QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
Internal structure to keep weak pointer to QgsMapLayer or layerId if the layer is not available yet. More...
#include <qgsmaplayerref.h>
Public Types | |
enum | MatchType { Name = 1 << 2 , Provider = 1 << 3 , Source = 1 << 4 , All = Provider | Source } |
Flag for match type in weak resolution. More... | |
Public Member Functions | |
_LayerRef (const QString &id, const QString &name=QString(), const QString &source=QString(), const QString &provider=QString()) | |
Constructor for a weak layer reference, using a combination of layer ID, name, public source and provider key. More... | |
_LayerRef (TYPE *l=nullptr) | |
Constructor for a layer reference from an existing map layer. More... | |
TYPE * | get () const |
Returns a pointer to the layer, or nullptr if the reference has not yet been matched to a layer. More... | |
bool | layerMatchesSource (QgsMapLayer *layer) const |
Returns true if a layer matches the weak references to layer public source, layer name and data provider contained in this layer reference. More... | |
bool | layerMatchesWeakly (QgsMapLayer *layer, MatchType matchType=MatchType::All) |
operator bool () const | |
Returns true if the layer reference is resolved and contains a reference to an existing map layer. More... | |
TYPE * | operator-> () const |
Forwards the to map layer. More... | |
TYPE * | resolve (const QgsProject *project) |
Resolves the map layer by attempting to find a layer with matching ID within a project. More... | |
TYPE * | resolveByIdOrNameOnly (const QgsProject *project) |
Resolves the map layer by attempting to find a matching layer in a project using a weak match. More... | |
TYPE * | resolveWeakly (const QgsProject *project, MatchType matchType=MatchType::All) |
Resolves the map layer by attempting to find a matching layer in a project using a weak match. More... | |
void | setLayer (TYPE *l) |
Sets the reference to point to a specified layer. More... | |
Public Attributes | |
QPointer< TYPE > | layer |
Weak pointer to map layer. More... | |
QString | layerId |
Original layer ID. More... | |
QString | name |
Weak reference to layer name. More... | |
QString | provider |
Weak reference to layer provider. More... | |
QString | source |
Weak reference to layer public source. More... | |
Internal structure to keep weak pointer to QgsMapLayer or layerId if the layer is not available yet.
Definition at line 34 of file qgsmaplayerref.h.
enum _LayerRef::MatchType |
Flag for match type in weak resolution.
Enumerator | |
---|---|
Name | |
Provider | Match layer name. |
Source | Match layer provider name. |
All | Match layer source. Match all |
Definition at line 41 of file qgsmaplayerref.h.
Constructor for a layer reference from an existing map layer.
The layerId, source, name and provider members will automatically be populated from this layer.
Definition at line 55 of file qgsmaplayerref.h.
|
inline |
Constructor for a weak layer reference, using a combination of layer ID, name, public source and provider key.
Definition at line 67 of file qgsmaplayerref.h.
|
inline |
Returns a pointer to the layer, or nullptr
if the reference has not yet been matched to a layer.
Definition at line 108 of file qgsmaplayerref.h.
|
inline |
Returns true
if a layer matches the weak references to layer public source, layer name and data provider contained in this layer reference.
Definition at line 131 of file qgsmaplayerref.h.
|
inline |
Definition at line 163 of file qgsmaplayerref.h.
|
inline |
Returns true
if the layer reference is resolved and contains a reference to an existing map layer.
Definition at line 91 of file qgsmaplayerref.h.
|
inline |
Forwards the to map layer.
Definition at line 99 of file qgsmaplayerref.h.
|
inline |
Resolves the map layer by attempting to find a layer with matching ID within a project.
If found, this reference will be updated to match the found layer and the layer will be returned. If no matching layer is found, nullptr
is returned.
Definition at line 150 of file qgsmaplayerref.h.
|
inline |
Resolves the map layer by attempting to find a matching layer in a project using a weak match.
First, the layer is attempted to match to project layers using the layer's ID (calling this method implicitly calls resolve()).
Failing a match by layer ID, the layer will be matched by using the weak references to layer public source, layer name and data provider contained in this layer reference.
Failing a match by weak reference, the layer will be matched by using the name only.
If a matching layer is found, this reference will be updated to match the found layer and the layer will be returned. If no matching layer is found, nullptr
is returned.
Definition at line 270 of file qgsmaplayerref.h.
|
inline |
Resolves the map layer by attempting to find a matching layer in a project using a weak match.
First, the layer is attempted to match to project layers using the layer's ID (calling this method implicitly calls resolve()).
Failing a match by layer ID, the layer will be matched by using the weak references to layer public source, layer name and data provider contained in this layer reference.
The matchType enum can used to refine the matching criteria when using the weak reference and include layer name, provider name and layer source in the equality test, by default they are all checked.
If a matching layer is found, this reference will be updated to match the found layer and the layer will be returned. If no matching layer is found, nullptr
is returned.
Definition at line 211 of file qgsmaplayerref.h.
|
inline |
Sets the reference to point to a specified layer.
Definition at line 78 of file qgsmaplayerref.h.
QPointer<TYPE> _LayerRef< TYPE >::layer |
Weak pointer to map layer.
Definition at line 114 of file qgsmaplayerref.h.
QString _LayerRef< TYPE >::layerId |
Original layer ID.
Definition at line 117 of file qgsmaplayerref.h.
QString _LayerRef< TYPE >::name |
Weak reference to layer name.
Definition at line 122 of file qgsmaplayerref.h.
QString _LayerRef< TYPE >::provider |
Weak reference to layer provider.
Definition at line 124 of file qgsmaplayerref.h.
QString _LayerRef< TYPE >::source |
Weak reference to layer public source.
Definition at line 120 of file qgsmaplayerref.h.