QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 #include "qgslayertreegroup.h"
19 
27 class CORE_EXPORT QgsLayerDefinition
28 {
29  public:
31  static bool loadLayerDefinition( const QString & path, QgsLayerTreeGroup* rootGroup, QString &errorMessage );
33  static bool loadLayerDefinition( QDomDocument doc, QgsLayerTreeGroup* rootGroup, QString &errorMessage, const QString& relativeBasePath = QString() );
35  static bool exportLayerDefinition( QString path, const QList<QgsLayerTreeNode*>& selectedTreeNodes, QString &errorMessage );
37  static bool exportLayerDefinition( QDomDocument doc, const QList<QgsLayerTreeNode*>& selectedTreeNodes, QString &errorMessage, const QString& relativeBasePath = QString() );
38 
43  class CORE_EXPORT DependencySorter
44  {
45  public:
49  DependencySorter( const QDomDocument& doc );
50 
54  DependencySorter( const QString& fileName );
55 
57  QVector<QDomNode> sortedLayerNodes() const { return mSortedLayerNodes; }
58 
60  QStringList sortedLayerIds() const { return mSortedLayerIds; }
61 
63  bool hasCycle() const { return mHasCycle; }
64 
66  bool hasMissingDependency() const { return mHasMissingDependency; }
67 
68  private:
69  QVector<QDomNode> mSortedLayerNodes;
70  QStringList mSortedLayerIds;
71  bool mHasCycle;
72  bool mHasMissingDependency;
73  void init( const QDomDocument& doc );
74  };
75 };
76 
77 #endif // QGSLAYERDEFINITION_H
Layer tree group node serves as a container for layers and further groups.
The QgsLayerDefinition class holds generic methods for loading/exporting QLR files.
Class used to work with layer dependencies stored in a XML project or layer definition file...
QVector< QDomNode > sortedLayerNodes() const
Get the layer nodes in an order where they can be loaded incrementally without dependency break...
bool hasCycle() const
Whether some cyclic dependency has been detected.
QStringList sortedLayerIds() const
Get the layer IDs in an order where they can be loaded incrementally without dependency break...
bool hasMissingDependency() const
Whether some dependency is missing.