40 #include <QApplication>
44 #include <QTextStream>
61 keyTokens += key.
split(
'/', QString::SkipEmptyParts );
91 while ( !keySequence.
isEmpty() )
95 if ( keySequence.
first() == currentProperty->
name() )
100 if ( 1 == keySequence.
count() )
103 return currentProperty->
find( keySequence.
front() );
105 else if ( keySequence.
isEmpty() )
110 return currentProperty;
112 else if (( nextProperty = currentProperty->
find( keySequence.
first() ) ) )
114 if ( nextProperty->
isKey() )
118 else if ( nextProperty->
isValue() && 1 == keySequence.
count() )
124 return currentProperty;
170 while ( ! keySequence.
isEmpty() )
174 if ( keySequence.
first() == currentProperty->
name() )
181 if ( 1 == keySequence.
count() )
184 return currentProperty;
188 else if ( keySequence.
isEmpty() )
192 return currentProperty;
194 else if (( nextProperty = currentProperty->
find( keySequence.
first() ) ) )
198 if ( currentProperty )
209 if (( newPropertyKey = currentProperty->
addKey( keySequence.
first() ) ) )
211 currentProperty = newPropertyKey;
240 while ( ! keySequence.
isEmpty() )
244 if ( keySequence.
first() == currentProperty->
name() )
251 if ( 1 == keySequence.
count() )
258 else if ( keySequence.
isEmpty() )
260 previousQgsPropertyKey->
removeKey( currentProperty->
name() );
262 else if (( nextProperty = currentProperty->
find( keySequence.
first() ) ) )
264 previousQgsPropertyKey = currentProperty;
267 if ( currentProperty )
323 QgsProject::QgsProject()
342 delete mBadLayerHandler;
343 delete mRelationManager;
399 imp_->file.setFileName( name );
408 return imp_->file.fileName();
414 mEmbeddedLayers.
clear();
415 mRelationManager->
clear();
421 writeEntry(
"PositionPrecision",
"/Automatic",
true );
422 writeEntry(
"PositionPrecision",
"/DecimalPlaces", 2 );
432 topQgsPropertyKey.
dump();
472 if ( properties.
count() > 1 )
474 QgsDebugMsg(
"there appears to be more than one ``properties'' XML tag ... bailing" );
477 else if ( properties.
count() < 1 )
485 if ( scopes.
count() < 1 )
487 QgsDebugMsg(
"empty ``properties'' XML tag ... bailing" );
493 if ( ! project_properties.
readXML( propertyNode ) )
495 QgsDebugMsg(
"Project_properties.readXML() failed" );
535 if ( !titleTextNode.
isText() )
543 title = titleText.
data();
558 QgsDebugMsg(
" unable to find qgis element in project file" );
566 return projectVersion;
632 if ( 0 == nl.
count() )
634 return qMakePair(
true, brokenNodes );
642 bool returnStatus =
true;
650 for (
int i = 0; i < nl.
count(); i++ )
659 if ( element.
attribute(
"embedded" ) ==
"1" )
666 if ( !
addLayer( element, brokenNodes, vLayerList ) )
668 returnStatus =
false;
677 for ( ; vIt != vLayerList.
end(); ++vIt )
679 vIt->
first->createJoinCaches();
680 vIt->
first->updateFields();
684 for ( vIt = vLayerList.
begin(); vIt != vLayerList.
end(); ++vIt )
689 notified << vIt->
first;
695 return qMakePair( returnStatus, brokenNodes );
704 if ( type ==
"vector" )
708 else if ( type ==
"raster" )
712 else if ( type ==
"plugin" )
725 Q_CHECK_PTR( mapLayer );
735 vectorLayerList.push_back( qMakePair( vLayer, layerElem ) );
738 myLayers << mapLayer;
747 QgsDebugMsg(
"Unable to load " + type +
" layer" );
759 imp_->file.setFileName( file.
filePath() );
775 if ( !imp_->file.open( QIODevice::ReadOnly | QIODevice::Text ) )
779 setError(
tr(
"Unable to open %1" ).arg( imp_->file.fileName() ) );
788 if ( !doc->setContent( &imp_->file, &errorMsg, &line, &column ) )
793 tr(
"%1 at line %2 column %3" ).arg( errorMsg ).arg( line ).arg( column ) );
796 QString errorString =
tr(
"Project file read error: %1 at line %2 column %3" )
797 .
arg( errorMsg ).
arg( line ).
arg( column );
803 setError(
tr(
"%1 for file %2" ).arg( errorString ).arg( imp_->file.fileName() ) );
811 QgsDebugMsg(
"Opened document " + imp_->file.fileName() );
818 if ( thisVersion > fileVersion )
821 "version of qgis (saved in " + fileVersion.
text() +
823 "). Problems may occur." );
829 QgsDebugMsg(
"Emitting oldProjectVersionWarning(oldVersion)." );
831 projectFile.updateRevision( thisVersion );
837 imp_->file.setFileName( fileName );
844 dump_( imp_->properties_ );
853 QDomElement layerTreeElem = doc->documentElement().firstChildElement(
"layer-tree-group" );
854 if ( !layerTreeElem.
isNull() )
865 mLayerTreeRegistryBridge->
setEnabled(
false );
871 bool clean = getMapLayersResults.first;
875 QgsDebugMsg(
"Unable to get map layers from project file." );
877 if ( ! getMapLayersResults.second.isEmpty() )
927 clonedChildren << newGroupChild->
clone();
963 imp_->file.setFileName( file.
filePath() );
985 if ( !imp_->file.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
990 setError(
tr(
"Unable to save to file %1" ).arg( imp_->file.fileName() ) );
999 setError(
tr(
"%1 is not writable. Please adjust permissions (if possible) and try again." )
1000 .arg( imp_->file.fileName() ) );
1014 QDomElement qgisNode = doc->createElement(
"qgis" );
1018 doc->appendChild( qgisNode );
1021 QDomElement titleNode = doc->createElement(
"title" );
1042 QDomElement projectLayersNode = doc->createElement(
"projectlayers" );
1043 projectLayersNode.
setAttribute(
"layercount", qulonglong( layers.
size() ) );
1046 while ( li != layers.
end() )
1054 if ( emIt == mEmbeddedLayers.
constEnd() )
1057 QDomElement maplayerElem = doc->createElement(
"maplayer" );
1069 if ( emIt.value().second )
1071 QDomElement mapLayerElem = doc->createElement(
"maplayer" );
1086 dump_( imp_->properties_ );
1088 QgsDebugMsg(
QString(
"there are %1 property scopes" ).arg( static_cast<int>( imp_->properties_.count() ) ) );
1090 if ( !imp_->properties_.isEmpty() )
1093 imp_->properties_.writeXML(
"properties", qgisNode, *doc );
1101 doc->save( projectFileStream, 2 );
1107 if ( projectFileStream.
pos() == -1 || imp_->file.error() != QFile::NoError )
1109 setError(
tr(
"Unable to save to file %1. Your project "
1110 "may be corrupted on disk. Try clearing some space on the volume and "
1111 "check file permissions before pressing save again." )
1112 .arg( imp_->file.fileName() ) );
1139 return addKey_( scope, key, &imp_->properties_, value );
1149 return addKey_( scope, key, &imp_->properties_, value );
1158 return addKey_( scope, key, &imp_->properties_, value );
1168 return addKey_( scope, key, &imp_->properties_, value );
1178 return addKey_( scope, key, &imp_->properties_, value );
1193 value =
property->
value();
1195 bool valid = QVariant::StringList == value.
type();
1221 value =
property->
value();
1223 bool valid = value.
canConvert( QVariant::String );
1245 value =
property->
value();
1248 bool valid = value.
canConvert( QVariant::String );
1257 return value.
toInt();
1274 bool valid = value.
canConvert( QVariant::Double );
1296 bool valid = value.
canConvert( QVariant::Bool );
1314 return !
findKey_( scope, key, imp_->properties_ );
1325 if ( foundProperty )
1343 if ( foundProperty )
1359 dump_( imp_->properties_ );
1377 if ( src.
startsWith(
"/vsi", Qt::CaseInsensitive ) )
1386 #if defined(Q_OS_WIN)
1389 ( src[0].isLetter() && src[1] ==
':' ) )
1392 return vsiPrefix + src;
1395 if ( src[0] ==
'/' )
1398 return vsiPrefix + src;
1408 return vsiPrefix + src;
1414 return vsiPrefix + src;
1427 return vsiPrefix + src;
1430 #if defined(Q_OS_WIN)
1432 projPath.
replace(
"\\",
"/" );
1440 #if defined(Q_OS_WIN)
1443 projElems.
insert( 0,
"" );
1444 projElems.
insert( 0,
"" );
1452 projElems << srcElems;
1457 while (( pos = projElems.
indexOf(
".." ) ) > 0 )
1464 #if !defined(Q_OS_WIN)
1469 return vsiPrefix + projElems.
join(
"/" );
1485 if ( !relativeBasePath.
isNull() )
1487 projPath = relativeBasePath;
1502 #if defined( Q_OS_WIN )
1503 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1510 srcPath =
"\\\\" + srcPath.
mid( 2 );
1513 projPath.
replace(
"\\",
"/" );
1517 projPath =
"\\\\" + projPath.
mid( 2 );
1520 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1534 while ( srcElems.
size() > 0 &&
1535 projElems.
size() > 0 &&
1536 srcElems[0].compare( projElems[0], cs ) == 0 )
1549 if ( projElems.
size() > 0 )
1552 for (
int i = 0; i < projElems.
size(); i++ )
1554 srcElems.
insert( 0,
".." );
1561 srcElems.
insert( 0,
"." );
1564 return vsiPrefix + srcElems.
join(
"/" );
1569 mErrorMessage = errorMessage;
1574 return mErrorMessage;
1584 delete mBadLayerHandler;
1585 mBadLayerHandler = handler;
1591 if ( it == mEmbeddedLayers.
constEnd() )
1595 return it.
value().first;
1603 static QString prevProjectFilePath;
1606 if ( projectFilePath != prevProjectFilePath )
1608 prevProjectFilePath.
clear();
1610 QFile projectFile( projectFilePath );
1611 if ( !projectFile.
open( QIODevice::ReadOnly ) )
1616 if ( !projectDocument.
setContent( &projectFile ) )
1621 prevProjectFilePath = projectFilePath;
1625 bool useAbsolutePathes =
true;
1628 if ( !propertiesElem.
isNull() )
1633 useAbsolutePathes = absElem.
text().
compare(
"true", Qt::CaseInsensitive ) == 0;
1638 if ( projectLayersElem.
isNull() )
1644 for (
int i = 0; i < mapLayerNodes.
size(); ++i )
1649 if (
id == layerId )
1652 if ( mapLayerElem.
attribute(
"embedded" ) ==
"1" )
1657 mEmbeddedLayers.
insert( layerId, qMakePair( projectFilePath, saveFlag ) );
1660 if ( !useAbsolutePathes )
1663 if ( provider.
text() ==
"spatialite" )
1669 QFileInfo absoluteDs(
QFileInfo( projectFilePath ).absolutePath() +
"/" + uri.database() );
1670 if ( absoluteDs.exists() )
1672 uri.setDatabase( absoluteDs.absoluteFilePath() );
1682 if ( absoluteDs.exists() )
1690 if (
addLayer( mapLayerElem, brokenNodes, vectorLayerList ) )
1696 mEmbeddedLayers.
remove( layerId );
1709 QFile projectFile( projectFilePath );
1710 if ( !projectFile.
open( QIODevice::ReadOnly ) )
1716 if ( !projectDocument.
setContent( &projectFile ) )
1724 if ( !disabledLayersElem.
isNull() )
1727 for (
int i = 0; i < valueList.
size(); ++i )
1736 if ( !layerTreeElem.
isNull() )
1762 mLayerTreeRegistryBridge->
setEnabled(
false );
1764 mLayerTreeRegistryBridge->
setEnabled(
true );
1769 if ( embeddedIdentifyDisabledLayers.
contains( layerId ) )
1772 thisProjectIdentifyDisabledLayers.
append( layerId );
1779 layer->
setVisible( invisibleLayers.
contains( layerId ) ? Qt::Unchecked : Qt::Checked );
1809 QStringList layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList;
1810 snapSettings( layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList );
1811 int idx = layerIdList.
indexOf( layerId );
1819 avoidIntersectionList.
removeOne( layerId );
1822 layerIdList.
append( layerId );
1825 enabledList.
append( enabled ?
"enabled" :
"disabled" );
1831 typeString =
"to_segment";
1835 typeString =
"to_vertex_and_segment";
1839 typeString =
"to_vertex";
1841 snapTypeList.
append( typeString );
1850 if ( avoidIntersection )
1852 avoidIntersectionList.
append( layerId );
1855 writeEntry(
"Digitizing",
"/LayerSnappingList", layerIdList );
1856 writeEntry(
"Digitizing",
"/LayerSnappingEnabledList", enabledList );
1857 writeEntry(
"Digitizing",
"/LayerSnappingToleranceList", toleranceList );
1858 writeEntry(
"Digitizing",
"/LayerSnappingToleranceUnitList", toleranceUnitList );
1859 writeEntry(
"Digitizing",
"/LayerSnapToList", snapTypeList );
1860 writeEntry(
"Digitizing",
"/AvoidIntersectionsList", avoidIntersectionList );
1865 bool &avoidIntersection )
const
1867 QStringList layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList;
1868 snapSettings( layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList );
1869 int idx = layerIdList.
indexOf( layerId );
1876 int minListEntries = idx + 1;
1877 if ( layerIdList.
size() < minListEntries || enabledList.
size() < minListEntries || snapTypeList.
size() < minListEntries ||
1878 toleranceUnitList.
size() < minListEntries || toleranceList.
size() < minListEntries )
1884 enabled = enabledList.
at( idx ) ==
"enabled";
1887 QString snapType = snapTypeList.
at( idx );
1888 if ( snapType ==
"to_segment" )
1892 else if ( snapType ==
"to_vertex_and_segment" )
1902 if ( toleranceUnitList.
at( idx ) ==
"1" )
1906 else if ( toleranceUnitList.
at( idx ) ==
"2" )
1916 tolerance = toleranceList.
at( idx ).toDouble();
1919 avoidIntersection = ( avoidIntersectionList.
indexOf( layerId ) != -1 );
1927 layerIdList =
readListEntry(
"Digitizing",
"/LayerSnappingList" );
1928 enabledList =
readListEntry(
"Digitizing",
"/LayerSnappingEnabledList" );
1929 toleranceList =
readListEntry(
"Digitizing",
"/LayerSnappingToleranceList" );
1930 toleranceUnitList =
readListEntry(
"Digitizing",
"/LayerSnappingToleranceUnitList" );
1931 snapTypeList =
readListEntry(
"Digitizing",
"/LayerSnapToList" );
1932 avoidIntersectionList =
readListEntry(
"Digitizing",
"/AvoidIntersectionsList" );
1955 return QString::null;
1962 return mRelationManager;
virtual void handleBadLayers(QList< QDomNode > layers, QDomDocument projectDom) override
QObject * child(const char *objName, const char *inheritsClass, bool recursiveSearch) const
static const char * QGIS_VERSION
bool canConvert(Type t) const
Layer tree group node serves as a container for layers and further groups.
bool topologicalEditing() const
Convenience function to query topological editing status.
static QgsProperty * findKey_(QString const &scope, QString const &key, QgsPropertyKey &rootProperty)
return the property that matches the given key sequence, if any
QDomNodeList elementsByTagName(const QString &tagname) const
Base class for all map layer types.
static void removeInvalidLayers(QgsLayerTreeGroup *group)
Remove layer nodes that refer to invalid layers.
const QList< QgsVectorJoinInfo > vectorJoins() const
iterator insert(const Key &key, const T &value)
QDomNode item(int index) const
QString writePath(QString filename, QString relativeBasePath=QString::null) const
prepare a filename to save it to the project file
void readChildrenFromXML(QDomElement &element)
Read children from XML and append them to the group.
QgsPropertyKey properties_
QgsPropertyKey * addKey(const QString &keyName)
add the given property key
void setTopologicalEditing(bool enabled)
Convenience function to set topological editing.
QDomNode appendChild(const QDomNode &newChild)
bool writeLayerXML(QDomElement &layerElement, QDomDocument &document, QString relativeBasePath=QString::null)
stores state in Dom node
bool snapSettingsForLayer(const QString &layerId, bool &enabled, QgsSnapper::SnappingType &type, QgsTolerance::UnitType &units, double &tolerance, bool &avoidIntersection) const
Convenience function to query snap settings of a layer.
void push_back(const T &value)
void entryList(QStringList &entries) const
return keys that do not contain other keys
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QString attribute(const QString &name, const QString &defValue) const
static void _getProperties(QDomDocument const &doc, QgsPropertyKey &project_properties)
Restore any optional properties found in "doc" to "properties".
QgsPropertyValue * setValue(const QString &name, const QVariant &value)
set the value associated with this key
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
void removeAllChildren()
Remove all child nodes. The nodes will be deleted.
virtual QgsLayerTreeNode * clone() const =0
Create a copy of the node. Returns new instance.
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
static QgsProperty * addKey_(QString const &scope, QString const &key, QgsPropertyKey *rootProperty, QVariant value)
add the given key and value
static void warning(const QString &msg)
Goes to qWarning.
void oldProjectVersionWarning(QString)
emitted when an old project file is read.
const_iterator constBegin() const
const T & at(int i) const
bool rename(const QString &newName)
static bool readOldLegend(QgsLayerTreeGroup *root, const QDomElement &legendElem)
Try to load layer tree from.
bool contains(const QString &str, Qt::CaseSensitivity cs) const
void setFileName(const QString &name)
Every project has an associated file that contains its XML.
UnitType
Type of unit of tolerance value from settings.
void setFileName(const QString &name)
QString qgsVsiPrefix(QString path)
void push_front(const T &value)
QString layerIsEmbedded(const QString &id) const
Returns project file path if layer is embedded from other project file.
void setSnapSettingsForLayer(const QString &layerId, bool enabled, QgsSnapper::SnappingType type, QgsTolerance::UnitType unit, double tolerance, bool avoidIntersection)
Convenience function to set snap settings per layer.
QDomElement documentElement() const
QString join(const QString &separator) const
QString homePath() const
Return project's home path.
void clear()
clear project properties when a new project is started
const_iterator insert(const T &value)
QString & remove(int position, int n)
static void _getTitle(QDomDocument const &doc, QString &title)
Get the project title.
bool readBoolEntry(const QString &scope, const QString &key, bool def=false, bool *ok=0) const
void insertChildNodes(int index, QList< QgsLayerTreeNode * > nodes)
Insert existing nodes at specified position. The nodes must not have a parent yet. The nodes will be owned by this group.
void setDirty(bool b)
Set project as dirty (modified).
void projectSaved()
emitted when the project file has been written and closed
QDomNodeList childNodes() const
void loadEmbeddedNodes(QgsLayerTreeGroup *group)
QString tr(const char *sourceText, const char *disambiguation, int n)
QString readPath(QString filename) const
turn filename read from the project file to an absolute path
int readNumEntry(const QString &scope, const QString &key, int def=0, bool *ok=0) const
QgsPluginLayer * createLayer(QString typeName, const QString &uri=QString())
return new layer if corresponding plugin has been found, else return NULL.
virtual void writeXML(QDomElement &parentElement)=0
Write layer tree to XML.
void clear()
Remove any relation managed by this class.
QgsLayerTreeGroup * toGroup(QgsLayerTreeNode *node)
Cast node to a group. No type checking is done - use isGroup() to find out whether this operation is ...
QDomElement toElement() const
SnappingType
Snap to vertex, to segment or both.
const char * name() const
bool writeEntry(const QString &scope, const QString &key, bool value)
QString canonicalFilePath() const
QStringList readListEntry(const QString &scope, const QString &key, QStringList def=QStringList(), bool *ok=0) const
key value accessors
QString number(int n, int base)
int count(const T &value) const
bool createEmbeddedLayer(const QString &layerId, const QString &projectFilePath, QList< QDomNode > &brokenNodes, QList< QPair< QgsVectorLayer *, QDomElement > > &vectorLayerList, bool saveFlag=true)
Creates a maplayer instance defined in an arbitrary project file.
bool read()
presuming that the caller has already reset the map canvas, map registry, and legend ...
static QgsProjectVersion _getVersion(QDomDocument const &doc)
return the version string found in the given Dom document
void append(const T &value)
void removeKey(const QString &keyName)
remove the given key
QStringList subkeyList(const QString &scope, const QString &key) const
return keys with keys – do not return keys that contain only values
void initializeEmbeddedSubtree(const QString &projectFilePath, QgsLayerTreeGroup *group)
QVariant property(const char *name) const
const_iterator constEnd() const
QString canonicalPath() const
int toInt(bool *ok) const
Pixels unit of tolerance.
QList< QgsMapLayer * > addMapLayers(QList< QgsMapLayer * > theMapLayers, bool addToLegend=true, bool takeOwnership=true)
Add a list of layers to the map of loaded layers.
virtual void clearKeys()
delete any sub-nodes
void setAttribute(const QString &name, const QString &value)
A class to describe the version of a project.
QDomNodeList elementsByTagName(const QString &tagname) const
void setBadLayerHandler(QgsProjectBadLayerHandler *handler)
Change handler for missing layers.
int removeAll(const T &value)
void readProject(const QDomDocument &)
emitted when project is being read
Listens to the updates in map layer registry and does changes in layer tree.
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
static void replaceChildrenOfEmbeddedGroups(QgsLayerTreeGroup *group)
Remove subtree of embedded groups and replaces it with a custom property embedded-visible-layers.
void layerLoaded(int i, int n)
emitted when a layer from a projects was read
QString fileName() const
returns file name
This class is a base class for nodes in a layer tree.
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
bool removeEntry(const QString &scope, const QString &key)
remove the given key
static void updateEmbeddedGroupsProjectPath(QgsLayerTreeGroup *group)
Reads and writes project states.
void setVisible(Qt::CheckState visible)
virtual QgsLayerTreeNode * clone() const override
Return a clone of the group. The children are cloned too.
void writeMapLayer(QgsMapLayer *mapLayer, QDomElement &layerElem, QDomDocument &doc)
Emitted, when a layer is being saved.
QString error() const
Return error message from previous read/write.
QString name() const
Get group's name.
int remove(const Key &key)
QList< QgsLayerTreeNode * > children()
Get list of children of the node. Children are owned by the parent.
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
bool isLayer(QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
An Abstract Base Class for QGIS project property hierarchies.
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
bool hasChildNodes() const
double readDoubleEntry(const QString &scope, const QString &key, double def=0, bool *ok=0) const
QgsProperty * find(QString &propertyName)
QDomText createTextNode(const QString &value)
const T value(const Key &key) const
iterator find(const Key &key)
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
void subkeyList(QStringList &entries) const
return keys that contain other keys
QDomNode removeChild(const QDomNode &oldChild)
QDomNode namedItem(const QString &name) const
QgsLayerTreeGroup * createEmbeddedGroup(const QString &groupName, const QString &projectFilePath, const QStringList &invisibleLayers)
Create layer group instance defined in an arbitrary project file.
void clearError()
Clear error message.
void setError(QString errorMessage)
Set error message from read/write operation.
bool isDirty() const
the dirty flag is true if the project has been modified since the last write()
bool contains(const T &value) const
QString & replace(int position, int n, QChar after)
bool addLayer(const QDomElement &layerElem, QList< QDomNode > &brokenNodes, QList< QPair< QgsVectorLayer *, QDomElement > > &vectorLayerList)
void setInvalidDataPolicy(InvalidDataPolicy policy)
void writeProject(QDomDocument &)
emitted when project is being written
virtual QString dump() const override
Return text representation of the tree. For debugging purposes only.
QDomNode firstChild() const
QString readEntry(const QString &scope, const QString &key, const QString &def=QString::null, bool *ok=0) const
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QString mid(int position, int n) const
QStringList toStringList() const
QgsLayerTreeLayer * toLayer(QgsLayerTreeNode *node)
Cast node to a layer. No type checking is done - use isLayer() to find out whether this operation is ...
void insert(int i, const T &value)
This class manages a set of relations between layers.
QStringList findLayerIds() const
Find layer IDs used in all layer nodes. Searches recursively the whole sub-tree.
QgsLayerTreeGroup * findGroup(const QString &name)
Find group node with specified name. Searches recursively the whole sub-tree.
static QgsProject * instance()
access to canonical QgsProject instance
QDomElement firstChildElement(const QString &tagName) const
static void removeKey_(QString const &scope, QString const &key, QgsPropertyKey &rootProperty)
void setTitle(const QString &title)
Set project title.
StandardButton critical(QWidget *parent, const QString &title, const QString &text, QFlags< QMessageBox::StandardButton > buttons, StandardButton defaultButton)
void loadingLayer(QString)
const QMap< QString, QgsMapLayer * > & mapLayers()
Retrieve the mapLayers collection (mainly intended for use by projection)
void setEnabled(bool enabled)
bool readXML(QDomNode &keyNode) override
restores property hierarchy to given Dom node
QStringList entryList(const QString &scope, const QString &key) const
return keys with values – do not return keys that contain other keys
QgsLayerTreeLayer * findLayer(const QString &layerId) const
Find layer node representing the map layer specified by its ID. Searches recursively the whole sub-tr...
bool readLayerXML(const QDomElement &layerElement)
sets state from Dom document
int indexOf(const QRegExp &rx, int from) const
void prepend(const T &value)
double toDouble(bool *ok) const
const QString & title() const
returns title
void dumpProperties() const
dump out current project properties to stderr
void clearProperties()
removes all project properties
static QgsPluginLayerRegistry * instance()
means of accessing canonical single instance
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 nav...
const QString & name() const
every key has a name
void readMapLayer(QgsMapLayer *mapLayer, const QDomElement &layerNode)
Emitted, after the basic initialisation of a layer from the project file is done. ...
QgsLayerTreeGroup * layerTreeRoot() const
Return pointer to the root (invisible) node of the project's layer tree.
Default bad layer handler which ignores any missing layers.
virtual bool isKey() const =0
returns true if is a QgsPropertyKey
QDomDocumentType createDocumentType(const QString &qName, const QString &publicId, const QString &systemId)
Represents a vector layer which manages a vector based data sets.
int compare(const QString &other) const
QgsRelationManager * relationManager() const
bool isGroup(QgsLayerTreeNode *node)
Check whether the node is a valid group node.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
bool removeOne(const T &value)
virtual bool isValue() const =0
returns true if is a QgsPropertyValue
static void dump_(QgsPropertyKey const &topQgsPropertyKey)
void clear()
Clear the project.
Interface for classes that handle missing layer files when reading project file.
Layer tree node points to a map layer.
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for the node.
QDomNode at(int index) const
bool setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
void dump(int tabs=0) const override
dumps out the keys and values
const T value(const Key &key) const
void snapSettingsChanged()
virtual void handleBadLayers(QList< QDomNode > layers, QDomDocument projectDom)=0