QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
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:
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 
87  signals:
88 
93  void addedLayersToLayerTree( const QList<QgsMapLayer *> &layers );
94 
95  protected slots:
96  void layersAdded( const QList<QgsMapLayer *> &layers );
97  void layersWillBeRemoved( const QStringList &layerIds );
98 
99  void groupWillRemoveChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
100  void groupRemovedChildren();
101 
102  void removeLayersFromRegistry( const QStringList &layerIds );
103 
104  protected:
105  QgsLayerTreeGroup *mRoot = nullptr;
106  QgsProject *mProject = nullptr;
107  QStringList mLayerIdsForRemoval;
109  bool mEnabled;
111 
113 };
114 
115 #endif // QGSLAYERTREEREGISTRYBRIDGE_H
QgsLayerTreeRegistryBridge::InsertionPoint
A structure to define the insertion point to the layer tree.
Definition: qgslayertreeregistrybridge.h:55
QgsLayerTreeNode
This class is a base class for nodes in a layer tree.
Definition: qgslayertreenode.h:75
QgsLayerTreeRegistryBridge::InsertionPoint::InsertionPoint
InsertionPoint(QgsLayerTreeGroup *group, int position)
Constructs an insertion point as layer tree group with its corresponding position.
Definition: qgslayertreeregistrybridge.h:57
QgsLayerTreeRegistryBridge::setEnabled
void setEnabled(bool enabled)
Definition: qgslayertreeregistrybridge.h:67
QgsLayerTreeRegistryBridge::addedLayersToLayerTree
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...
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:95
QgsLayerTreeRegistryBridge::mLayerIdsForRemoval
QStringList mLayerIdsForRemoval
Definition: qgslayertreeregistrybridge.h:107
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QgsLayerTreeRegistryBridge::mRegistryRemovingLayers
bool mRegistryRemovingLayers
Definition: qgslayertreeregistrybridge.h:108
qgis_sip.h
QgsLayerTreeGroup
Layer tree group node serves as a container for layers and further groups.
Definition: qgslayertreegroup.h:35
QgsLayerTreeRegistryBridge::newLayersVisible
bool newLayersVisible() const
Definition: qgslayertreeregistrybridge.h:71
QgsLayerTreeRegistryBridge::mInsertionPoint
InsertionPoint mInsertionPoint
Definition: qgslayertreeregistrybridge.h:112
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsLayerTreeRegistryBridge::mNewLayersVisible
bool mNewLayersVisible
Definition: qgslayertreeregistrybridge.h:110
QgsLayerTreeRegistryBridge::mEnabled
bool mEnabled
Definition: qgslayertreeregistrybridge.h:109
QgsLayerTreeRegistryBridge::setNewLayersVisible
void setNewLayersVisible(bool enabled)
Definition: qgslayertreeregistrybridge.h:70
QgsLayerTreeRegistryBridge::isEnabled
bool isEnabled() const
Definition: qgslayertreeregistrybridge.h:68
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsLayerTreeRegistryBridge
Listens to the updates in map layer registry and does changes in layer tree.
Definition: qgslayertreeregistrybridge.h:45