41 #include <QApplication>
45 #include <QTextStream>
64 keyTokens += key.
split(
'/', QString::SkipEmptyParts );
94 while ( !keySequence.
isEmpty() )
98 if ( keySequence.
first() == currentProperty->
name() )
103 if ( 1 == keySequence.
count() )
106 return currentProperty->
find( keySequence.
front() );
108 else if ( keySequence.
isEmpty() )
113 return currentProperty;
115 else if (( nextProperty = currentProperty->
find( keySequence.
first() ) ) )
117 if ( nextProperty->
isKey() )
121 else if ( nextProperty->
isValue() && 1 == keySequence.
count() )
127 return currentProperty;
173 while ( ! keySequence.
isEmpty() )
177 if ( keySequence.
first() == currentProperty->
name() )
184 if ( 1 == keySequence.
count() )
187 return currentProperty;
191 else if ( keySequence.
isEmpty() )
195 return currentProperty;
197 else if (( nextProperty = currentProperty->
find( keySequence.
first() ) ) )
201 if ( currentProperty )
212 if (( newPropertyKey = currentProperty->
addKey( keySequence.
first() ) ) )
214 currentProperty = newPropertyKey;
243 while ( ! keySequence.
isEmpty() )
247 if ( keySequence.
first() == currentProperty->
name() )
254 if ( 1 == keySequence.
count() )
261 else if ( keySequence.
isEmpty() )
263 previousQgsPropertyKey->
removeKey( currentProperty->
name() );
265 else if (( nextProperty = currentProperty->
find( keySequence.
first() ) ) )
267 previousQgsPropertyKey = currentProperty;
270 if ( currentProperty )
307 properties_.
name() =
"properties";
326 QgsProject::QgsProject()
344 delete mBadLayerHandler;
345 delete mRelationManager;
396 imp_->file.setFileName( name );
405 return imp_->file.fileName();
416 mEmbeddedLayers.
clear();
417 mRelationManager->
clear();
425 writeEntry(
"PositionPrecision",
"/Automatic",
true );
426 writeEntry(
"PositionPrecision",
"/DecimalPlaces", 2 );
436 topQgsPropertyKey.
dump();
476 if ( properties.
count() > 1 )
478 QgsDebugMsg(
"there appears to be more than one ``properties'' XML tag ... bailing" );
481 else if ( properties.
count() < 1 )
489 if ( scopes.
count() < 1 )
491 QgsDebugMsg(
"empty ``properties'' XML tag ... bailing" );
497 if ( ! project_properties.
readXML( propertyNode ) )
499 QgsDebugMsg(
"Project_properties.readXML() failed" );
539 if ( !titleTextNode.
isText() )
547 title = titleText.
data();
562 QgsDebugMsg(
" unable to find qgis element in project file" );
570 return projectVersion;
636 if ( 0 == nl.
count() )
638 return qMakePair(
true, brokenNodes );
646 bool returnStatus =
true;
654 for (
int i = 0; i < nl.
count(); i++ )
663 if ( element.
attribute(
"embedded" ) ==
"1" )
670 if ( !
addLayer( element, brokenNodes, vLayerList ) )
672 returnStatus =
false;
681 for ( ; vIt != vLayerList.
end(); ++vIt )
683 vIt->
first->createJoinCaches();
684 vIt->
first->updateFields();
688 for ( vIt = vLayerList.
begin(); vIt != vLayerList.
end(); ++vIt )
693 notified << vIt->
first;
699 return qMakePair( returnStatus, brokenNodes );
708 if ( type ==
"vector" )
712 else if ( type ==
"raster" )
716 else if ( type ==
"plugin" )
729 Q_CHECK_PTR( mapLayer );
739 vectorLayerList.push_back( qMakePair( vLayer, layerElem ) );
742 myLayers << mapLayer;
751 QgsDebugMsg(
"Unable to load " + type +
" layer" );
763 imp_->file.setFileName( file.
filePath() );
779 if ( !imp_->file.open( QIODevice::ReadOnly | QIODevice::Text ) )
783 setError(
tr(
"Unable to open %1" ).arg( imp_->file.fileName() ) );
792 if ( !doc->setContent( &imp_->file, &errorMsg, &line, &column ) )
797 tr(
"%1 at line %2 column %3" ).arg( errorMsg ).arg( line ).arg( column ) );
800 QString errorString =
tr(
"Project file read error: %1 at line %2 column %3" )
801 .
arg( errorMsg ).
arg( line ).
arg( column );
807 setError(
tr(
"%1 for file %2" ).arg( errorString, imp_->file.fileName() ) );
815 QgsDebugMsg(
"Opened document " + imp_->file.fileName() );
822 if ( thisVersion > fileVersion )
825 "version of qgis (saved in " + fileVersion.
text() +
827 "). Problems may occur." );
833 QgsDebugMsg(
"Emitting oldProjectVersionWarning(oldVersion)." );
835 projectFile.updateRevision( thisVersion );
841 imp_->file.setFileName( fileName );
848 dump_( imp_->properties_ );
857 QDomElement layerTreeElem = doc->documentElement().firstChildElement(
"layer-tree-group" );
858 if ( !layerTreeElem.
isNull() )
869 mLayerTreeRegistryBridge->
setEnabled(
false );
875 bool clean = getMapLayersResults.first;
879 QgsDebugMsg(
"Unable to get map layers from project file." );
881 if ( ! getMapLayersResults.second.isEmpty() )
902 mVisibilityPresetCollection->readXML( *doc );
934 clonedChildren << newGroupChild->
clone();
970 imp_->file.setFileName( file.
filePath() );
992 if ( !imp_->file.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
997 setError(
tr(
"Unable to save to file %1" ).arg( imp_->file.fileName() ) );
1006 setError(
tr(
"%1 is not writable. Please adjust permissions (if possible) and try again." )
1007 .arg( imp_->file.fileName() ) );
1021 QDomElement qgisNode = doc->createElement(
"qgis" );
1025 doc->appendChild( qgisNode );
1028 QDomElement titleNode = doc->createElement(
"title" );
1049 QDomElement projectLayersNode = doc->createElement(
"projectlayers" );
1050 projectLayersNode.
setAttribute(
"layercount", qulonglong( layers.
size() ) );
1053 while ( li != layers.
end() )
1061 if ( emIt == mEmbeddedLayers.
constEnd() )
1064 QDomElement maplayerElem = doc->createElement(
"maplayer" );
1076 if ( emIt.value().second )
1078 QDomElement mapLayerElem = doc->createElement(
"maplayer" );
1093 dump_( imp_->properties_ );
1095 QgsDebugMsg(
QString(
"there are %1 property scopes" ).arg( static_cast<int>( imp_->properties_.count() ) ) );
1097 if ( !imp_->properties_.isEmpty() )
1100 imp_->properties_.writeXML(
"properties", qgisNode, *doc );
1103 mVisibilityPresetCollection->writeXML( *doc );
1110 doc->save( projectFileStream, 2 );
1116 if ( projectFileStream.
pos() == -1 || imp_->file.error() != QFile::NoError )
1118 setError(
tr(
"Unable to save to file %1. Your project "
1119 "may be corrupted on disk. Try clearing some space on the volume and "
1120 "check file permissions before pressing save again." )
1121 .arg( imp_->file.fileName() ) );
1148 return addKey_( scope, key, &imp_->properties_, value );
1158 return addKey_( scope, key, &imp_->properties_, value );
1167 return addKey_( scope, key, &imp_->properties_, value );
1177 return addKey_( scope, key, &imp_->properties_, value );
1187 return addKey_( scope, key, &imp_->properties_, value );
1202 value =
property->
value();
1204 bool valid = QVariant::StringList == value.
type();
1230 value =
property->
value();
1232 bool valid = value.
canConvert( QVariant::String );
1254 value =
property->
value();
1257 bool valid = value.
canConvert( QVariant::String );
1266 return value.
toInt();
1283 bool valid = value.
canConvert( QVariant::Double );
1305 bool valid = value.
canConvert( QVariant::Bool );
1323 return !
findKey_( scope, key, imp_->properties_ );
1334 if ( foundProperty )
1352 if ( foundProperty )
1368 dump_( imp_->properties_ );
1386 if ( src.
startsWith(
"/vsi", Qt::CaseInsensitive ) )
1395 #if defined(Q_OS_WIN)
1398 ( src[0].isLetter() && src[1] ==
':' ) )
1401 return vsiPrefix + src;
1404 if ( src[0] ==
'/' )
1407 return vsiPrefix + src;
1417 return vsiPrefix + src;
1423 return vsiPrefix + src;
1436 return vsiPrefix + src;
1439 #if defined(Q_OS_WIN)
1441 projPath.
replace(
"\\",
"/" );
1449 #if defined(Q_OS_WIN)
1452 projElems.
insert( 0,
"" );
1453 projElems.
insert( 0,
"" );
1461 projElems << srcElems;
1466 while (( pos = projElems.
indexOf(
".." ) ) > 0 )
1473 #if !defined(Q_OS_WIN)
1478 return vsiPrefix + projElems.
join(
"/" );
1494 if ( !relativeBasePath.
isNull() )
1496 projPath = relativeBasePath;
1511 #if defined( Q_OS_WIN )
1512 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1519 srcPath =
"\\\\" + srcPath.
mid( 2 );
1522 projPath.
replace(
"\\",
"/" );
1526 projPath =
"\\\\" + projPath.
mid( 2 );
1529 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1543 while ( srcElems.
size() > 0 &&
1544 projElems.
size() > 0 &&
1545 srcElems[0].compare( projElems[0], cs ) == 0 )
1558 if ( projElems.
size() > 0 )
1561 for (
int i = 0; i < projElems.
size(); i++ )
1563 srcElems.
insert( 0,
".." );
1570 srcElems.
insert( 0,
"." );
1573 return vsiPrefix + srcElems.
join(
"/" );
1578 mErrorMessage = errorMessage;
1583 return mErrorMessage;
1593 delete mBadLayerHandler;
1594 mBadLayerHandler = handler;
1600 if ( it == mEmbeddedLayers.
constEnd() )
1604 return it.
value().first;
1612 static QString prevProjectFilePath;
1615 if ( projectFilePath != prevProjectFilePath )
1617 prevProjectFilePath.
clear();
1619 QFile projectFile( projectFilePath );
1620 if ( !projectFile.
open( QIODevice::ReadOnly ) )
1625 if ( !projectDocument.
setContent( &projectFile ) )
1630 prevProjectFilePath = projectFilePath;
1634 bool useAbsolutePathes =
true;
1637 if ( !propertiesElem.
isNull() )
1642 useAbsolutePathes = absElem.
text().
compare(
"true", Qt::CaseInsensitive ) == 0;
1647 if ( projectLayersElem.
isNull() )
1653 for (
int i = 0; i < mapLayerNodes.
size(); ++i )
1658 if (
id == layerId )
1661 if ( mapLayerElem.
attribute(
"embedded" ) ==
"1" )
1666 mEmbeddedLayers.
insert( layerId, qMakePair( projectFilePath, saveFlag ) );
1670 if ( !useAbsolutePathes )
1674 QString datasource( dsElem.text() );
1675 if ( provider ==
"spatialite" )
1679 if ( absoluteDs.exists() )
1682 datasource = uri.
uri();
1685 else if ( provider ==
"ogr" )
1687 QStringList theURIParts( datasource.split(
"|" ) );
1688 QFileInfo absoluteDs(
QFileInfo( projectFilePath ).absolutePath() +
"/" + theURIParts[0] );
1689 if ( absoluteDs.exists() )
1691 theURIParts[0] = absoluteDs.absoluteFilePath();
1692 datasource = theURIParts.join(
"|" );
1695 else if ( provider ==
"gpx" )
1697 QStringList theURIParts( datasource.split(
"?" ) );
1698 QFileInfo absoluteDs(
QFileInfo( projectFilePath ).absolutePath() +
"/" + theURIParts[0] );
1699 if ( absoluteDs.exists() )
1701 theURIParts[0] = absoluteDs.absoluteFilePath();
1702 datasource = theURIParts.join(
"?" );
1705 else if ( provider ==
"delimitedtext" )
1709 if ( !datasource.startsWith(
"file:" ) )
1713 urlSource.
setPath( file.path() );
1717 if ( absoluteDs.exists() )
1726 QFileInfo absoluteDs(
QFileInfo( projectFilePath ).absolutePath() +
"/" + datasource );
1727 if ( absoluteDs.
exists() )
1733 dsElem.removeChild( dsElem.childNodes().at( 0 ) );
1734 dsElem.appendChild( projectDocument.
createTextNode( datasource ) );
1737 if (
addLayer( mapLayerElem, brokenNodes, vectorLayerList ) )
1743 mEmbeddedLayers.
remove( layerId );
1756 QFile projectFile( projectFilePath );
1757 if ( !projectFile.
open( QIODevice::ReadOnly ) )
1763 if ( !projectDocument.
setContent( &projectFile ) )
1771 if ( !disabledLayersElem.
isNull() )
1774 for (
int i = 0; i < valueList.
size(); ++i )
1783 if ( !layerTreeElem.
isNull() )
1809 mLayerTreeRegistryBridge->
setEnabled(
false );
1811 mLayerTreeRegistryBridge->
setEnabled(
true );
1816 if ( embeddedIdentifyDisabledLayers.
contains( layerId ) )
1819 thisProjectIdentifyDisabledLayers.
append( layerId );
1826 layer->
setVisible( invisibleLayers.
contains( layerId ) ? Qt::Unchecked : Qt::Checked );
1856 QStringList layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList;
1857 snapSettings( layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList );
1858 int idx = layerIdList.
indexOf( layerId );
1866 avoidIntersectionList.
removeOne( layerId );
1869 layerIdList.
append( layerId );
1872 enabledList.
append( enabled ?
"enabled" :
"disabled" );
1878 typeString =
"to_segment";
1882 typeString =
"to_vertex_and_segment";
1886 typeString =
"to_vertex";
1888 snapTypeList.
append( typeString );
1897 if ( avoidIntersection )
1899 avoidIntersectionList.
append( layerId );
1902 writeEntry(
"Digitizing",
"/LayerSnappingList", layerIdList );
1903 writeEntry(
"Digitizing",
"/LayerSnappingEnabledList", enabledList );
1904 writeEntry(
"Digitizing",
"/LayerSnappingToleranceList", toleranceList );
1905 writeEntry(
"Digitizing",
"/LayerSnappingToleranceUnitList", toleranceUnitList );
1906 writeEntry(
"Digitizing",
"/LayerSnapToList", snapTypeList );
1907 writeEntry(
"Digitizing",
"/AvoidIntersectionsList", avoidIntersectionList );
1912 bool &avoidIntersection )
const
1914 QStringList layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList;
1915 snapSettings( layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList );
1916 int idx = layerIdList.
indexOf( layerId );
1923 int minListEntries = idx + 1;
1924 if ( layerIdList.
size() < minListEntries || enabledList.
size() < minListEntries || snapTypeList.
size() < minListEntries ||
1925 toleranceUnitList.
size() < minListEntries || toleranceList.
size() < minListEntries )
1931 enabled = enabledList.
at( idx ) ==
"enabled";
1934 QString snapType = snapTypeList.
at( idx );
1935 if ( snapType ==
"to_segment" )
1939 else if ( snapType ==
"to_vertex_and_segment" )
1949 if ( toleranceUnitList.
at( idx ) ==
"1" )
1953 else if ( toleranceUnitList.
at( idx ) ==
"2" )
1963 tolerance = toleranceList.
at( idx ).toDouble();
1966 avoidIntersection = ( avoidIntersectionList.
indexOf( layerId ) != -1 );
1974 layerIdList =
readListEntry(
"Digitizing",
"/LayerSnappingList" );
1975 enabledList =
readListEntry(
"Digitizing",
"/LayerSnappingEnabledList" );
1976 toleranceList =
readListEntry(
"Digitizing",
"/LayerSnappingToleranceList" );
1977 toleranceUnitList =
readListEntry(
"Digitizing",
"/LayerSnappingToleranceUnitList" );
1978 snapTypeList =
readListEntry(
"Digitizing",
"/LayerSnapToList" );
1979 avoidIntersectionList =
readListEntry(
"Digitizing",
"/AvoidIntersectionsList" );
2002 return QString::null;
2009 return mRelationManager;
2019 return mVisibilityPresetCollection.
data();
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
QString fromAscii(const char *str, int size)
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.
QString writePath(const QString &filename, const QString &relativeBasePath=QString::null) const
Prepare a filename to save it to the project file.
const QList< QgsVectorJoinInfo > vectorJoins() const
iterator insert(const Key &key, const T &value)
QDomNode item(int index) const
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 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)
QList< QgsMapLayer * > addMapLayers(const QList< QgsMapLayer * > &theMapLayers, bool addToLegend=true, bool takeOwnership=true)
Add a list of layers to the map of loaded layers.
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.
Pixels unit of tolerance.
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 void warning(const QString &msg)
Goes to qWarning.
QList< QPair< QString, QString > > queryItems() const
void oldProjectVersionWarning(QString)
emitted when an old project file is read.
void setDatabase(const QString &database)
Set database.
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.
void setFileName(const QString &name)
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
void setError(const QString &errorMessage)
Set error message from read/write operation.
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 setDirty(bool b)
Set project as dirty (modified).
void projectSaved()
emitted when the project file has been written and closed
QDomNodeList childNodes() const
bool writeLayerXML(QDomElement &layerElement, QDomDocument &document, const QString &relativeBasePath=QString::null)
Stores state in Dom node.
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
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 ...
static QgsProperty * addKey_(QString const &scope, QString const &key, QgsPropertyKey *rootProperty, const QVariant &value)
Add the given key and value.
QDomElement toElement() const
void setPath(const QString &path)
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
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
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.
QString absoluteFilePath() const
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
void setScheme(const QString &scheme)
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.
bool isValid()
Return the status of the layer.
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)
void insertChildNodes(int index, const 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.
QString toLocalFile() const
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 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.
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
QString qgsVsiPrefix(const QString &path)
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...
void setQueryItems(const QList< QPair< QString, QString > > &query)
bool readLayerXML(const QDomElement &layerElement)
Sets state from Dom document.
Container class that allows storage of visibility presets consisting of visible map layers and layer ...
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. ...
UnitType
Type of unit of tolerance value from settings.
QFileInfo fileInfo() const
Returns QFileInfo object for the project's associated file.
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.
QString uri(bool expandAuthConfig=true) const
return complete uri
virtual bool isKey() const =0
Returns true if is a QgsPropertyKey.
QDomDocumentType createDocumentType(const QString &qName, const QString &publicId, const QString &systemId)
QgsVisibilityPresetCollection * visibilityPresetCollection()
Returns pointer to the project's visibility preset collection.
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)
QgsPluginLayer * createLayer(const QString &typeName, const QString &uri=QString())
Return new layer if corresponding plugin has been found, else return NULL.
QUrl fromEncoded(const QByteArray &input)
QByteArray toEncoded(QFlags< QUrl::FormattingOption > options) const
void clear()
Clear the project.
Interface for classes that handle missing layer files when reading project file.
QStringList readListEntry(const QString &scope, const QString &key, const QStringList &def=QStringList(), bool *ok=0) const
Key value accessors.
QUrl fromLocalFile(const QString &localFile)
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