QGIS API Documentation 3.99.0-Master (752b475928d)
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 "qgis.h"
20#include "qgis_core.h"
21#include "qgis_sip.h"
22#include "qgslayertreegroup.h"
23
24#include <QObject>
25#include <QPointer>
26#include <QStringList>
27
29class QgsMapLayer;
30class QgsProject;
31
32
45class CORE_EXPORT QgsLayerTreeRegistryBridge : public QObject
46{
47 Q_OBJECT
48 public:
49
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
99
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 );
119
120 void removeLayersFromRegistry( const QStringList &layerIds );
121
122 protected:
127 bool mEnabled = true;
128 bool mNewLayersVisible = true;
129
130 QPointer< QgsLayerTreeGroup > mInsertionPointGroup;
132
134};
135
136#endif // QGSLAYERTREEREGISTRYBRIDGE_H
LayerTreeInsertionMethod
Layer tree insertion methods.
Definition qgis.h:4522
@ AboveInsertionPoint
Layers are added in the tree above the insertion point.
Definition qgis.h:4523
Layer tree group node serves as a container for layers and further groups.
Base class for nodes in a layer tree.
void removeLayersFromRegistry(const QStringList &layerIds)
void layersWillBeRemoved(const QStringList &layerIds)
void layersAdded(const QList< QgsMapLayer * > &layers)
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)
QPointer< QgsLayerTreeGroup > mInsertionPointGroup
QgsLayerTreeRegistryBridge(QgsLayerTreeGroup *root, QgsProject *project, QObject *parent=nullptr)
Create the instance that synchronizes given project with a layer tree root.
Qgis::LayerTreeInsertionMethod layerInsertionMethod() const
Returns the insertion method used to add layers to the tree.
Qgis::LayerTreeInsertionMethod mInsertionMethod
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:80
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:109
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
InsertionPoint(QgsLayerTreeGroup *group, int position)
Constructs an insertion point as layer tree group with its corresponding position.