2015-01-19 16:36:40 +10:00
|
|
|
/**
|
|
|
|
* @brief The QgsLayerDefinition class holds generic methods for loading/exporting QLR files.
|
|
|
|
*
|
|
|
|
* QLR files are an export of the layer xml including the style and datasource location. There is no link
|
|
|
|
* to the QLR file once loaded. Consider the QLR file a mini project file for layers and styles. QLR
|
|
|
|
* files also store the layer tree info for the exported layers, including group information.
|
|
|
|
*/
|
2015-03-24 12:01:18 +01:00
|
|
|
class QgsLayerDefinition
|
2015-01-19 09:22:10 +10:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgslayerdefinition.h>
|
|
|
|
%End
|
2015-03-24 12:01:18 +01:00
|
|
|
public:
|
2015-04-30 17:26:58 +10:00
|
|
|
/** Loads the QLR at path into QGIS. New layers are added to rootGroup and the map layer registry*/
|
2015-03-24 12:01:18 +01:00
|
|
|
static bool loadLayerDefinition( const QString & path, QgsLayerTreeGroup* rootGroup, QString &errorMessage /Out/ );
|
2015-04-30 17:26:58 +10:00
|
|
|
/** Loads the QLR from the XML document. New layers are added to rootGroup and the map layer registry */
|
2015-03-24 12:01:18 +01:00
|
|
|
static bool loadLayerDefinition( QDomDocument doc, QgsLayerTreeGroup* rootGroup, QString &errorMessage /Out/ );
|
2015-04-30 17:26:58 +10:00
|
|
|
/** Export the selected layer tree nodes to a QLR file */
|
2015-10-07 11:55:34 +11:00
|
|
|
static bool exportLayerDefinition( QString path, const QList<QgsLayerTreeNode*>& selectedTreeNodes, QString &errorMessage /Out/ );
|
2016-01-01 21:33:30 +01:00
|
|
|
/** Export the selected layer tree nodes to a QLR-XML document */
|
|
|
|
static bool exportLayerDefinition( QDomDocument doc, const QList<QgsLayerTreeNode*>& selectedTreeNodes, QString &errorMessage, const QString& relativeBasePath = QString::null );
|
2016-01-07 12:01:26 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class used to work with layer dependencies stored in a XML project or layer definition file
|
|
|
|
*/
|
|
|
|
class DependencySorter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Constructor
|
|
|
|
* @param doc The XML document containing maplayer elements
|
|
|
|
*/
|
2016-02-02 19:46:18 +11:00
|
|
|
DependencySorter( const QDomDocument& doc );
|
2016-01-07 12:01:26 +01:00
|
|
|
|
2016-01-07 14:37:23 +01:00
|
|
|
/** Constructor
|
|
|
|
* @param fileName The filename where the XML document is stored
|
|
|
|
*/
|
|
|
|
DependencySorter( const QString& fileName );
|
|
|
|
|
2016-01-07 12:01:26 +01:00
|
|
|
/** Get the layer nodes in an order where they can be loaded incrementally without dependency break */
|
|
|
|
QVector<QDomNode> sortedLayerNodes() const;
|
|
|
|
|
2016-01-07 14:37:23 +01:00
|
|
|
/** Get the layer IDs in an order where they can be loaded incrementally without dependency break */
|
|
|
|
QStringList sortedLayerIds() const;
|
|
|
|
|
2016-01-07 12:01:26 +01:00
|
|
|
/** Whether some cyclic dependency has been detected */
|
|
|
|
bool hasCycle() const;
|
|
|
|
|
|
|
|
/** Whether some dependency is missing */
|
|
|
|
bool hasMissingDependency() const;
|
|
|
|
};
|
2015-01-19 09:22:10 +10:00
|
|
|
};
|
|
|
|
|