QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
QgsLayerTreeRegistryBridge Class Reference

Listens to layer changes from a QgsProject and applies changes to a QgsLayerTree. More...

#include <qgslayertreeregistrybridge.h>

Inheritance diagram for QgsLayerTreeRegistryBridge:

Classes

struct  InsertionPoint
 A structure to define the insertion point to the layer tree. More...

Signals

void addedLayersToLayerTree (const QList< QgsMapLayer * > &layers)
 Tell others we have just added layers to the tree (used in QGIS to auto-select first newly added layer).

Public Member Functions

 QgsLayerTreeRegistryBridge (QgsLayerTreeGroup *root, QgsProject *project, QObject *parent=nullptr)
 Create the instance that synchronizes given project with a layer tree root.
bool isEnabled () const
Qgis::LayerTreeInsertionMethod layerInsertionMethod () const
 Returns the insertion method used to add layers to the tree.
InsertionPoint layerInsertionPoint () const
 Returns the insertion point used to add layers to the tree.
bool newLayersVisible () const
void setEnabled (bool enabled)
void setLayerInsertionMethod (Qgis::LayerTreeInsertionMethod method)
 Sets the insertion method used to add layers to the tree.
void setLayerInsertionPoint (const InsertionPoint &insertionPoint)
 Set where the new layers should be inserted - can be used to follow current selection.
Q_DECL_DEPRECATED void setLayerInsertionPoint (QgsLayerTreeGroup *parentGroup, int index)
 Set where the new layers should be inserted - can be used to follow current selection.
void setNewLayersVisible (bool enabled)

Protected Slots

void groupRemovedChildren ()
void groupWillRemoveChildren (QgsLayerTreeNode *node, int indexFrom, int indexTo)
void layersAdded (const QList< QgsMapLayer * > &layers)
void layersWillBeRemoved (const QStringList &layerIds)
void removeLayersFromRegistry (const QStringList &layerIds)

Protected Attributes

bool mEnabled = true
Qgis::LayerTreeInsertionMethod mInsertionMethod = Qgis::LayerTreeInsertionMethod::AboveInsertionPoint
QPointer< QgsLayerTreeGroupmInsertionPointGroup
int mInsertionPointPosition = 0
QStringList mLayerIdsForRemoval
bool mNewLayersVisible = true
QgsProjectmProject = nullptr
bool mRegistryRemovingLayers = false
QgsLayerTreeGroupmRoot = nullptr

Detailed Description

Listens to layer changes from a QgsProject and applies changes to a QgsLayerTree.

When connected to a layer tree, any layers added to the map layer registry will be also added to the layer tree. Similarly, map layers that are removed from registry will be removed from the layer tree.

If a layer is completely removed from the layer tree, it will be also removed from the map layer registry.

Definition at line 45 of file qgslayertreeregistrybridge.h.

Constructor & Destructor Documentation

◆ QgsLayerTreeRegistryBridge()

QgsLayerTreeRegistryBridge::QgsLayerTreeRegistryBridge ( QgsLayerTreeGroup * root,
QgsProject * project,
QObject * parent = nullptr )
explicit

Create the instance that synchronizes given project with a layer tree root.

Definition at line 25 of file qgslayertreeregistrybridge.cpp.

Member Function Documentation

◆ addedLayersToLayerTree

void QgsLayerTreeRegistryBridge::addedLayersToLayerTree ( const QList< QgsMapLayer * > & layers)
signal

Tell others we have just added layers to the tree (used in QGIS to auto-select first newly added layer).

◆ groupRemovedChildren

void QgsLayerTreeRegistryBridge::groupRemovedChildren ( )
protectedslot

Definition at line 174 of file qgslayertreeregistrybridge.cpp.

◆ groupWillRemoveChildren

void QgsLayerTreeRegistryBridge::groupWillRemoveChildren ( QgsLayerTreeNode * node,
int indexFrom,
int indexTo )
protectedslot

Definition at line 161 of file qgslayertreeregistrybridge.cpp.

◆ isEnabled()

bool QgsLayerTreeRegistryBridge::isEnabled ( ) const
inline

Definition at line 69 of file qgslayertreeregistrybridge.h.

◆ layerInsertionMethod()

Qgis::LayerTreeInsertionMethod QgsLayerTreeRegistryBridge::layerInsertionMethod ( ) const
inline

Returns the insertion method used to add layers to the tree.

Since
QGIS 3.30

Definition at line 104 of file qgslayertreeregistrybridge.h.

◆ layerInsertionPoint()

