QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
27 , mRegistryRemovingLayers( false )
29 , mNewLayersVisible( true )
30 , mInsertionPoint( root, 0 )
55 QList<QgsLayerTreeNode *> nodes;
65 if ( !projectFile.isEmpty() )
67 nodeLayer->setCustomProperty( QStringLiteral(
"embedded" ), 1 );
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 ) );
QgsLayerTreeLayer * findLayer(QgsMapLayer *layer) const
Find layer node representing the map layer.
QgsLayerTreeRegistryBridge(QgsLayerTreeGroup *root, QgsProject *project, QObject *parent=nullptr)
Create the instance that synchronizes given project with a layer tree root.
A structure to define the insertion point to the layer tree.
This class is a base class for nodes in a layer tree.
void layersWillBeRemoved(const QStringList &layerIds)
Emitted when one or more layers are about to be removed from the registry.
void setItemVisibilityChecked(bool checked)
Check or uncheck a node (independently of its ancestors or children)
void removedChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes has been removed from a node within the tree.
void removeLayersFromRegistry(const QStringList &layerIds)
#define QgsDebugMsgLevel(str, level)
QString layerId() const
Returns the ID for the map layer associated with this node.
void groupWillRemoveChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
static QgsLayerTreeLayer * toLayer(QgsLayerTreeNode *node)
Cast node to a layer.
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 removeMapLayers(const QStringList &layerIds)
Remove a set of layers from the registry by layer ID.
static QgsLayerTreeGroup * toGroup(QgsLayerTreeNode *node)
Cast node to a group.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QStringList mLayerIdsForRemoval
void layersWillBeRemoved(const QStringList &layerIds)
bool mRegistryRemovingLayers
Layer tree node points to a map layer.
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.
QgsLayerTreeGroup * mRoot
void legendLayersAdded(const QList< QgsMapLayer * > &layers)
Emitted, when a layer was added to the registry and the legend.
static bool isLayer(const QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
InsertionPoint mInsertionPoint
QString layerIsEmbedded(const QString &id) const
Returns the source project file path if the layer with matching id is embedded from other project fil...
Base class for all map layer types. This is the base class for all map layer types (vector,...
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
void groupRemovedChildren()
QgsLayerTreeGroup * group
Q_DECL_DEPRECATED void setLayerInsertionPoint(QgsLayerTreeGroup *parentGroup, int index)
Set where the new layers should be inserted - can be used to follow current selection.
QgsLayerTreeNode * parent()
Gets pointer to the parent. If parent is nullptr, the node is a root node.
void willRemoveChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes will be removed from a node within the tree.
static bool isGroup(QgsLayerTreeNode *node)
Check whether the node is a valid group node.
void layersAdded(const QList< QgsMapLayer * > &layers)