QGIS API Documentation
3.0.2-Girona (307d082)
|
Reads and writes project states. More...
#include <qgsproject.h>
Public Slots | |
void | setDirty (bool b=true) |
Flag the project as dirty (modified). More... | |
void | setSnappingConfig (const QgsSnappingConfig &snappingConfig) |
The snapping configuration for this project. More... | |
Signals | |
void | avoidIntersectionsLayersChanged () |
Emitted whenever avoidIntersectionsLayers has changed. More... | |
void | crsChanged () |
Emitted when the CRS of the project has changed. More... | |
void | customVariablesChanged () |
Emitted whenever the expression variables stored in the project have been changed. More... | |
void | ellipsoidChanged (const QString &ellipsoid) |
Emitted when the project ellipsoid is changed. More... | |
void | fileNameChanged () |
Emitted when the file name of the project changes. More... | |
void | homePathChanged () |
Emitted when the home path of the project changes. More... | |
void | labelingEngineSettingsChanged () |
Emitted when global configuration of the labeling engine changes. More... | |
void | layerLoaded (int i, int n) |
Emitted when a layer from a projects was read. More... | |
void | layerRemoved (const QString &layerId) |
Emitted after a layer was removed from the registry. More... | |
void | layersAdded (const QList< QgsMapLayer *> &layers) |
Emitted when one or more layers were added to the registry. More... | |
void | layersRemoved (const QStringList &layerIds) |
Emitted after one or more layers were removed from the registry. More... | |
void | layersWillBeRemoved (const QStringList &layerIds) |
Emitted when one or more layers are about to be removed from the registry. More... | |
void | layersWillBeRemoved (const QList< QgsMapLayer *> &layers) |
Emitted when one or more layers are about to be removed from the registry. More... | |
void | layerWasAdded (QgsMapLayer *layer) |
Emitted when a layer was added to the registry. More... | |
void | layerWillBeRemoved (const QString &layerId) |
Emitted when a layer is about to be removed from the registry. More... | |
void | layerWillBeRemoved (QgsMapLayer *layer) |
Emitted when a layer is about to be removed from the registry. More... | |
void | legendLayersAdded (const QList< QgsMapLayer *> &layers) |
Emitted, when a layer was added to the registry and the legend. More... | |
void | loadingLayer (const QString &) |
void | mapThemeCollectionChanged () |
Emitted when the map theme collection changes. More... | |
void | missingDatumTransforms (const QStringList &missingTransforms) |
Emitted when datum transforms stored in the project are not available locally. More... | |
void | nonIdentifiableLayersChanged (QStringList nonIdentifiableLayers) |
Emitted when the list of layer which are excluded from map identification changes. More... | |
void | oldProjectVersionWarning (const QString &) |
emitted when an old project file is read. More... | |
void | projectSaved () |
emitted when the project file has been written and closed More... | |
void | readMapLayer (QgsMapLayer *mapLayer, const QDomElement &layerNode) |
Emitted, after the basic initialization of a layer from the project file is done. More... | |
void | readProject (const QDomDocument &) |
emitted when project is being read More... | |
void | removeAll () |
Emitted when all layers are removed, before layersWillBeRemoved() and layerWillBeRemoved() signals are emitted. More... | |
void | snappingConfigChanged (const QgsSnappingConfig &config) |
emitted whenever the configuration for snapping has changed More... | |
void | topologicalEditingChanged () |
Emitted when the topological editing flag has changed. More... | |
void | transactionGroupsChanged () |
Emitted whenever a new transaction group has been created or a transaction group has been removed. More... | |
void | transformContextChanged () |
Emitted when the project transformContext() is changed. More... | |
void | writeMapLayer (QgsMapLayer *mapLayer, QDomElement &layerElem, QDomDocument &doc) |
Emitted, when a layer is being saved. More... | |
void | writeProject (QDomDocument &) |
emitted when project is being written More... | |
Public Member Functions | |
QgsProject (QObject *parent=nullptr) | |
Create a new QgsProject. More... | |
~QgsProject () override | |
QgsMapLayer * | addMapLayer (QgsMapLayer *mapLayer, bool addToLegend=true, bool takeOwnership=true) |
Add a layer to the map of loaded layers. More... | |
QList< QgsMapLayer * > | addMapLayers (const QList< QgsMapLayer *> &mapLayers, bool addToLegend=true, bool takeOwnership=true) |
Add a list of layers to the map of loaded layers. More... | |
QgsAnnotationManager * | annotationManager () |
Returns pointer to the project's annotation manager. More... | |
const QgsAnnotationManager * | annotationManager () const |
Returns a const pointer to the project's annotation manager. More... | |
QgsUnitTypes::AreaUnit | areaUnits () const |
Convenience function to query default area measurement units for project. More... | |
bool | autoTransaction () const |
Transactional editing means that on supported datasources (postgres databases) the edit state of all tables that originate from the same database are synchronized and executed in a server side transaction. More... | |
const QgsAuxiliaryStorage * | auxiliaryStorage () const |
Returns the current const auxiliary storage. More... | |
QgsAuxiliaryStorage * | auxiliaryStorage () |
Returns the current auxiliary storage. More... | |
QList< QgsVectorLayer * > | avoidIntersectionsLayers () const |
A list of layers with which intersections should be avoided. More... | |
void | clear () |
Clear the project - removes all settings and resets it back to an empty, default state. More... | |
int | count () const |
Returns the number of registered layers. More... | |
QgsLayerTreeGroup * | createEmbeddedGroup (const QString &groupName, const QString &projectFilePath, const QStringList &invisibleLayers) |
Create layer group instance defined in an arbitrary project file. More... | |
bool | createEmbeddedLayer (const QString &layerId, const QString &projectFilePath, QList< QDomNode > &brokenNodes, bool saveFlag=true) |
Creates a maplayer instance defined in an arbitrary project file. More... | |
QgsExpressionContext | createExpressionContext () const override |
This method needs to be reimplemented in all classes which implement this interface and return an expression context. More... | |
QgsCoordinateReferenceSystem | crs () const |
Returns the project's native coordinate reference system. More... | |
QVariantMap | customVariables () const |
A map of custom project variables. More... | |
QgsCoordinateReferenceSystem | defaultCrsForNewLayers () const |
Returns the default CRS for new layers based on the settings and the current project CRS. More... | |
QgsUnitTypes::DistanceUnit | distanceUnits () const |
Convenience function to query default distance measurement units for project. More... | |
void | dumpProperties () const |
Dump out current project properties to stderr. More... | |
QString | ellipsoid () const |
Returns a proj string representing the project's ellipsoid setting, e.g., "WGS84". More... | |
QStringList | entryList (const QString &scope, const QString &key) const |
Return keys with values – do not return keys that contain other keys. More... | |
QString | error () const |
Return error message from previous read/write. More... | |
bool | evaluateDefaultValues () const |
Should default values be evaluated on provider side when requested and not when committed. More... | |
QFileInfo | fileInfo () const |
Returns QFileInfo object for the project's associated file. More... | |
QString | fileName () const |
Returns the project's file name. More... | |
QString | homePath () const |
Return project's home path. More... | |
bool | isDirty () const |
Returns true if the project has been modified since the last write() More... | |
bool | isZipped () const |
Returns true if the project comes from a zip archive, false otherwise. More... | |
const QgsLabelingEngineSettings & | labelingEngineSettings () const |
Returns project's global labeling engine settings. More... | |
QString | layerIsEmbedded (const QString &id) const |
Returns project file path if layer is embedded from other project file. Returns empty string if layer is not embedded. More... | |
template<typename T > | |
QVector< T > | layers () const |
Returns a list of registered map layers with a specified layer type. More... | |
QgsMapLayerStore * | layerStore () |
Returns a pointer to the project's internal layer store. More... | |
const QgsMapLayerStore * | layerStore () const |
Returns a pointer to the project's internal layer store. More... | |
QgsLayerTreeRegistryBridge * | layerTreeRegistryBridge () const |
Return pointer to the helper class that synchronizes map layer registry with layer tree. More... | |
QgsLayerTree * | layerTreeRoot () const |
Return pointer to the root (invisible) node of the project's layer tree. More... | |
const QgsLayoutManager * | layoutManager () const |
Returns the project's layout manager, which manages compositions within the project. More... | |
QgsLayoutManager * | layoutManager () |
Returns the project's layout manager, which manages compositions within the project. More... | |
QgsMapLayer * | mapLayer (const QString &layerId) const |
Retrieve a pointer to a registered layer by layer ID. More... | |
QMap< QString, QgsMapLayer * > | mapLayers () const |
Returns a map of all registered layers by layer ID. More... | |
QList< QgsMapLayer * > | mapLayersByName (const QString &layerName) const |
Retrieve a list of matching registered layers by layer name. More... | |
QgsMapThemeCollection * | mapThemeCollection () |
Returns pointer to the project's map theme collection. More... | |
QStringList | nonIdentifiableLayers () const |
Get the list of layers which currently should not be taken into account on map identification. More... | |
QgsPathResolver | pathResolver () const |
Return path resolver object with considering whether the project uses absolute or relative paths and using current project's path. More... | |
bool | read (const QString &filename) |
Reads given project file from the given file. More... | |
bool | read () |
Reads the project from its currently associated file (see fileName() ). More... | |
bool | readBoolEntry (const QString &scope, const QString &key, bool def=false, bool *ok=nullptr) const |
double | readDoubleEntry (const QString &scope, const QString &key, double def=0, bool *ok=nullptr) const |
QString | readEntry (const QString &scope, const QString &key, const QString &def=QString(), bool *ok=nullptr) const |
bool | readLayer (const QDomNode &layerNode) |
Reads the layer described in the associated DOM node. More... | |
QStringList | readListEntry (const QString &scope, const QString &key, const QStringList &def=QStringList(), bool *ok=nullptr) const |
Key value accessors. More... | |
int | readNumEntry (const QString &scope, const QString &key, int def=0, bool *ok=nullptr) const |
QString | readPath (const QString &filename) const |
Turn filename read from the project file to an absolute path. More... | |
QgsRelationManager * | relationManager () const |
void | reloadAllLayers () |
Reload all registered layer's provider data caches, synchronising the layer with any changes in the datasource. More... | |
void | removeAllMapLayers () |
Removes all registered layers. More... | |
bool | removeEntry (const QString &scope, const QString &key) |
Remove the given key. More... | |
void | removeMapLayer (const QString &layerId) |
Remove a layer from the registry by layer ID. More... | |
void | removeMapLayer (QgsMapLayer *layer) |
Remove a layer from the registry. More... | |
void | removeMapLayers (const QStringList &layerIds) |
Remove a set of layers from the registry by layer ID. More... | |
void | removeMapLayers (const QList< QgsMapLayer *> &layers) |
Remove a set of layers from the registry. More... | |
void | setAreaUnits (QgsUnitTypes::AreaUnit unit) |
Sets the default area measurement units for the project. More... | |
void | setAutoTransaction (bool autoTransaction) |
Transactional editing means that on supported datasources (postgres databases) the edit state of all tables that originate from the same database are synchronized and executed in a server side transaction. More... | |
void | setAvoidIntersectionsLayers (const QList< QgsVectorLayer *> &layers) |
A list of layers with which intersections should be avoided. More... | |
void | setBadLayerHandler (QgsProjectBadLayerHandler *handler) |
Change handler for missing layers. More... | |
void | setCrs (const QgsCoordinateReferenceSystem &crs) |
Sets the project's native coordinate reference system. More... | |
void | setCustomVariables (const QVariantMap &customVariables) |
A map of custom project variables. More... | |
void | setDistanceUnits (QgsUnitTypes::DistanceUnit unit) |
Sets the default distance measurement units for the project. More... | |
void | setEllipsoid (const QString &ellipsoid) |
Sets the project's ellipsoid from a proj string representation, e.g., "WGS84". More... | |
void | setEvaluateDefaultValues (bool evaluateDefaultValues) |
Defines if default values should be evaluated on provider side when requested and not when committed. More... | |
void | setFileName (const QString &name) |
Sets the file name associated with the project. More... | |
void | setLabelingEngineSettings (const QgsLabelingEngineSettings &settings) |
Sets project's global labeling engine settings. More... | |
void | setNonIdentifiableLayers (const QList< QgsMapLayer *> &layers) |
Set a list of layers which should not be taken into account on map identification. More... | |
void | setNonIdentifiableLayers (const QStringList &layerIds) |
Set a list of layers which should not be taken into account on map identification. More... | |
void | setTitle (const QString &title) |
Sets the project's title. More... | |
void | setTopologicalEditing (bool enabled) |
Convenience function to set topological editing. More... | |
void | setTransformContext (const QgsCoordinateTransformContext &context) |
Sets the project's coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system. More... | |
void | setTrustLayerMetadata (bool trust) |
Sets the trust option allowing to indicate if the extent has to be read from the XML document when data source has no metadata or if the data provider has to determine it. More... | |
QgsSnappingConfig | snappingConfig () const |
The snapping configuration for this project. More... | |
QStringList | subkeyList (const QString &scope, const QString &key) const |
Return keys with keys – do not return keys that contain only values. More... | |
QgsMapLayer * | takeMapLayer (QgsMapLayer *layer) |
Takes a layer from the registry. More... | |
QString | title () const |
Returns the project's title. More... | |
bool | topologicalEditing () const |
Convenience function to query topological editing status. More... | |
QMap< QPair< QString, QString >, QgsTransactionGroup * > | transactionGroups () |
Map of transaction groups. More... | |
QgsCoordinateTransformContext | transformContext () const |
Returns a copy of the project's coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system. More... | |
bool | trustLayerMetadata () const |
Returns true if the trust option is activated, false otherwise. More... | |
bool | write (const QString &filename) |
Writes the project to a file. More... | |
bool | write () |
Writes the project to its current associated file (see fileName() ). More... | |
bool | writeEntry (const QString &scope, const QString &key, bool value) |
Write a boolean entry to the project file. More... | |
bool | writeEntry (const QString &scope, const QString &key, double value) |
Write a double entry to the project file. More... | |
bool | writeEntry (const QString &scope, const QString &key, int value) |
Write an integer entry to the project file. More... | |
bool | writeEntry (const QString &scope, const QString &key, const QString &value) |
Write a string entry to the project file. More... | |
bool | writeEntry (const QString &scope, const QString &key, const QStringList &value) |
Write a string list entry to the project file. More... | |
QString | writePath (const QString &filename) const |
Prepare a filename to save it to the project file. More... | |
Public Member Functions inherited from QgsExpressionContextGenerator | |
virtual | ~QgsExpressionContextGenerator ()=default |
Static Public Member Functions | |
static QgsProject * | instance () |
Returns the QgsProject singleton instance. More... | |
Properties | |
QList< QgsVectorLayer * > | avoidIntersectionsLayers |
QgsCoordinateReferenceSystem | crs |
QString | ellipsoid |
QString | fileName |
QString | homePath |
QgsMapThemeCollection | mapThemeCollection |
QStringList | nonIdentifiableLayers |
QgsRelationManager | relationManager |
QgsSnappingConfig | snappingConfig |
Reads and writes project states.
Has two general kinds of state to make persistent. (I.e., to read and write.) First, QGIS proprietary information. Second plug-in information.
A singleton since there shall only be one active project at a time; and provides canonical location for plug-ins and main app to find/set properties.
Definition at line 82 of file qgsproject.h.
|
explicit |
Create a new QgsProject.
Most of the time you want to use QgsProject::instance() instead as many components of QGIS work with the singleton.
Definition at line 328 of file qgsproject.cpp.
|
override |
Definition at line 369 of file qgsproject.cpp.
QgsMapLayer * QgsProject::addMapLayer | ( | QgsMapLayer * | mapLayer, |
bool | addToLegend = true , |
||
bool | takeOwnership = true |
||
) |
Add a layer to the map of loaded layers.
The layersAdded() and layerWasAdded() signals will always be emitted. The legendLayersAdded() signal is emitted only if addToLegend is true. If you are adding multiple layers at once, you should use addMapLayers() instead.
mapLayer | A layer to add to the registry |
addToLegend | If true (by default), the layer will be added to the legend and to the main canvas. If you have a private layer you can set this parameter to false to hide it. |
takeOwnership | Ownership will be transferred to the layer registry. If you specify false here you have take care of deleting the layer yourself. Not available in Python. |
Definition at line 2325 of file qgsproject.cpp.
QList< QgsMapLayer * > QgsProject::addMapLayers | ( | const QList< QgsMapLayer *> & | mapLayers, |
bool | addToLegend = true , |
||
bool | takeOwnership = true |
||
) |
Add a list of layers to the map of loaded layers.
The layersAdded() and layerWasAdded() signals will always be emitted. The legendLayersAdded() signal is emitted only if addToLegend is true.
mapLayers | A list of layer which should be added to the registry |
addToLegend | If true (by default), the layers will be added to the legend and to the main canvas. If you have a private layer you can set this parameter to false to hide it. |
takeOwnership | Ownership will be transferred to the layer registry. If you specify false here you have take care of deleting the layers yourself. Not available in Python. |
Definition at line 2294 of file qgsproject.cpp.
QgsAnnotationManager * QgsProject::annotationManager | ( | ) |
Returns pointer to the project's annotation manager.
Definition at line 2107 of file qgsproject.cpp.
const QgsAnnotationManager * QgsProject::annotationManager | ( | ) | const |
Returns a const pointer to the project's annotation manager.
Definition at line 2112 of file qgsproject.cpp.
QgsUnitTypes::AreaUnit QgsProject::areaUnits | ( | ) | const |
Convenience function to query default area measurement units for project.
Definition at line 2055 of file qgsproject.cpp.
bool QgsProject::autoTransaction | ( | ) | const |
Transactional editing means that on supported datasources (postgres databases) the edit state of all tables that originate from the same database are synchronized and executed in a server side transaction.
Definition at line 2152 of file qgsproject.cpp.
const QgsAuxiliaryStorage * QgsProject::auxiliaryStorage | ( | ) | const |
Returns the current const auxiliary storage.
Definition at line 2441 of file qgsproject.cpp.
QgsAuxiliaryStorage * QgsProject::auxiliaryStorage | ( | ) |
Returns the current auxiliary storage.
Definition at line 2446 of file qgsproject.cpp.
QList<QgsVectorLayer *> QgsProject::avoidIntersectionsLayers | ( | ) | const |
A list of layers with which intersections should be avoided.
|
signal |
Emitted whenever avoidIntersectionsLayers has changed.
void QgsProject::clear | ( | ) |
Clear the project - removes all settings and resets it back to an empty, default state.
Definition at line 485 of file qgsproject.cpp.
int QgsProject::count | ( | ) | const |
Returns the number of registered layers.
Definition at line 2181 of file qgsproject.cpp.
QgsLayerTreeGroup * QgsProject::createEmbeddedGroup | ( | const QString & | groupName, |
const QString & | projectFilePath, | ||
const QStringList & | invisibleLayers | ||
) |
Create layer group instance defined in an arbitrary project file.
Definition at line 1900 of file qgsproject.cpp.
bool QgsProject::createEmbeddedLayer | ( | const QString & | layerId, |
const QString & | projectFilePath, | ||
QList< QDomNode > & | brokenNodes, | ||
bool | saveFlag = true |
||
) |
Creates a maplayer instance defined in an arbitrary project file.
Caller takes ownership
Definition at line 1815 of file qgsproject.cpp.
|
overridevirtual |
This method needs to be reimplemented in all classes which implement this interface and return an expression context.
Implements QgsExpressionContextGenerator.
Definition at line 1197 of file qgsproject.cpp.
QgsCoordinateReferenceSystem QgsProject::crs | ( | ) | const |
Returns the project's native coordinate reference system.
|
signal |
Emitted when the CRS of the project has changed.
QVariantMap QgsProject::customVariables | ( | ) | const |
A map of custom project variables.
To get all available variables including generated ones use QgsExpressionContextUtils::projectScope() instead.
Definition at line 1126 of file qgsproject.cpp.
|
signal |
Emitted whenever the expression variables stored in the project have been changed.
QgsCoordinateReferenceSystem QgsProject::defaultCrsForNewLayers | ( | ) | const |
Returns the default CRS for new layers based on the settings and the current project CRS.
Definition at line 2380 of file qgsproject.cpp.
QgsUnitTypes::DistanceUnit QgsProject::distanceUnits | ( | ) | const |
Convenience function to query default distance measurement units for project.
Definition at line 2037 of file qgsproject.cpp.
void QgsProject::dumpProperties | ( | ) | const |
Dump out current project properties to stderr.
Definition at line 1763 of file qgsproject.cpp.
QString QgsProject::ellipsoid | ( | ) | const |
Returns a proj string representing the project's ellipsoid setting, e.g., "WGS84".
|
signal |
QStringList QgsProject::entryList | ( | const QString & | scope, |
const QString & | key | ||
) | const |
Return keys with values – do not return keys that contain other keys.
Definition at line 1729 of file qgsproject.cpp.
QString QgsProject::error | ( | ) | const |
Return error message from previous read/write.
Definition at line 1789 of file qgsproject.cpp.
bool QgsProject::evaluateDefaultValues | ( | ) | const |
Should default values be evaluated on provider side when requested and not when committed.
Definition at line 2005 of file qgsproject.cpp.
QFileInfo QgsProject::fileInfo | ( | ) | const |
Returns QFileInfo object for the project's associated file.
Definition at line 441 of file qgsproject.cpp.
QString QgsProject::fileName | ( | ) | const |
Returns the project's file name.
This is the file which contains the project's XML representation.
|
signal |
Emitted when the file name of the project changes.
QString QgsProject::homePath | ( | ) | const |
Return project's home path.
|
signal |
Emitted when the home path of the project changes.
|
static |
Returns the QgsProject singleton instance.
Definition at line 383 of file qgsproject.cpp.
bool QgsProject::isDirty | ( | ) | const |
Returns true if the project has been modified since the last write()
Definition at line 409 of file qgsproject.cpp.
bool QgsProject::isZipped | ( | ) | const |
Returns true if the project comes from a zip archive, false otherwise.
Definition at line 2289 of file qgsproject.cpp.
const QgsLabelingEngineSettings & QgsProject::labelingEngineSettings | ( | ) | const |
Returns project's global labeling engine settings.
Definition at line 1161 of file qgsproject.cpp.
|
signal |
Emitted when global configuration of the labeling engine changes.
QString QgsProject::layerIsEmbedded | ( | const QString & | id | ) | const |
Returns project file path if layer is embedded from other project file. Returns empty string if layer is not embedded.
Definition at line 1805 of file qgsproject.cpp.
|
signal |
Emitted when a layer from a projects was read.
i | current layer |
n | number of layers |
|
signal |
Emitted after a layer was removed from the registry.
layerId | The ID of the layer removed. |
|
inline |
Returns a list of registered map layers with a specified layer type.
Example:
QVector<QgsVectorLayer*> vectorLayers = QgsProject::instance()->layers<QgsVectorLayer*>();
Definition at line 649 of file qgsproject.h.
|
signal |
Emitted when one or more layers were added to the registry.
This signal is also emitted for layers added to the registry, but not to the legend.
layers | List of layers which have been added. |
|
signal |
Emitted after one or more layers were removed from the registry.
layerIds | A list of IDs of the layers which were removed. |
QgsMapLayerStore * QgsProject::layerStore | ( | ) |
Returns a pointer to the project's internal layer store.
/since QGIS 3.0
Definition at line 1166 of file qgsproject.cpp.
const QgsMapLayerStore * QgsProject::layerStore | ( | ) | const |
Returns a pointer to the project's internal layer store.
/since QGIS 3.0
Definition at line 1171 of file qgsproject.cpp.
|
signal |
Emitted when one or more layers are about to be removed from the registry.
layerIds | A list of IDs for the layers which are to be removed. |
|
signal |
Emitted when one or more layers are about to be removed from the registry.
layers | A list of layers which are to be removed. |
|
inline |
Return pointer to the helper class that synchronizes map layer registry with layer tree.
Definition at line 456 of file qgsproject.h.
QgsLayerTree * QgsProject::layerTreeRoot | ( | ) | const |
Return pointer to the root (invisible) node of the project's layer tree.
Definition at line 2097 of file qgsproject.cpp.
|
signal |
Emitted when a layer was added to the registry.
|
signal |
Emitted when a layer is about to be removed from the registry.
layerId | The ID of the layer to be removed. |
|
signal |
Emitted when a layer is about to be removed from the registry.
layer | The layer to be removed. |
const QgsLayoutManager * QgsProject::layoutManager | ( | ) | const |
Returns the project's layout manager, which manages compositions within the project.
Definition at line 2087 of file qgsproject.cpp.
QgsLayoutManager * QgsProject::layoutManager | ( | ) |
Returns the project's layout manager, which manages compositions within the project.
Definition at line 2092 of file qgsproject.cpp.
|
signal |
Emitted, when a layer was added to the registry and the legend.
Layers can also be private layers, which are signalled by layersAdded() and layerWasAdded() but will not be advertised by this signal.
layers | List of QgsMapLayer which were added to the legend. |
|
signal |
QgsMapLayer * QgsProject::mapLayer | ( | const QString & | layerId | ) | const |
Retrieve a pointer to a registered layer by layer ID.
layerId | ID of layer to retrieve |
Definition at line 2186 of file qgsproject.cpp.
QMap< QString, QgsMapLayer * > QgsProject::mapLayers | ( | ) | const |
Returns a map of all registered layers by layer ID.
Definition at line 2374 of file qgsproject.cpp.
QList< QgsMapLayer * > QgsProject::mapLayersByName | ( | const QString & | layerName | ) | const |
Retrieve a list of matching registered layers by layer name.
layerName | name of layers to match |
Definition at line 2191 of file qgsproject.cpp.
QgsMapThemeCollection* QgsProject::mapThemeCollection | ( | ) |
Returns pointer to the project's map theme collection.
|
signal |
Emitted when the map theme collection changes.
This only happens when the map theme collection is reset. Any pointer previously received from mapThemeCollection() must no longer be used after this signal is emitted. You must still connect to signals from the map theme collection if you want to be notified about new map themes being added and map themes being removed.
|
signal |
Emitted when datum transforms stored in the project are not available locally.
QStringList QgsProject::nonIdentifiableLayers | ( | ) | const |
Get the list of layers which currently should not be taken into account on map identification.
|
signal |
Emitted when the list of layer which are excluded from map identification changes.
|
signal |
emitted when an old project file is read.
QgsPathResolver QgsProject::pathResolver | ( | ) | const |
Return path resolver object with considering whether the project uses absolute or relative paths and using current project's path.
Definition at line 1768 of file qgsproject.cpp.
|
signal |
emitted when the project file has been written and closed
bool QgsProject::read | ( | const QString & | filename | ) |
Reads given project file from the given file.
filename | name of project file to read |
Definition at line 783 of file qgsproject.cpp.
bool QgsProject::read | ( | ) |
Reads the project from its currently associated file (see fileName() ).
Definition at line 790 of file qgsproject.cpp.
bool QgsProject::readBoolEntry | ( | const QString & | scope, |
const QString & | key, | ||
bool | def = false , |
||
bool * | ok = nullptr |
||
) | const |
Definition at line 1698 of file qgsproject.cpp.
double QgsProject::readDoubleEntry | ( | const QString & | scope, |
const QString & | key, | ||
double | def = 0 , |
||
bool * | ok = nullptr |
||
) | const |
Definition at line 1678 of file qgsproject.cpp.
QString QgsProject::readEntry | ( | const QString & | scope, |
const QString & | key, | ||
const QString & | def = QString() , |
||
bool * | ok = nullptr |
||
) | const |
Definition at line 1627 of file qgsproject.cpp.
bool QgsProject::readLayer | ( | const QDomNode & | layerNode | ) |
Reads the layer described in the associated DOM node.
layerNode | represents a QgsProject DOM node that encodes a specific layer. |
Definition at line 1286 of file qgsproject.cpp.
QStringList QgsProject::readListEntry | ( | const QString & | scope, |
const QString & | key, | ||
const QStringList & | def = QStringList() , |
||
bool * | ok = nullptr |
||
) | const |
Key value accessors.
keys would be the familiar QgsSettings-like '/' delimited entries, implying a hierarchy of keys and corresponding values
Definition at line 1600 of file qgsproject.cpp.
|
signal |
Emitted, after the basic initialization of a layer from the project file is done.
You can use this signal to read additional information from the project file.
mapLayer | The map layer which is being initialized |
layerNode | The layer node from the project file |
int QgsProject::readNumEntry | ( | const QString & | scope, |
const QString & | key, | ||
int | def = 0 , |
||
bool * | ok = nullptr |
||
) | const |
Definition at line 1651 of file qgsproject.cpp.
QString QgsProject::readPath | ( | const QString & | filename | ) | const |
Turn filename read from the project file to an absolute path.
Definition at line 1774 of file qgsproject.cpp.
|
signal |
emitted when project is being read
QgsRelationManager* QgsProject::relationManager | ( | ) | const |
void QgsProject::reloadAllLayers | ( | ) |
Reload all registered layer's provider data caches, synchronising the layer with any changes in the datasource.
Definition at line 2364 of file qgsproject.cpp.
|
signal |
Emitted when all layers are removed, before layersWillBeRemoved() and layerWillBeRemoved() signals are emitted.
The layersWillBeRemoved() and layerWillBeRemoved() signals will still be emitted following this signal. You can use this signal to do easy (and fast) cleanup.
void QgsProject::removeAllMapLayers | ( | ) |
Removes all registered layers.
If the registry has ownership of any layers these layers will also be deleted.
Definition at line 2359 of file qgsproject.cpp.
bool QgsProject::removeEntry | ( | const QString & | scope, |
const QString & | key | ||
) |
Remove the given key.
Definition at line 1719 of file qgsproject.cpp.
void QgsProject::removeMapLayer | ( | const QString & | layerId | ) |
Remove a layer from the registry by layer ID.
The specified layer will be removed from the registry. If the registry has ownership of the layer then it will also be deleted.
layerId | ID of the layer to remove |
Definition at line 2344 of file qgsproject.cpp.
void QgsProject::removeMapLayer | ( | QgsMapLayer * | layer | ) |
Remove a layer from the registry.
The specified layer will be removed from the registry. If the registry has ownership of the layer then it will also be deleted.
layer | The layer to remove. Null pointers are ignored. |
Definition at line 2349 of file qgsproject.cpp.
void QgsProject::removeMapLayers | ( | const QStringList & | layerIds | ) |
Remove a set of layers from the registry by layer ID.
The specified layers will be removed from the registry. If the registry has ownership of any layers these layers will also be deleted.
layerIds | list of IDs of the layers to remove |
Definition at line 2334 of file qgsproject.cpp.
void QgsProject::removeMapLayers | ( | const QList< QgsMapLayer *> & | layers | ) |
Remove a set of layers from the registry.
The specified layers will be removed from the registry. If the registry has ownership of any layers these layers will also be deleted.
layers | A list of layers to remove. Null pointers are ignored. |
Definition at line 2339 of file qgsproject.cpp.
void QgsProject::setAreaUnits | ( | QgsUnitTypes::AreaUnit | unit | ) |
Sets the default area measurement units for the project.
Definition at line 2068 of file qgsproject.cpp.
void QgsProject::setAutoTransaction | ( | bool | autoTransaction | ) |
Transactional editing means that on supported datasources (postgres databases) the edit state of all tables that originate from the same database are synchronized and executed in a server side transaction.
Make sure that this is only called when all layers are not in edit mode.
Definition at line 2157 of file qgsproject.cpp.
void QgsProject::setAvoidIntersectionsLayers | ( | const QList< QgsVectorLayer *> & | layers | ) |
A list of layers with which intersections should be avoided.
Definition at line 1188 of file qgsproject.cpp.
void QgsProject::setBadLayerHandler | ( | QgsProjectBadLayerHandler * | handler | ) |
Change handler for missing layers.
Deletes old handler and takes ownership of the new one.
Definition at line 1799 of file qgsproject.cpp.
void QgsProject::setCrs | ( | const QgsCoordinateReferenceSystem & | crs | ) |
Sets the project's native coordinate reference system.
Definition at line 451 of file qgsproject.cpp.
void QgsProject::setCustomVariables | ( | const QVariantMap & | customVariables | ) |
A map of custom project variables.
Be careful not to set generated variables.
Definition at line 1131 of file qgsproject.cpp.
|
slot |
Flag the project as dirty (modified).
If this flag is set, the user will be asked to save changes to the project before closing the current project.
Definition at line 414 of file qgsproject.cpp.
void QgsProject::setDistanceUnits | ( | QgsUnitTypes::DistanceUnit | unit | ) |
Sets the default distance measurement units for the project.
Definition at line 2050 of file qgsproject.cpp.
void QgsProject::setEllipsoid | ( | const QString & | ellipsoid | ) |
Sets the project's ellipsoid from a proj string representation, e.g., "WGS84".
Definition at line 467 of file qgsproject.cpp.
void QgsProject::setEvaluateDefaultValues | ( | bool | evaluateDefaultValues | ) |
Defines if default values should be evaluated on provider side when requested and not when committed.
Definition at line 2010 of file qgsproject.cpp.
void QgsProject::setFileName | ( | const QString & | name | ) |
Sets the file name associated with the project.
This is the file which contains the project's XML representation.
name | project file name |
Definition at line 419 of file qgsproject.cpp.
void QgsProject::setLabelingEngineSettings | ( | const QgsLabelingEngineSettings & | settings | ) |
Sets project's global labeling engine settings.
Definition at line 1155 of file qgsproject.cpp.
void QgsProject::setNonIdentifiableLayers | ( | const QList< QgsMapLayer *> & | layers | ) |
Set a list of layers which should not be taken into account on map identification.
Definition at line 2117 of file qgsproject.cpp.
void QgsProject::setNonIdentifiableLayers | ( | const QStringList & | layerIds | ) |
Set a list of layers which should not be taken into account on map identification.
Definition at line 2140 of file qgsproject.cpp.
|
slot |
The snapping configuration for this project.
Definition at line 657 of file qgsproject.cpp.
void QgsProject::setTitle | ( | const QString & | title | ) |
Sets the project's title.
title | new title |
Definition at line 392 of file qgsproject.cpp.
void QgsProject::setTopologicalEditing | ( | bool | enabled | ) |
Convenience function to set topological editing.
Definition at line 2026 of file qgsproject.cpp.
void QgsProject::setTransformContext | ( | const QgsCoordinateTransformContext & | context | ) |
Sets the project's coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system.
Definition at line 479 of file qgsproject.cpp.
void QgsProject::setTrustLayerMetadata | ( | bool | trust | ) |
Sets the trust option allowing to indicate if the extent has to be read from the XML document when data source has no metadata or if the data provider has to determine it.
Moreover, when this option is activated, primary key unicity is not checked for views and materialized views with Postgres provider.
trust | True to trust the project, false otherwise |
Definition at line 2401 of file qgsproject.cpp.
QgsSnappingConfig QgsProject::snappingConfig | ( | ) | const |
The snapping configuration for this project.
|
signal |
emitted whenever the configuration for snapping has changed
QStringList QgsProject::subkeyList | ( | const QString & | scope, |
const QString & | key | ||
) | const |
Return keys with keys – do not return keys that contain only values.
Definition at line 1746 of file qgsproject.cpp.
QgsMapLayer * QgsProject::takeMapLayer | ( | QgsMapLayer * | layer | ) |
Takes a layer from the registry.
If the layer was owned by the project, the layer will be returned without deleting it. The caller takes ownership of the layer and is responsible for deleting it.
Definition at line 2354 of file qgsproject.cpp.
QString QgsProject::title | ( | ) | const |
bool QgsProject::topologicalEditing | ( | ) | const |
Convenience function to query topological editing status.
Definition at line 2032 of file qgsproject.cpp.
|
signal |
Emitted when the topological editing flag has changed.
QMap< QPair< QString, QString >, QgsTransactionGroup * > QgsProject::transactionGroups | ( | ) |
Map of transaction groups.
QPair( providerKey, connString ) -> transactionGroup
Definition at line 2170 of file qgsproject.cpp.
|
signal |
Emitted whenever a new transaction group has been created or a transaction group has been removed.
QgsCoordinateTransformContext QgsProject::transformContext | ( | ) | const |
Returns a copy of the project's coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system.
Definition at line 474 of file qgsproject.cpp.
|
signal |
|
inline |
Returns true if the trust option is activated, false otherwise.
This option allows indicateing if the extent has to be read from the XML document when data source has no metadata or if the data provider has to determine it. Moreover, when this option is activated, primary key unicity is not checked for views and materialized views with Postgres provider.
Definition at line 834 of file qgsproject.h.
bool QgsProject::write | ( | const QString & | filename | ) |
Writes the project to a file.
filename | destination file |
Definition at line 1307 of file qgsproject.cpp.
bool QgsProject::write | ( | ) |
Writes the project to its current associated file (see fileName() ).
Definition at line 1314 of file qgsproject.cpp.
bool QgsProject::writeEntry | ( | const QString & | scope, |
const QString & | key, | ||
bool | value | ||
) |
Write a boolean entry to the project file.
Keys are '/'-delimited entries, implying a hierarchy of keys and corresponding values
Definition at line 1565 of file qgsproject.cpp.
bool QgsProject::writeEntry | ( | const QString & | scope, |
const QString & | key, | ||
double | value | ||
) |
Write a double entry to the project file.
Keys are '/'-delimited entries, implying a hierarchy of keys and corresponding values
Definition at line 1572 of file qgsproject.cpp.
bool QgsProject::writeEntry | ( | const QString & | scope, |
const QString & | key, | ||
int | value | ||
) |
Write an integer entry to the project file.
Keys are '/'-delimited entries, implying a hierarchy of keys and corresponding values
Definition at line 1579 of file qgsproject.cpp.
bool QgsProject::writeEntry | ( | const QString & | scope, |
const QString & | key, | ||
const QString & | value | ||
) |
Write a string entry to the project file.
Keys are '/'-delimited entries, implying a hierarchy of keys and corresponding values
Definition at line 1586 of file qgsproject.cpp.
bool QgsProject::writeEntry | ( | const QString & | scope, |
const QString & | key, | ||
const QStringList & | value | ||
) |
Write a string list entry to the project file.
Keys are '/'-delimited entries, implying a hierarchy of keys and corresponding values
Definition at line 1593 of file qgsproject.cpp.
|
signal |
Emitted, when a layer is being saved.
You can use this method to save additional information to the layer.
mapLayer | The map layer which is being initialized |
layerElem | The layer element from the project file |
doc | The document |
QString QgsProject::writePath | ( | const QString & | filename | ) | const |
Prepare a filename to save it to the project file.
Creates an absolute or relative path according to the project settings. Paths written to the project file should be prepared with this method.
Definition at line 1779 of file qgsproject.cpp.
|
signal |
emitted when project is being written
|
readwrite |
Definition at line 93 of file qgsproject.h.
|
readwrite |
Definition at line 88 of file qgsproject.h.
|
readwrite |
Definition at line 89 of file qgsproject.h.
|
readwrite |
Definition at line 86 of file qgsproject.h.
|
read |
Definition at line 87 of file qgsproject.h.
|
read |
Definition at line 90 of file qgsproject.h.
|
readwrite |
Definition at line 85 of file qgsproject.h.
|
read |
Definition at line 92 of file qgsproject.h.
|
readwrite |
Definition at line 91 of file qgsproject.h.