QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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
44class CORE_EXPORT QgsLayerTreeRegistryBridge : public QObject
45{
46 Q_OBJECT
47 public:
48
55 {
57 InsertionPoint( QgsLayerTreeGroup *group, int position )
58 : group( group ), position( position ) {}
59
60 QgsLayerTreeGroup *group = nullptr;
61 int position = 0;
62 };
63
65 explicit QgsLayerTreeRegistryBridge( QgsLayerTreeGroup *root, QgsProject *project, QObject *parent SIP_TRANSFERTHIS = nullptr );
66
67 void setEnabled( bool enabled ) { mEnabled = enabled; }
68 bool isEnabled() const { return mEnabled; }
69
70 void setNewLayersVisible( bool enabled ) { mNewLayersVisible = enabled; }
71 bool newLayersVisible() const { return mNewLayersVisible; }
72
78 Q_DECL_DEPRECATED void setLayerInsertionPoint( QgsLayerTreeGroup *parentGroup, int index ) SIP_DEPRECATED;
79
85 void setLayerInsertionPoint( const InsertionPoint &insertionPoint );
86
91 void setLayerInsertionMethod( Qgis::LayerTreeInsertionMethod method ) { mInsertionMethod = method; }
92
97 Qgis::LayerTreeInsertionMethod layerInsertionMethod() const { return mInsertionMethod; }
98
99 signals:
100
104 void addedLayersToLayerTree( const QList<QgsMapLayer *> &layers );
105
106 protected slots:
107 void layersAdded( const QList<QgsMapLayer *> &layers );
108 void layersWillBeRemoved( const QStringList &layerIds );
109
110 void groupWillRemoveChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
111 void groupRemovedChildren();
112
113 void removeLayersFromRegistry( const QStringList &layerIds );
114
115 protected:
116 QgsLayerTreeGroup *mRoot = nullptr;
117 QgsProject *mProject = nullptr;
122
125};
126
127#endif // QGSLAYERTREEREGISTRYBRIDGE_H
LayerTreeInsertionMethod
Layer tree insertion methods.
Definition qgis.h:4217
@ 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: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.