QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Functions
qgsproject.cpp File Reference
#include "qgsproject.h"
#include <deque>
#include <memory>
#include "qgsdatasourceuri.h"
#include "qgsexception.h"
#include "qgslayertree.h"
#include "qgslayertreeutils.h"
#include "qgslayertreeregistrybridge.h"
#include "qgslogger.h"
#include "qgsmaplayerregistry.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 <QApplication>
#include <QFileInfo>
#include <QDomNode>
#include <QObject>
#include <QTextStream>
Include dependency graph for qgsproject.cpp:

Go to the source code of this file.

Classes

struct  QgsProject::Imp
 

Functions

static QStringList makeKeyTokens_ (QString const &scope, QString const &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...
 
static QgsPropertyfindKey_ (QString const &scope, QString const &key, QgsPropertyKey &rootProperty)
 return the property that matches the given key sequence, if any More...
 
static QgsPropertyaddKey_ (QString const &scope, QString const &key, QgsPropertyKey *rootProperty, QVariant value)
 add the given key and value More...
 
static void removeKey_ (QString const &scope, QString const &key, QgsPropertyKey &rootProperty)
 
static void dump_ (QgsPropertyKey const &topQgsPropertyKey)
 basically a debugging tool to dump property list values More...
 
static void _getProperties (QDomDocument const &doc, QgsPropertyKey &project_properties)
 Restore any optional properties found in "doc" to "properties". More...
 
static void _getTitle (QDomDocument const &doc, QString &title)
 Get the project title. More...
 
static QgsProjectVersion _getVersion (QDomDocument const &doc)
 return the version string found in the given Dom document More...
 

Function Documentation

static void _getProperties ( QDomDocument const &  doc,
QgsPropertyKey project_properties 
)
static

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 484 of file qgsproject.cpp.

References QgsPropertyKey::addKey(), QgsPropertyKey::find(), QgsDebugMsg, and QgsPropertyKey::readXML().

Referenced by QgsProject::read().

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

Get the project title.

XML in file has this form:

   <qgis projectname="default project">
   <title>a project title</title>
Todo:
XXX we should go with the attribute xor title, not both.

Definition at line 569 of file qgsproject.cpp.

References QgsDebugMsg.

Referenced by QgsProject::read().

static QgsProjectVersion _getVersion ( QDomDocument const &  doc)
static

return the version string found in the given Dom document

Returns
the version string or an empty string if none found

Definition at line 608 of file qgsproject.cpp.

References QgsDebugMsg.

Referenced by QgsProject::read().

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

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 160 of file qgsproject.cpp.

References QgsPropertyKey::addKey(), QgsPropertyKey::find(), makeKeyTokens_(), QgsPropertyKey::name(), and QgsPropertyKey::setValue().

Referenced by QgsProject::writeEntry().

static void dump_ ( QgsPropertyKey const &  topQgsPropertyKey)
static

basically a debugging tool to dump property list values

Definition at line 442 of file qgsproject.cpp.

References QgsPropertyKey::dump(), and QgsDebugMsg.

Referenced by QgsProject::dumpProperties(), QgsProject::read(), and QgsProject::write().

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

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 86 of file qgsproject.cpp.

References QgsPropertyKey::find(), QgsProperty::isKey(), QgsProperty::isValue(), makeKeyTokens_(), and QgsPropertyKey::name().

Referenced by QgsProject::entryList(), QgsProject::readBoolEntry(), QgsProject::readDoubleEntry(), QgsProject::readEntry(), QgsProject::readListEntry(), QgsProject::readNumEntry(), QgsProject::removeEntry(), and QgsProject::subkeyList().

static QStringList makeKeyTokens_ ( QString const &  scope,
QString const &  key 
)
static

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 58 of file qgsproject.cpp.

Referenced by addKey_(), findKey_(), and removeKey_().

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