QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
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.h
"
20
#include "qgis_core.h"
21
#include "
qgis_sip.h
"
22
#include "
qgslayertreeregistrybridge.h
"
23
24
#include <QDomNode>
25
#include <QSet>
26
#include <QString>
27
#include <QVector>
28
29
class
QDomDocument;
30
31
class
QgsLayerTreeGroup
;
32
class
QgsLayerTreeNode
;
33
class
QgsMapLayer
;
34
class
QgsReadWriteContext
;
35
class
QgsProject
;
36
45
class
CORE_EXPORT
QgsLayerDefinition
46
{
47
public
:
58
static
bool
loadLayerDefinition
(
59
const
QString &path,
60
QgsProject
*project,
61
QgsLayerTreeGroup
*rootGroup,
62
QString &errorMessage
SIP_OUT
,
63
Qgis::LayerTreeInsertionMethod
insertMethod =
Qgis::LayerTreeInsertionMethod::OptimalInInsertionGroup
,
64
const
QgsLayerTreeRegistryBridge::InsertionPoint
*insertPoint =
nullptr
65
);
66
78
static
bool
loadLayerDefinition
(
79
QDomDocument doc,
80
QgsProject
*project,
81
QgsLayerTreeGroup
*rootGroup,
82
QString &errorMessage
SIP_OUT
,
83
QgsReadWriteContext
&context,
84
Qgis::LayerTreeInsertionMethod
insertMethod =
Qgis::LayerTreeInsertionMethod::OptimalInInsertionGroup
,
85
const
QgsLayerTreeRegistryBridge::InsertionPoint
*insertPoint =
nullptr
86
);
87
88
// TODO QGIS 5.0 -- remove this in favour of the version with explicit Qgis::FilePathType parameter
104
Q_DECL_DEPRECATED
static
bool
exportLayerDefinition
(
const
QString &path,
const
QList<QgsLayerTreeNode *> &selectedTreeNodes, QString &errorMessage
SIP_OUT
)
SIP_DEPRECATED
;
105
118
static
bool
exportLayerDefinition
(
const
QString &path,
const
QList<QgsLayerTreeNode *> &selectedTreeNodes,
Qgis::FilePathType
pathType, QString &errorMessage
SIP_OUT
);
119
123
static
bool
exportLayerDefinition
( QDomDocument doc,
const
QList<QgsLayerTreeNode *> &selectedTreeNodes, QString &errorMessage
SIP_OUT
,
const
QgsReadWriteContext
&context );
124
134
static
QDomDocument
exportLayerDefinitionLayers
(
const
QList<QgsMapLayer *> &layers,
const
QgsReadWriteContext
&context );
135
141
static
QList<QgsMapLayer *>
loadLayerDefinitionLayers
( QDomDocument &document,
QgsReadWriteContext
&context )
SIP_FACTORY
;
142
148
static
QList<QgsMapLayer *>
loadLayerDefinitionLayers
(
const
QString &qlrfile )
SIP_FACTORY
;
149
154
class
CORE_EXPORT
DependencySorter
155
{
156
public
:
161
explicit
DependencySorter
(
const
QDomDocument &doc );
162
167
explicit
DependencySorter
(
const
QString &fileName );
168
170
QVector<QDomNode>
sortedLayerNodes
()
const
{
return
mSortedLayerNodes; }
171
173
QStringList
sortedLayerIds
()
const
{
return
mSortedLayerIds; }
174
176
bool
hasCycle
()
const
{
return
mHasCycle; }
177
179
bool
hasMissingDependency
()
const
{
return
mHasMissingDependency; }
180
186
bool
isLayerDependent(
const
QString &layerId )
const
;
187
188
private
:
189
QVector<QDomNode> mSortedLayerNodes;
190
QStringList mSortedLayerIds;
191
QSet<QString> mDependentLayerIds;
192
bool
mHasCycle;
193
bool
mHasMissingDependency;
194
void
init(
const
QDomDocument &doc );
195
};
196
197
private
:
198
static
QList<QgsMapLayer *> loadLayerDefinitionLayersInternal( QDomDocument &document,
QgsReadWriteContext
&context, QString &errorMessage );
199
};
200
201
#endif
// QGSLAYERDEFINITION_H
Qgis::LayerTreeInsertionMethod
LayerTreeInsertionMethod
Layer tree insertion methods.
Definition
qgis.h:5022
Qgis::LayerTreeInsertionMethod::OptimalInInsertionGroup
@ OptimalInInsertionGroup
Layers are added at optimal locations across the insertion point's group.
Definition
qgis.h:5025
Qgis::FilePathType
FilePathType
File path types.
Definition
qgis.h:1846
QgsLayerDefinition::DependencySorter::hasMissingDependency
bool hasMissingDependency() const
Whether some dependency is missing.
Definition
qgslayerdefinition.h:179
QgsLayerDefinition::DependencySorter::sortedLayerIds
QStringList sortedLayerIds() const
Gets the layer IDs in an order where they can be loaded incrementally without dependency break.
Definition
qgslayerdefinition.h:173
QgsLayerDefinition::DependencySorter::hasCycle
bool hasCycle() const
Whether some cyclic dependency has been detected.
Definition
qgslayerdefinition.h:176
QgsLayerDefinition::DependencySorter::DependencySorter
DependencySorter(const QDomDocument &doc)
Constructor.
Definition
qgslayerdefinition.cpp:543
QgsLayerDefinition::DependencySorter::sortedLayerNodes
QVector< QDomNode > sortedLayerNodes() const
Gets the layer nodes in an order where they can be loaded incrementally without dependency break.
Definition
qgslayerdefinition.h:170
QgsLayerDefinition
Holds generic methods for loading/exporting QLR files.
Definition
qgslayerdefinition.h:46
QgsLayerDefinition::exportLayerDefinitionLayers
static QDomDocument exportLayerDefinitionLayers(const QList< QgsMapLayer * > &layers, const QgsReadWriteContext &context)
Returns the given layer as a layer definition document Layer definitions store the data source as wel...
Definition
qgslayerdefinition.cpp:303
QgsLayerDefinition::loadLayerDefinitionLayers
static QList< QgsMapLayer * > loadLayerDefinitionLayers(QDomDocument &document, QgsReadWriteContext &context)
Creates new layers from a layer definition document.
Definition
qgslayerdefinition.cpp:320
QgsLayerDefinition::loadLayerDefinition
static bool loadLayerDefinition(const QString &path, QgsProject *project, QgsLayerTreeGroup *rootGroup, QString &errorMessage, Qgis::LayerTreeInsertionMethod insertMethod=Qgis::LayerTreeInsertionMethod::OptimalInInsertionGroup, const QgsLayerTreeRegistryBridge::InsertionPoint *insertPoint=nullptr)
Loads the QLR at path into QGIS.
Definition
qgslayerdefinition.cpp:46
QgsLayerDefinition::exportLayerDefinition
static Q_DECL_DEPRECATED bool exportLayerDefinition(const QString &path, const QList< QgsLayerTreeNode * > &selectedTreeNodes, QString &errorMessage)
Exports the selected layer tree nodes to a QLR file.
Definition
qgslayerdefinition.cpp:237
QgsLayerTreeGroup
Layer tree group node serves as a container for layers and further groups.
Definition
qgslayertreegroup.h:45
QgsLayerTreeNode
Base class for nodes in a layer tree.
Definition
qgslayertreenode.h:81
QgsMapLayer
Base class for all map layer types.
Definition
qgsmaplayer.h:83
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition
qgsproject.h:114
QgsReadWriteContext
A container for the context for various read/write operations on objects.
Definition
qgsreadwritecontext.h:38
qgis.h
qgis_sip.h
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition
qgis_sip.h:113
SIP_OUT
#define SIP_OUT
Definition
qgis_sip.h:57
SIP_FACTORY
#define SIP_FACTORY
Definition
qgis_sip.h:83
qgslayertreeregistrybridge.h
QgsLayerTreeRegistryBridge::InsertionPoint
A structure to define the insertion point to the layer tree.
Definition
qgslayertreeregistrybridge.h:55
Generated on
for QGIS API Documentation by
1.17.0