27 , mRegistryRemovingLayers( false )
29 , mNewLayersVisible( true )
30 , mInsertionPoint( root, 0 )
55 QList<QgsLayerTreeNode *> nodes;
65 if ( !projectFile.isEmpty() )
68 nodeLayer->
setCustomProperty( QStringLiteral(
"embedded_project" ), projectFile );
81 QgsDebugMsgLevel( QStringLiteral(
"%1 layers will be removed, enabled:%2" ).arg( layerIds.count() ).arg(
mEnabled ), 4 );
90 const auto constLayerIds = layerIds;
91 for (
const QString &layerId : constLayerIds )
95 qobject_cast<QgsLayerTreeGroup *>( nodeLayer->
parent() )->removeChildNode( nodeLayer );
102 static void _collectLayerIdsInGroup(
QgsLayerTreeGroup *group,
int indexFrom,
int indexTo, QStringList &lst )
104 for (
int i = indexFrom; i <= indexTo; ++i )
138 QStringList toRemove;
140 for (
const QString &layerId : constMLayerIdsForRemoval )
145 QgsDebugMsgLevel( QStringLiteral(
"%1 layers will be removed" ).arg( toRemove.count() ), 4 );
150 QMetaObject::invokeMethod(
this,
"removeLayersFromRegistry", Qt::QueuedConnection, Q_ARG( QStringList, toRemove ) );
Layer tree group node serves as a container for layers and further groups.
void insertChildNodes(int index, const QList< QgsLayerTreeNode * > &nodes)
Insert existing nodes at specified position.
QgsLayerTreeLayer * findLayer(QgsMapLayer *layer) const
Find layer node representing the map layer.
Layer tree node points to a map layer.
QString layerId() const
Returns the ID for the map layer associated with this node.
This class is a base class for nodes in a layer tree.
void removedChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes has been removed from a node within the tree.
void setCustomProperty(const QString &key, const QVariant &value)
Sets a custom property for the node. Properties are stored in a map and saved in project file.
void willRemoveChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes will be removed from a node within the tree.
QgsLayerTreeNode * parent()
Gets pointer to the parent. If parent is nullptr, the node is a root node.
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
void setItemVisibilityChecked(bool checked)
Check or uncheck a node (independently of its ancestors or children)
void removeLayersFromRegistry(const QStringList &layerIds)
void groupRemovedChildren()
void layersWillBeRemoved(const QStringList &layerIds)
void layersAdded(const QList< QgsMapLayer * > &layers)
QStringList mLayerIdsForRemoval
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 laye...
void groupWillRemoveChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
QgsLayerTreeRegistryBridge(QgsLayerTreeGroup *root, QgsProject *project, QObject *parent=nullptr)
Create the instance that synchronizes given project with a layer tree root.
Q_DECL_DEPRECATED void setLayerInsertionPoint(QgsLayerTreeGroup *parentGroup, int index)
Set where the new layers should be inserted - can be used to follow current selection.
QgsLayerTreeGroup * mRoot
InsertionPoint mInsertionPoint
bool mRegistryRemovingLayers
static bool isLayer(const QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
static QgsLayerTreeLayer * toLayer(QgsLayerTreeNode *node)
Cast node to a layer.
static bool isGroup(QgsLayerTreeNode *node)
Check whether the node is a valid group node.
static QgsLayerTreeGroup * toGroup(QgsLayerTreeNode *node)
Cast node to a group.
Base class for all map layer types.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
void layersWillBeRemoved(const QStringList &layerIds)
Emitted when one or more layers are about to be removed from the registry.
void removeMapLayers(const QStringList &layerIds)
Remove a set of layers from the registry by layer ID.
void legendLayersAdded(const QList< QgsMapLayer * > &layers)
Emitted, when a layer was added to the registry and the legend.
QString layerIsEmbedded(const QString &id) const
Returns the source project file path if the layer with matching id is embedded from other project fil...
#define QgsDebugMsgLevel(str, level)
A structure to define the insertion point to the layer tree.
QgsLayerTreeGroup * group