QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Classes | Functions
qgsproject.cpp File Reference
#include "qgsproject.h"
#include "qgsdatasourceuri.h"
#include "qgsexception.h"
#include "qgslayertree.h"
#include "qgslayertreeutils.h"
#include "qgslayertreeregistrybridge.h"
#include "qgslogger.h"
#include "qgsmaplayerregistry.h"
#include "qgsmessagelog.h"
#include "qgspluginlayer.h"
#include "qgspluginlayerregistry.h"
#include "qgsprojectfiletransform.h"
#include "qgsprojectproperty.h"
#include "qgsprojectversion.h"
#include "qgsrasterlayer.h"
#include "qgsrectangle.h"
#include "qgsrelationmanager.h"
#include "qgsvectorlayer.h"
#include "qgsvisibilitypresetcollection.h"
#include "qgslayerdefinition.h"
#include "qgsunittypes.h"
#include "qgstransaction.h"
#include "qgstransactiongroup.h"
#include "qgsvectordataprovider.h"
#include <QApplication>
#include <QFileInfo>
#include <QDomNode>
#include <QObject>
#include <QTextStream>
#include <QTemporaryFile>
#include <QDir>
#include <QUrl>
#include <QSettings>
Include dependency graph for qgsproject.cpp:

Go to the source code of this file.

Classes

struct  QgsProject::Imp
 

Functions

void _getProperties (const QDomDocument &doc, QgsPropertyKey &project_properties)
 Restore any optional properties found in "doc" to "properties". More...
 
static void _getTitle (const QDomDocument &doc, QString &title)
 Get the project title. More...
 
QgsPropertyaddKey_ (const QString &scope, const QString &key, QgsPropertyKey *rootProperty, const QVariant &value)
 Add the given key and value. More...
 
void dump_ (const QgsPropertyKey &topQgsPropertyKey)
 
QgsPropertyfindKey_ (const QString &scope, const QString &key, QgsPropertyKey &rootProperty)
 return the property that matches the given key sequence, if any More...
 
QgsProjectVersion getVersion (const QDomDocument &doc)
 Return the version string found in the given DOM document. More...
 
QStringList makeKeyTokens_ (const QString &scope, const QString &key)
 Take the given scope and key and convert them to a string list of key tokens that will be used to navigate through a Property hierarchy. More...
 
void removeKey_ (const QString &scope, const QString &key, QgsPropertyKey &rootProperty)
 

Function Documentation

◆ _getProperties()

void _getProperties ( const QDomDocument doc,
QgsPropertyKey project_properties 
)

Restore any optional properties found in "doc" to "properties".

properties tags for all optional properties. Within that there will be scope tags. In the following example there exist one property in the "fsplugin" scope. "layers" is a list containing three string values.

<properties>
<fsplugin>
<foo type="int" >42</foo>
<baz type="int" >1</baz>
<layers type="QStringList" >
<value>railroad</value>
<value>airport</value>
</layers>
<xyqzzy type="int" >1</xyqzzy>
<bar type="double" >123.456</bar>
<feature_types type="QStringList" >
<value>type</value>
</feature_types>
</fsplugin>
</properties>
Parameters
docxml document
project_propertiesshould be the top QgsPropertyKey node.

Definition at line 509 of file qgsproject.cpp.

◆ _getTitle()

static void _getTitle ( const QDomDocument doc,
QString title 
)
static

Get the project title.

Todo:
XXX we should go with the attribute xor title, not both.

Definition at line 545 of file qgsproject.cpp.

◆ addKey_()

QgsProperty* addKey_ ( const QString scope,
const QString key,
QgsPropertyKey rootProperty,
const QVariant value 
)

Add the given key and value.

Parameters
scopescope of key
keykey name
rootPropertyis the property from which to start adding
valuethe value associated with the key

Definition at line 188 of file qgsproject.cpp.

◆ dump_()

void dump_ ( const QgsPropertyKey topQgsPropertyKey)

Definition at line 472 of file qgsproject.cpp.

◆ findKey_()

QgsProperty* findKey_ ( const QString scope,
const QString key,
QgsPropertyKey rootProperty 
)

return the property that matches the given key sequence, if any

Parameters
scopescope of key
keykeyname
rootPropertyis likely to be the top level QgsPropertyKey in QgsProject:e:Imp.
Returns
null if not found, otherwise located Property

Definition at line 113 of file qgsproject.cpp.

◆ getVersion()

QgsProjectVersion getVersion ( QDomDocument const &  doc)

Return the version string found in the given DOM document.

Returns
the version string or an empty string if none found

Definition at line 579 of file qgsproject.cpp.

◆ makeKeyTokens_()

QStringList makeKeyTokens_ ( const QString scope,
const QString key 
)

Take the given scope and key and convert them to a string list of key tokens that will be used to navigate through a Property hierarchy.

E.g., scope "someplugin" and key "/foo/bar/baz" will become a string list of { "properties", "someplugin", "foo", "bar", "baz" }. "properties" is always first because that's the permanent ``root'' Property node.

Definition at line 71 of file qgsproject.cpp.

◆ removeKey_()

void removeKey_ ( const QString scope,
const QString key,
QgsPropertyKey rootProperty 
)

Definition at line 257 of file qgsproject.cpp.