QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgslayertreeregistrybridge.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayertreeregistrybridge.h
3 --------------------------------------
4 Date : May 2014
5 Copyright : (C) 2014 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSLAYERTREEREGISTRYBRIDGE_H
17#define QGSLAYERTREEREGISTRYBRIDGE_H
18
19#include <QObject>
20#include <QStringList>
21
22#include "qgis_core.h"
23#include "qgis_sip.h"
24#include "qgis.h"
25
28class QgsMapLayer;
29class QgsProject;
30
31
45class CORE_EXPORT QgsLayerTreeRegistryBridge : public QObject
46{
47 Q_OBJECT
48 public:
49
56 {
58 InsertionPoint( QgsLayerTreeGroup *group, int position )
59 : group( group ), position( position ) {}
60
61 QgsLayerTreeGroup *group = nullptr;
62 int position = 0;
63 };
64
66 explicit QgsLayerTreeRegistryBridge( QgsLayerTreeGroup *root, QgsProject *project, QObject *parent SIP_TRANSFERTHIS = nullptr );
67
68 void setEnabled( bool enabled ) { mEnabled = enabled; }
69 bool isEnabled() const { return mEnabled; }
70
71 void setNewLayersVisible( bool enabled ) { mNewLayersVisible = enabled; }
72 bool newLayersVisible() const { return mNewLayersVisible; }
73
79 Q_DECL_DEPRECATED void setLayerInsertionPoint( QgsLayerTreeGroup *parentGroup, int index ) SIP_DEPRECATED;
80
86 void setLayerInsertionPoint( const InsertionPoint &insertionPoint );
87
92 void setLayerInsertionMethod( Qgis::LayerTreeInsertionMethod method ) { mInsertionMethod = method; }
93
98 Qgis::LayerTreeInsertionMethod layerInsertionMethod() const { return mInsertionMethod; }
99
100 signals:
101
106 void addedLayersToLayerTree( const QList<QgsMapLayer *> &layers );
107
108 protected slots:
109 void layersAdded( const QList<QgsMapLayer *> &layers );
110 void layersWillBeRemoved( const QStringList &layerIds );
111
112 void groupWillRemoveChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
113 void groupRemovedChildren();
114
115 void removeLayersFromRegistry( const QStringList &layerIds );
116
117 protected:
118 QgsLayerTreeGroup *mRoot = nullptr;
119 QgsProject *mProject = nullptr;
124
127};
128
129#endif // QGSLAYERTREEREGISTRYBRIDGE_H
LayerTreeInsertionMethod
Script language capabilities.
Definition qgis.h:3150
@ AboveInsertionPoint
Layers are added in the tree above the insertion point.
Layer tree group node serves as a container for layers and further groups.
This class is a base class for nodes in a layer tree.
Listens to the updates in map layer registry and does changes in layer tree.
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...
Qgis::LayerTreeInsertionMethod layerInsertionMethod() const
Returns the insertion method used to add layers to the tree.
void setLayerInsertionMethod(Qgis::LayerTreeInsertionMethod method)
Sets the insertion method used to add layers to the tree.
Base class for all map layer types.
Definition qgsmaplayer.h:74
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
A structure to define the insertion point to the layer tree.
InsertionPoint(QgsLayerTreeGroup *group, int position)
Constructs an insertion point as layer tree group with its corresponding position.