QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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#include <QDomNodeList>
23#include "qgis_core.h"
24
25class QDomElement;
26class QDomDocument;
27
31class QgsMapLayer;
32class QgsProject;
33
39class CORE_EXPORT QgsLayerTreeUtils
40{
41 public:
42
44 static bool readOldLegend( QgsLayerTreeGroup *root, const QDomElement &legendElem );
46 static bool readOldLegendLayerOrder( const QDomElement &legendElem, bool &hasCustomOrder, QStringList &order );
48 static QDomElement writeOldLegend( QDomDocument &doc, QgsLayerTreeGroup *root, bool hasCustomOrder, const QList<QgsMapLayer *> &order );
49
51 static QString checkStateToXml( Qt::CheckState state );
53 static Qt::CheckState checkStateFromXml( const QString &txt );
54
61 static bool layersEditable( const QList<QgsLayerTreeLayer *> &layerNodes, bool ignoreLayersWhichCannotBeToggled = false );
62
64 static bool layersModified( const QList<QgsLayerTreeLayer *> &layerNodes );
65
67 static void removeInvalidLayers( QgsLayerTreeGroup *group );
68
73 static void storeOriginalLayersProperties( QgsLayerTreeGroup *group, const QDomDocument *doc );
74
76 static void replaceChildrenOfEmbeddedGroups( QgsLayerTreeGroup *group );
77
81 static void updateEmbeddedGroupsProjectPath( QgsLayerTreeGroup *group, const QgsProject *project );
82
84 static QStringList invisibleLayerList( QgsLayerTreeNode *node );
85
87 static void setLegendFilterByExpression( QgsLayerTreeLayer &layer, const QString &expr, bool enabled = true );
89 static QString legendFilterByExpression( const QgsLayerTreeLayer &layer, bool *enabled = nullptr );
91 static bool hasLegendFilterExpression( const QgsLayerTreeGroup &group );
92
100 static QgsLayerTreeLayer *insertLayerBelow( QgsLayerTreeGroup *group, const QgsMapLayer *refLayer, QgsMapLayer *layerToInsert );
101
107 static QSet<QgsMapLayer *> collectMapLayersRecursive( const QList<QgsLayerTreeNode *> &nodes );
108
121 static int countMapLayerInTree( QgsLayerTreeNode *tree, QgsMapLayer *layer );
122
130 static QgsLayerTreeGroup *firstGroupWithoutCustomProperty( QgsLayerTreeGroup *group, const QString &property );
131
148 static QgsLayerTreeLayer *insertLayerAtOptimalPlacement( QgsLayerTreeGroup *group, QgsMapLayer *layer );
149};
150
151#endif // QGSLAYERTREEUTILS_H
Layer tree group node serves as a container for layers and further groups.
Layer tree node points to a map layer.
This class is a base class for nodes in a layer tree.
Assorted functions for dealing with layer trees.
Base class for all map layer types.
Definition qgsmaplayer.h:76
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107