QGIS API Documentation 3.41.0-Master (88383c3d16f)
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#include <QPointer>
22
23#include "qgis_core.h"
24#include "qgis_sip.h"
25#include "qgis.h"
26#include "qgslayertreegroup.h"
27
29class QgsMapLayer;
30class QgsProject;
31
32
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
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 InsertionPoint layerInsertionPoint() const;
93
98 void setLayerInsertionMethod( Qgis::LayerTreeInsertionMethod method ) { mInsertionMethod = method; }
99
104 Qgis::LayerTreeInsertionMethod layerInsertionMethod() const { return mInsertionMethod; }
105
106 signals:
107
111 void addedLayersToLayerTree( const QList<QgsMapLayer *> &layers );
112
113 protected slots:
114 void layersAdded( const QList<QgsMapLayer *> &layers );
115 void layersWillBeRemoved( const QStringList &layerIds );
116
117 void groupWillRemoveChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
118 void groupRemovedChildren();
119
120 void removeLayersFromRegistry( const QStringList &layerIds );
121
122 protected:
123 QgsLayerTreeGroup *mRoot = nullptr;
124 QgsProject *mProject = nullptr;
129
130 QPointer< QgsLayerTreeGroup > mInsertionPointGroup;
131 int mInsertionPointPosition = 0;
132
134};
135
136#endif // QGSLAYERTREEREGISTRYBRIDGE_H
LayerTreeInsertionMethod
Layer tree insertion methods.
Definition qgis.h:4308
@ 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...
QPointer< QgsLayerTreeGroup > mInsertionPointGroup
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:76
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.