QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgslayertreeutils.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayertreeutils.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 QGSLAYERTREEUTILS_H
17 #define QGSLAYERTREEUTILS_H
18 
19 #include <qnamespace.h>
20 #include <QList>
21 #include <QPair>
22 
23 class QDomElement;
24 class QDomDocument;
25 class QStringList;
26 
27 class QgsLayerTreeNode;
28 class QgsLayerTreeGroup;
29 class QgsLayerTreeLayer;
30 class QgsMapLayer;
31 
37 class CORE_EXPORT QgsLayerTreeUtils
38 {
39  public:
40 
42  static bool readOldLegend( QgsLayerTreeGroup* root, const QDomElement& legendElem );
44  static bool readOldLegendLayerOrder( const QDomElement& legendElem, bool& hasCustomOrder, QStringList& order );
46  static QDomElement writeOldLegend( QDomDocument& doc, QgsLayerTreeGroup* root, bool hasCustomOrder, const QStringList& order );
47 
49  static QString checkStateToXml( Qt::CheckState state );
51  static Qt::CheckState checkStateFromXml( const QString& txt );
52 
54  static bool layersEditable( const QList<QgsLayerTreeLayer*>& layerNodes );
56  static bool layersModified( const QList<QgsLayerTreeLayer*>& layerNodes );
57 
59  static void removeInvalidLayers( QgsLayerTreeGroup* group );
60 
62  static void replaceChildrenOfEmbeddedGroups( QgsLayerTreeGroup* group );
63 
65  static void updateEmbeddedGroupsProjectPath( QgsLayerTreeGroup* group );
66 
68  static QStringList invisibleLayerList( QgsLayerTreeNode *node );
69 
71  static void setLegendFilterByExpression( QgsLayerTreeLayer& layer, const QString& expr, bool enabled = true );
73  static QString legendFilterByExpression( const QgsLayerTreeLayer& layer, bool* enabled = nullptr );
75  static bool hasLegendFilterExpression( const QgsLayerTreeGroup& group );
76 
82  static QgsLayerTreeLayer* insertLayerBelow( QgsLayerTreeGroup* group, const QgsMapLayer* refLayer, QgsMapLayer* layerToInsert );
83 };
84 
85 #endif // QGSLAYERTREEUTILS_H
Layer tree group node serves as a container for layers and further groups.
Base class for all map layer types.
Definition: qgsmaplayer.h:49
Assorted functions for dealing with layer trees.
This class is a base class for nodes in a layer tree.
Layer tree node points to a map layer.