QgsLayerTreeRegistryBridge::InsertionPoint QgsLayerTreeRegistryBridge::layerInsertionPoint ( ) const

Returns the insertion point used to add layers to the tree.

Since
QGIS 3.42

Definition at line 50 of file qgslayertreeregistrybridge.cpp.

◆ layersAdded

void QgsLayerTreeRegistryBridge::layersAdded ( const QList< QgsMapLayer * > & layers)
protectedslot

Definition at line 56 of file qgslayertreeregistrybridge.cpp.

◆ layersWillBeRemoved

void QgsLayerTreeRegistryBridge::layersWillBeRemoved ( const QStringList & layerIds)
protectedslot

Definition at line 122 of file qgslayertreeregistrybridge.cpp.

◆ newLayersVisible()

bool QgsLayerTreeRegistryBridge::newLayersVisible ( ) const
inline

Definition at line 72 of file qgslayertreeregistrybridge.h.

◆ removeLayersFromRegistry

void QgsLayerTreeRegistryBridge::removeLayersFromRegistry ( const QStringList & layerIds)
protectedslot

Definition at line 196 of file qgslayertreeregistrybridge.cpp.

◆ setEnabled()

void QgsLayerTreeRegistryBridge::setEnabled ( bool enabled)
inline

Definition at line 68 of file qgslayertreeregistrybridge.h.

◆ setLayerInsertionMethod()

void QgsLayerTreeRegistryBridge::setLayerInsertionMethod ( Qgis::LayerTreeInsertionMethod method)
inline

Sets the insertion method used to add layers to the tree.

Since
QGIS 3.30

Definition at line 98 of file qgslayertreeregistrybridge.h.

◆ setLayerInsertionPoint() [1/2]

void QgsLayerTreeRegistryBridge::setLayerInsertionPoint ( const InsertionPoint & insertionPoint)

Set where the new layers should be inserted - can be used to follow current selection.

By default it is root group with zero index.

Since
QGIS 3.10

Definition at line 44 of file qgslayertreeregistrybridge.cpp.

◆ setLayerInsertionPoint() [2/2]

void QgsLayerTreeRegistryBridge::setLayerInsertionPoint ( QgsLayerTreeGroup * parentGroup,
int index )

Set where the new layers should be inserted - can be used to follow current selection.

By default it is root group with zero index.

Deprecated
QGIS 3.10. Use setLayerInsertionPoint( const InsertionPoint &insertionPoint ) instead.

Definition at line 38 of file qgslayertreeregistrybridge.cpp.

◆ setNewLayersVisible()

void QgsLayerTreeRegistryBridge::setNewLayersVisible ( bool enabled)
inline

Definition at line 71 of file qgslayertreeregistrybridge.h.

Member Data Documentation

◆ mEnabled

bool QgsLayerTreeRegistryBridge::mEnabled = true
protected

Definition at line 127 of file qgslayertreeregistrybridge.h.

◆ mInsertionMethod

Qgis::LayerTreeInsertionMethod QgsLayerTreeRegistryBridge::mInsertionMethod = Qgis::LayerTreeInsertionMethod::AboveInsertionPoint
protected

Definition at line 133 of file qgslayertreeregistrybridge.h.

◆ mInsertionPointGroup

QPointer< QgsLayerTreeGroup > QgsLayerTreeRegistryBridge::mInsertionPointGroup
protected

Definition at line 130 of file qgslayertreeregistrybridge.h.

◆ mInsertionPointPosition

int QgsLayerTreeRegistryBridge::mInsertionPointPosition = 0
protected

Definition at line 131 of file qgslayertreeregistrybridge.h.

◆ mLayerIdsForRemoval

QStringList QgsLayerTreeRegistryBridge::mLayerIdsForRemoval
protected

Definition at line 125 of file qgslayertreeregistrybridge.h.

◆ mNewLayersVisible

bool QgsLayerTreeRegistryBridge::mNewLayersVisible = true
protected

Definition at line 128 of file qgslayertreeregistrybridge.h.

◆ mProject

QgsProject* QgsLayerTreeRegistryBridge::mProject = nullptr
protected

Definition at line 124 of file qgslayertreeregistrybridge.h.

◆ mRegistryRemovingLayers

bool QgsLayerTreeRegistryBridge::mRegistryRemovingLayers = false
protected

Definition at line 126 of file qgslayertreeregistrybridge.h.

◆ mRoot

QgsLayerTreeGroup* QgsLayerTreeRegistryBridge::mRoot = nullptr
protected

Definition at line 123 of file qgslayertreeregistrybridge.h.


The documentation for this class was generated from the following files: