QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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.h"
24 
25 class QgsLayerTreeGroup;
26 class QgsLayerTreeNode;
27 class QgsMapLayer;
28 class QgsProject;
29 
30 
44 class CORE_EXPORT QgsLayerTreeRegistryBridge : public QObject
45 {
46  Q_OBJECT
47  public:
49  explicit QgsLayerTreeRegistryBridge( QgsLayerTreeGroup *root, QgsProject *project, QObject *parent SIP_TRANSFERTHIS = nullptr );
50 
51  void setEnabled( bool enabled ) { mEnabled = enabled; }
52  bool isEnabled() const { return mEnabled; }
53 
54  void setNewLayersVisible( bool enabled ) { mNewLayersVisible = enabled; }
55  bool newLayersVisible() const { return mNewLayersVisible; }
56 
61  void setLayerInsertionPoint( QgsLayerTreeGroup *parentGroup, int index );
62 
63  signals:
64 
69  void addedLayersToLayerTree( const QList<QgsMapLayer *> &layers );
70 
71  protected slots:
72  void layersAdded( const QList<QgsMapLayer *> &layers );
73  void layersWillBeRemoved( const QStringList &layerIds );
74 
75  void groupWillRemoveChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
76  void groupRemovedChildren();
77 
78  void removeLayersFromRegistry( const QStringList &layerIds );
79 
80  protected:
81  QgsLayerTreeGroup *mRoot = nullptr;
82  QgsProject *mProject = nullptr;
83  QStringList mLayerIdsForRemoval;
85  bool mEnabled;
87 
88  QgsLayerTreeGroup *mInsertionPointGroup = nullptr;
90 };
91 
92 #endif // QGSLAYERTREEREGISTRYBRIDGE_H
Layer tree group node serves as a container for layers and further groups.
Base class for all map layer types.
Definition: qgsmaplayer.h:63
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
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:89