QGIS API Documentation  2.99.0-Master (b681b7b)
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 
24 class QgsLayerTreeGroup;
25 class QgsLayerTreeNode;
26 class QgsMapLayer;
27 class QgsProject;
28 
29 
42 class CORE_EXPORT QgsLayerTreeRegistryBridge : public QObject
43 {
44  Q_OBJECT
45  public:
47  explicit QgsLayerTreeRegistryBridge( QgsLayerTreeGroup* root, QgsProject* project, QObject *parent = nullptr );
48 
49  void setEnabled( bool enabled ) { mEnabled = enabled; }
50  bool isEnabled() const { return mEnabled; }
51 
52  void setNewLayersVisible( bool enabled ) { mNewLayersVisible = enabled; }
53  bool newLayersVisible() const { return mNewLayersVisible; }
54 
57  void setLayerInsertionPoint( QgsLayerTreeGroup* parentGroup, int index );
58 
59  signals:
62  void addedLayersToLayerTree( const QList<QgsMapLayer*>& layers );
63 
64  protected slots:
65  void layersAdded( const QList<QgsMapLayer*>& layers );
66  void layersWillBeRemoved( const QStringList& layerIds );
67 
68  void groupWillRemoveChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo );
69  void groupRemovedChildren();
70 
71  void removeLayersFromRegistry( const QStringList& layerIds );
72 
73  protected:
74  QgsLayerTreeGroup* mRoot = nullptr;
75  QgsProject* mProject = nullptr;
76  QStringList mLayerIdsForRemoval;
78  bool mEnabled;
80 
81  QgsLayerTreeGroup* mInsertionPointGroup = nullptr;
83 };
84 
85 #endif // QGSLAYERTREEREGISTRYBRIDGE_H
Layer tree group node serves as a container for layers and further groups.
static unsigned index
Base class for all map layer types.
Definition: qgsmaplayer.h:52
Listens to the updates in map layer registry and does changes in layer tree.
This class is a base class for nodes in a layer tree.
Reads and writes project states.
Definition: qgsproject.h:74