QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgslayerdefinition.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayerdefinition.h
3 ---------------------
4 begin : January 2015
5 copyright : (C) 2015 by Nathan Woodrow
6 email : woodrow dot nathan 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#ifndef QGSLAYERDEFINITION_H
16#define QGSLAYERDEFINITION_H
17
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include "qgis.h"
22
23#include <QString>
24#include <QVector>
25#include <QDomNode>
26#include <QSet>
27
28class QDomDocument;
29
32class QgsMapLayer;
34class QgsProject;
35
44class CORE_EXPORT QgsLayerDefinition
45{
46 public:
48 static bool loadLayerDefinition( const QString &path, QgsProject *project, QgsLayerTreeGroup *rootGroup, QString &errorMessage SIP_OUT );
50 static bool loadLayerDefinition( QDomDocument doc, QgsProject *project, QgsLayerTreeGroup *rootGroup, QString &errorMessage SIP_OUT, QgsReadWriteContext &context );
51
65 static bool exportLayerDefinition( const QString &path, const QList<QgsLayerTreeNode *> &selectedTreeNodes, QString &errorMessage SIP_OUT );
66
79 static bool exportLayerDefinition( const QString &path, const QList<QgsLayerTreeNode *> &selectedTreeNodes, Qgis::FilePathType pathType, QString &errorMessage SIP_OUT );
80
84 static bool exportLayerDefinition( QDomDocument doc, const QList<QgsLayerTreeNode *> &selectedTreeNodes, QString &errorMessage SIP_OUT, const QgsReadWriteContext &context );
85
95 static QDomDocument exportLayerDefinitionLayers( const QList<QgsMapLayer *> &layers, const QgsReadWriteContext &context );
96
102 static QList<QgsMapLayer *> loadLayerDefinitionLayers( QDomDocument &document, QgsReadWriteContext &context ) SIP_FACTORY;
103
109 static QList<QgsMapLayer *> loadLayerDefinitionLayers( const QString &qlrfile ) SIP_FACTORY;
110
115 class CORE_EXPORT DependencySorter
116 {
117 public:
118
123 explicit DependencySorter( const QDomDocument &doc );
124
129 explicit DependencySorter( const QString &fileName );
130
132 QVector<QDomNode> sortedLayerNodes() const { return mSortedLayerNodes; }
133
135 QStringList sortedLayerIds() const { return mSortedLayerIds; }
136
138 bool hasCycle() const { return mHasCycle; }
139
141 bool hasMissingDependency() const { return mHasMissingDependency; }
142
148 bool isLayerDependent( const QString &layerId ) const;
149
150 private:
151 QVector<QDomNode> mSortedLayerNodes;
152 QStringList mSortedLayerIds;
153 QSet<QString> mDependentLayerIds;
154 bool mHasCycle;
155 bool mHasMissingDependency;
156 void init( const QDomDocument &doc );
157 };
158
159 private:
160
161 static QList<QgsMapLayer *> loadLayerDefinitionLayersInternal( QDomDocument &document, QgsReadWriteContext &context, QString &errorMessage );
162
163
164};
165
166#endif // QGSLAYERDEFINITION_H
FilePathType
File path types.
Definition qgis.h:1185
Class used to work with layer dependencies stored in a XML project or layer definition file.
bool hasMissingDependency() const
Whether some dependency is missing.
QStringList sortedLayerIds() const
Gets the layer IDs in an order where they can be loaded incrementally without dependency break.
bool hasCycle() const
Whether some cyclic dependency has been detected.
QVector< QDomNode > sortedLayerNodes() const
Gets the layer nodes in an order where they can be loaded incrementally without dependency break.
The QgsLayerDefinition class holds generic methods for loading/exporting QLR files.
Layer tree group node serves as a container for layers and further groups.
This class is a base class for nodes in a layer tree.
Base class for all map layer types.
Definition qgsmaplayer.h:74
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
The class is used as a container of context for various read/write operations on other objects.
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_FACTORY
Definition qgis_sip.h:76