QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgsproject.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsproject.h
3 
4  Implements persistent project state.
5 
6  -------------------
7  begin : July 23, 2004
8  copyright : (C) 2004 by Mark Coletti
9  email : mcoletti at gmail.com
10  ***************************************************************************/
11 
12 /***************************************************************************
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  ***************************************************************************/
20 
21 #ifndef QGSPROJECT_H
22 #define QGSPROJECT_H
23 
24 #include "qgis_core.h"
25 #include "qgis_sip.h"
26 #include <memory>
27 #include <QHash>
28 #include <QList>
29 #include <QObject>
30 #include <QPair>
31 #include <QFileInfo>
32 #include <QStringList>
33 #include <QTranslator>
34 
35 #include "qgsunittypes.h"
36 #include "qgssnappingconfig.h"
37 #include "qgsprojectversion.h"
42 #include "qgsprojectproperty.h"
43 #include "qgsmaplayerstore.h"
44 #include "qgsarchive.h"
45 #include "qgsreadwritecontext.h"
46 #include "qgsprojectmetadata.h"
47 #include "qgstranslationcontext.h"
48 #include "qgsprojecttranslator.h"
50 #include "qgscolorscheme.h"
51 
52 class QFileInfo;
53 class QDomDocument;
54 class QDomElement;
55 class QDomNode;
56 
57 class QgsLayerTreeGroup;
59 class QgsMapLayer;
61 class QgsPathResolver;
63 class QgsProjectStorage;
64 class QgsRelationManager;
65 class QgsTolerance;
67 class QgsVectorLayer;
69 class QgsLayoutManager;
70 class QgsLayerTree;
73 class QgsMapLayer;
74 class QgsBookmarkManager;
75 
89 class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenerator, public QgsExpressionContextScopeGenerator, public QgsProjectTranslator
90 {
91  Q_OBJECT
92  Q_PROPERTY( QStringList nonIdentifiableLayers READ nonIdentifiableLayers WRITE setNonIdentifiableLayers NOTIFY nonIdentifiableLayersChanged )
93  Q_PROPERTY( QString fileName READ fileName WRITE setFileName NOTIFY fileNameChanged )
94  Q_PROPERTY( QString homePath READ homePath WRITE setPresetHomePath NOTIFY homePathChanged )
95  Q_PROPERTY( QgsCoordinateReferenceSystem crs READ crs WRITE setCrs NOTIFY crsChanged )
96  Q_PROPERTY( QgsCoordinateTransformContext transformContext READ transformContext WRITE setTransformContext NOTIFY transformContextChanged )
97  Q_PROPERTY( QString ellipsoid READ ellipsoid WRITE setEllipsoid NOTIFY ellipsoidChanged )
98  Q_PROPERTY( QgsMapThemeCollection *mapThemeCollection READ mapThemeCollection NOTIFY mapThemeCollectionChanged )
99  Q_PROPERTY( QgsSnappingConfig snappingConfig READ snappingConfig WRITE setSnappingConfig NOTIFY snappingConfigChanged )
100  Q_PROPERTY( QgsRelationManager *relationManager READ relationManager )
101  Q_PROPERTY( QList<QgsVectorLayer *> avoidIntersectionsLayers READ avoidIntersectionsLayers WRITE setAvoidIntersectionsLayers NOTIFY avoidIntersectionsLayersChanged )
102  Q_PROPERTY( QgsProjectMetadata metadata READ metadata WRITE setMetadata NOTIFY metadataChanged )
103  Q_PROPERTY( QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged )
104  Q_PROPERTY( QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged )
105 
106  public:
108  static QgsProject *instance();
109 
115  explicit QgsProject( QObject *parent SIP_TRANSFERTHIS = nullptr );
116 
117  ~QgsProject() override;
118 
128  void setTitle( const QString &title );
129 
136  QString title() const;
137 
141  bool isDirty() const;
142 
149  void setFileName( const QString &name );
150 
157  QString fileName() const;
158 
169  Q_DECL_DEPRECATED QFileInfo fileInfo() const SIP_DEPRECATED;
170 
177  QgsProjectStorage *projectStorage() const;
178 
183  QDateTime lastModified() const;
184 
190  QString absoluteFilePath() const;
191 
197  QString absolutePath() const;
198 
203  QString baseName() const;
204 
212 
222  void setCrs( const QgsCoordinateReferenceSystem &crs, bool adjustEllipsoid = false );
223 
230  QString ellipsoid() const;
231 
238  void setEllipsoid( const QString &ellipsoid );
239 
240 
250  QgsCoordinateTransformContext transformContext() const;
251 
261  void setTransformContext( const QgsCoordinateTransformContext &context );
262 
268  void clear();
269 
274  enum ReadFlag
275  {
276  FlagDontResolveLayers = 1 << 0,
277  FlagDontLoadLayouts = 1 << 1,
278  };
279  Q_DECLARE_FLAGS( ReadFlags, ReadFlag )
280 
281 
287  bool read( const QString &filename, QgsProject::ReadFlags flags = nullptr );
288 
297  bool read( QgsProject::ReadFlags flags = nullptr );
298 
308  bool readLayer( const QDomNode &layerNode );
309 
318  bool write( const QString &filename );
319 
325  bool write();
326 
336  bool writeEntry( const QString &scope, const QString &key, bool value ) SIP_PYNAME( writeEntryBool );
337 
347  bool writeEntry( const QString &scope, const QString &key, double value ) SIP_PYNAME( writeEntryDouble );
348 
357  bool writeEntry( const QString &scope, const QString &key, int value );
358 
367  bool writeEntry( const QString &scope, const QString &key, const QString &value );
368 
377  bool writeEntry( const QString &scope, const QString &key, const QStringList &value );
378 
385  QStringList readListEntry( const QString &scope, const QString &key, const QStringList &def = QStringList(), bool *ok = nullptr ) const;
386 
387  QString readEntry( const QString &scope, const QString &key, const QString &def = QString(), bool *ok = nullptr ) const;
388  int readNumEntry( const QString &scope, const QString &key, int def = 0, bool *ok = nullptr ) const;
389  double readDoubleEntry( const QString &scope, const QString &key, double def = 0, bool *ok = nullptr ) const;
390  bool readBoolEntry( const QString &scope, const QString &key, bool def = false, bool *ok = nullptr ) const;
391 
392 
394  bool removeEntry( const QString &scope, const QString &key );
395 
396 
402  QStringList entryList( const QString &scope, const QString &key ) const;
403 
409  QStringList subkeyList( const QString &scope, const QString &key ) const;
410 
411 
415  // TODO Now slightly broken since re-factoring. Won't print out top-level key
416  // and redundantly prints sub-keys.
417  void dumpProperties() const;
418 
424  QgsPathResolver pathResolver() const;
425 
431  QString writePath( const QString &filename ) const;
432 
434  QString readPath( const QString &filename ) const;
435 
437  QString error() const;
438 
443  void setBadLayerHandler( QgsProjectBadLayerHandler *handler SIP_TRANSFER );
444 
446  QString layerIsEmbedded( const QString &id ) const;
447 
456  bool createEmbeddedLayer( const QString &layerId, const QString &projectFilePath, QList<QDomNode> &brokenNodes,
457  bool saveFlag = true, QgsProject::ReadFlags flags = nullptr ) SIP_SKIP;
458 
466  QgsLayerTreeGroup *createEmbeddedGroup( const QString &groupName, const QString &projectFilePath, const QStringList &invisibleLayers, QgsProject::ReadFlags flags = nullptr );
467 
469  void setTopologicalEditing( bool enabled );
470 
472  bool topologicalEditing() const;
473 
480  QgsUnitTypes::DistanceUnit distanceUnits() const;
481 
488  void setDistanceUnits( QgsUnitTypes::DistanceUnit unit );
489 
495  QgsUnitTypes::AreaUnit areaUnits() const;
496 
503  void setAreaUnits( QgsUnitTypes::AreaUnit unit );
504 
517  QString homePath() const;
518 
531  QString presetHomePath() const;
532 
533  QgsRelationManager *relationManager() const;
534 
541  const QgsLayoutManager *layoutManager() const SIP_SKIP;
542 
548  QgsLayoutManager *layoutManager();
549 
556  const QgsBookmarkManager *bookmarkManager() const SIP_SKIP;
557 
563  QgsBookmarkManager *bookmarkManager();
564 
569  QgsLayerTree *layerTreeRoot() const;
570 
575  QgsLayerTreeRegistryBridge *layerTreeRegistryBridge() const { return mLayerTreeRegistryBridge; }
576 
582  QgsMapThemeCollection *mapThemeCollection();
583 
588  QgsAnnotationManager *annotationManager();
589 
594  const QgsAnnotationManager *annotationManager() const SIP_SKIP;
595 
600  Q_DECL_DEPRECATED void setNonIdentifiableLayers( const QList<QgsMapLayer *> &layers );
601 
606  Q_DECL_DEPRECATED void setNonIdentifiableLayers( const QStringList &layerIds );
607 
612  Q_DECL_DEPRECATED QStringList nonIdentifiableLayers() const;
613 
621  bool autoTransaction() const;
622 
632  void setAutoTransaction( bool autoTransaction );
633 
642  QMap< QPair< QString, QString>, QgsTransactionGroup *> transactionGroups() SIP_SKIP;
643 
651  QgsTransactionGroup *transactionGroup( const QString &providerKey, const QString &connString );
652 
658  bool evaluateDefaultValues() const;
659 
665  void setEvaluateDefaultValues( bool evaluateDefaultValues );
666 
669 
675  QgsSnappingConfig snappingConfig() const;
676 
682  QList<QgsVectorLayer *> avoidIntersectionsLayers() const;
683 
689  void setAvoidIntersectionsLayers( const QList<QgsVectorLayer *> &layers );
690 
696  QVariantMap customVariables() const;
697 
702  void setCustomVariables( const QVariantMap &customVariables );
703 
708  void setLabelingEngineSettings( const QgsLabelingEngineSettings &settings );
709 
714  const QgsLabelingEngineSettings &labelingEngineSettings() const;
715 
716  //
717  // Functionality from QgsMapLayerRegistry
718  //
719 
724  QgsMapLayerStore *layerStore();
725 
730  SIP_SKIP const QgsMapLayerStore *layerStore() const;
731 
733  int count() const;
734 
736  int validCount() const;
737 
745  Q_INVOKABLE QgsMapLayer *mapLayer( const QString &layerId ) const;
746 
747 #ifndef SIP_RUN
748 
764  template <class T>
765  T mapLayer( const QString &layerId ) const
766  {
767  return qobject_cast<T>( mapLayer( layerId ) );
768  }
769 #endif
770 
778  QList<QgsMapLayer *> mapLayersByName( const QString &layerName ) const;
779 
789  QList<QgsMapLayer *> mapLayersByShortName( const QString &shortName ) const;
790 
791 
800  QMap<QString, QgsMapLayer *> mapLayers( const bool validOnly = false ) const;
801 
805  bool isZipped() const;
806 
807 #ifndef SIP_RUN
808 
820  template <typename T>
821  QVector<T> layers() const
822  {
823  return mLayerStore->layers<T>();
824  }
825 
837  template <typename T>
838  QVector<T> mapLayersByShortName( const QString &shortName ) const
839  {
840  QVector<T> layers;
841  const auto constMapLayers { mLayerStore->layers<T>() };
842  for ( const auto l : constMapLayers )
843  {
844  if ( ! l->shortName().isEmpty() )
845  {
846  if ( l->shortName() == shortName )
847  layers << l;
848  }
849  else if ( l->name() == shortName )
850  {
851  layers << l;
852  }
853  }
854  return layers;
855  }
856 
857 #endif
858 
884  QList<QgsMapLayer *> addMapLayers( const QList<QgsMapLayer *> &mapLayers SIP_TRANSFER,
885  bool addToLegend = true,
886  bool takeOwnership SIP_PYARGREMOVE = true );
887 
915  QgsMapLayer *addMapLayer( QgsMapLayer *mapLayer SIP_TRANSFER,
916  bool addToLegend = true,
917  bool takeOwnership SIP_PYARGREMOVE = true );
918 
933  void removeMapLayers( const QStringList &layerIds );
934 
935  //TODO QGIS 4.0 - add PyName alias to avoid list type conversion error
936 
950  void removeMapLayers( const QList<QgsMapLayer *> &layers );
951 
965  void removeMapLayer( const QString &layerId );
966 
980  void removeMapLayer( QgsMapLayer *layer );
981 
989  QgsMapLayer *takeMapLayer( QgsMapLayer *layer ) SIP_TRANSFERBACK;
990 
1001  void removeAllMapLayers();
1002 
1008  void reloadAllLayers();
1009 
1014  QgsCoordinateReferenceSystem defaultCrsForNewLayers() const;
1015 
1027  void setTrustLayerMetadata( bool trust );
1028 
1039  bool trustLayerMetadata() const { return mTrustLayerMetadata; }
1040 
1046  const QgsAuxiliaryStorage *auxiliaryStorage() const SIP_SKIP;
1047 
1053  QgsAuxiliaryStorage *auxiliaryStorage();
1054 
1063  QString attachedFile( const QString &fileName ) const SIP_SKIP;
1064 
1074  QgsStringMap attachedFiles() const SIP_SKIP;
1075 
1082  const QgsProjectMetadata &metadata() const;
1083 
1090  void setMetadata( const QgsProjectMetadata &metadata );
1091 
1100  Q_DECL_DEPRECATED QSet<QgsMapLayer *> requiredLayers() const;
1101 
1110  Q_DECL_DEPRECATED void setRequiredLayers( const QSet<QgsMapLayer *> &layers );
1111 
1118  void setProjectColors( const QgsNamedColorList &colors );
1119 
1126  void setBackgroundColor( const QColor &color );
1127 
1134  QColor backgroundColor() const;
1135 
1142  void setSelectionColor( const QColor &color );
1143 
1150  QColor selectionColor() const;
1151 
1163  void setMapScales( const QVector<double> &scales );
1164 
1176  QVector<double> mapScales() const;
1177 
1186  void setUseProjectScales( bool enabled );
1187 
1196  bool useProjectScales() const;
1197 
1202  void generateTsFile( const QString &locale );
1203 
1214  QString translate( const QString &context, const QString &sourceText, const char *disambiguation = nullptr, int n = -1 ) const override;
1215 
1225  bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
1226 
1227 #ifdef SIP_RUN
1228  SIP_PYOBJECT __repr__();
1229  % MethodCode
1230  QString str = QStringLiteral( "<QgsProject: '%1'%2>" ).arg( sipCpp->fileName(),
1231  sipCpp == QgsProject::instance() ? QStringLiteral( " (singleton instance)" ) : QString() );
1232  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
1233  % End
1234 #endif
1235 
1236  signals:
1237 
1245  void cleared();
1246 
1250  void readProject( const QDomDocument & );
1251 
1255  void readProjectWithContext( const QDomDocument &, QgsReadWriteContext &context );
1256 
1260  void writeProject( QDomDocument & );
1261 
1270  void readMapLayer( QgsMapLayer *mapLayer, const QDomElement &layerNode );
1271 
1280  void writeMapLayer( QgsMapLayer *mapLayer, QDomElement &layerElem, QDomDocument &doc );
1281 
1285  void projectSaved();
1286 
1290  void oldProjectVersionWarning( const QString & );
1291 
1297  void layerLoaded( int i, int n );
1298 
1300  void loadingLayer( const QString &layerName );
1301 
1308  void loadingLayerMessageReceived( const QString &layerName, const QList<QgsReadWriteContext::ReadWriteMessage> &messages );
1309 
1314  Q_DECL_DEPRECATED void nonIdentifiableLayersChanged( QStringList nonIdentifiableLayers );
1315 
1317  void fileNameChanged();
1318 
1325  void homePathChanged();
1326 
1330  void snappingConfigChanged( const QgsSnappingConfig &config );
1331 
1336  void customVariablesChanged();
1337 
1343  void crsChanged();
1344 
1352  void ellipsoidChanged( const QString &ellipsoid );
1353 
1354 
1361  void transformContextChanged();
1362 
1367  void missingDatumTransforms( const QStringList &missingTransforms );
1368 
1375  void transactionGroupsChanged();
1376 
1382  void topologicalEditingChanged();
1383 
1389  void avoidIntersectionsLayersChanged();
1390 
1402  void mapThemeCollectionChanged();
1403 
1408  void labelingEngineSettingsChanged();
1409 
1416  void metadataChanged();
1417 
1424  void projectColorsChanged();
1425 
1432  void backgroundColorChanged();
1433 
1440  void selectionColorChanged();
1441 
1442  //
1443  // signals from QgsMapLayerRegistry
1444  //
1445 
1453  void layersWillBeRemoved( const QStringList &layerIds );
1454 
1462  void layersWillBeRemoved( const QList<QgsMapLayer *> &layers );
1463 
1473  void layerWillBeRemoved( const QString &layerId );
1474 
1484  void layerWillBeRemoved( QgsMapLayer *layer );
1485 
1492  void layersRemoved( const QStringList &layerIds );
1493 
1502  void layerRemoved( const QString &layerId );
1503 
1504  //TODO QGIS 4.0 - rename to past tense
1505 
1512  void removeAll();
1513 
1524  void layersAdded( const QList<QgsMapLayer *> &layers );
1525 
1532  void layerWasAdded( QgsMapLayer *layer );
1533 
1542  void legendLayersAdded( const QList<QgsMapLayer *> &layers );
1543 
1551  void isDirtyChanged( bool dirty );
1552 
1566  void collectAttachedFiles( QgsStringMap &files SIP_INOUT ) SIP_SKIP;
1567 
1576  void mapScalesChanged();
1577 
1578  public slots:
1579 
1585  void setSnappingConfig( const QgsSnappingConfig &snappingConfig );
1586 
1587  // TODO QGIS 4.0 - rename b to dirty
1588 
1596  void setDirty( bool b = true );
1597 
1606  void setPresetHomePath( const QString &path );
1607 
1617  void registerTranslatableContainers( QgsTranslationContext *translationContext, QgsAttributeEditorContainer *parent, const QString &layerId );
1618 
1625  void registerTranslatableObjects( QgsTranslationContext *translationContext );
1626 
1627  private slots:
1628  void onMapLayersAdded( const QList<QgsMapLayer *> &layers );
1629  void onMapLayersRemoved( const QList<QgsMapLayer *> &layers );
1630  void cleanTransactionGroups( bool force = false );
1631 
1632  private:
1633 
1634  static QgsProject *sProject;
1635 
1644  static void setInstance( QgsProject *project ) SIP_SKIP;
1645 
1654  bool _getMapLayers( const QDomDocument &doc, QList<QDomNode> &brokenNodes, QgsProject::ReadFlags flags = nullptr );
1655 
1660  void setError( const QString &errorMessage ) SIP_SKIP;
1661 
1666  void clearError() SIP_SKIP;
1667 
1675  bool addLayer( const QDomElement &layerElem, QList<QDomNode> &brokenNodes, QgsReadWriteContext &context, QgsProject::ReadFlags flags = nullptr ) SIP_SKIP;
1676 
1682  void initializeEmbeddedSubtree( const QString &projectFilePath, QgsLayerTreeGroup *group, QgsProject::ReadFlags flags = nullptr ) SIP_SKIP;
1683 
1688  void loadEmbeddedNodes( QgsLayerTreeGroup *group, QgsProject::ReadFlags flags = nullptr ) SIP_SKIP;
1689 
1691  bool readProjectFile( const QString &filename, QgsProject::ReadFlags flags = nullptr );
1692 
1694  bool writeProjectFile( const QString &filename );
1695 
1697  bool unzip( const QString &filename, QgsProject::ReadFlags flags = nullptr );
1698 
1700  bool zip( const QString &filename );
1701 
1703  bool saveAuxiliaryStorage( const QString &filename = QString() );
1704 
1705  std::unique_ptr< QgsMapLayerStore > mLayerStore;
1706 
1707  QString mErrorMessage;
1708 
1709  QgsProjectBadLayerHandler *mBadLayerHandler = nullptr;
1710 
1716  QHash< QString, QPair< QString, bool> > mEmbeddedLayers;
1717 
1718  QgsSnappingConfig mSnappingConfig;
1719 
1720  QgsRelationManager *mRelationManager = nullptr;
1721 
1722  std::unique_ptr<QgsAnnotationManager> mAnnotationManager;
1723  std::unique_ptr<QgsLayoutManager> mLayoutManager;
1724 
1725  QgsBookmarkManager *mBookmarkManager = nullptr;
1726 
1727  QgsLayerTree *mRootGroup = nullptr;
1728 
1729  QgsLayerTreeRegistryBridge *mLayerTreeRegistryBridge = nullptr;
1730 
1732  QMap< QPair< QString, QString>, QgsTransactionGroup *> mTransactionGroups;
1733 
1734  std::unique_ptr<QgsMapThemeCollection> mMapThemeCollection;
1735 
1736  std::unique_ptr<QgsLabelingEngineSettings> mLabelingEngineSettings;
1737 
1738  QVariantMap mCustomVariables;
1739 
1740  std::unique_ptr<QgsProjectArchive> mArchive;
1741 
1742  std::unique_ptr<QgsAuxiliaryStorage> mAuxiliaryStorage;
1743 
1744  QFile mFile; // current physical project file
1745 
1750  QString mHomePath;
1751  mutable QString mCachedHomePath;
1752 
1753  QColor mBackgroundColor;
1754  QColor mSelectionColor;
1755 
1756  mutable QgsProjectPropertyKey mProperties; // property hierarchy, TODO: this shouldn't be mutable
1757  bool mAutoTransaction = false; // transaction grouped editing
1758  bool mEvaluateDefaultValues = false; // evaluate default values immediately
1760  bool mDirty = false; // project has been modified since it has been read or saved
1761  int mDirtyBlockCount = 0;
1762  bool mTrustLayerMetadata = false;
1763 
1764  QgsCoordinateTransformContext mTransformContext;
1765 
1766  QgsProjectMetadata mMetadata;
1767 
1768  std::unique_ptr< QTranslator > mTranslator;
1769 
1770  bool mIsBeingDeleted = false;
1771 
1772  mutable std::unique_ptr< QgsExpressionContextScope > mProjectScope;
1773 
1775 
1776  // Required to avoid creating a new project in it's destructor
1777  friend class QgsProviderRegistry;
1778 
1779  // Required by QGIS Server for switching the current project instance
1780  friend class QgsConfigCache;
1781 };
1782 
1783 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProject::ReadFlags )
1784 
1785 
1806 class CORE_EXPORT QgsProjectDirtyBlocker
1807 {
1808  public:
1809 
1816  : mProject( project )
1817  {
1818  mProject->mDirtyBlockCount++;
1819  }
1820 
1822  QgsProjectDirtyBlocker( const QgsProjectDirtyBlocker &other ) = delete;
1823 
1825  QgsProjectDirtyBlocker &operator=( const QgsProjectDirtyBlocker &other ) = delete;
1826 
1828  {
1829  mProject->mDirtyBlockCount--;
1830  }
1831 
1832  private:
1833  QgsProject *mProject = nullptr;
1834 
1835 #ifdef SIP_RUN
1836  QgsProjectDirtyBlocker( const QgsProjectDirtyBlocker &other );
1837 #endif
1838 };
1839 
1845 CORE_EXPORT QgsProjectVersion getVersion( QDomDocument const &doc ) SIP_SKIP;
1846 
1847 
1848 
1850 #ifndef SIP_RUN
1851 class GetNamedProjectColor : public QgsScopedExpressionFunction
1852 {
1853  public:
1854  GetNamedProjectColor( const QgsProject *project );
1855 
1860  GetNamedProjectColor( const QHash< QString, QColor > &colors );
1861 
1862  QVariant func( const QVariantList &values, const QgsExpressionContext *, QgsExpression *, const QgsExpressionNodeFunction * ) override;
1863  QgsScopedExpressionFunction *clone() const override;
1864 
1865  private:
1866 
1867  QHash< QString, QColor > mColors;
1868 
1869 };
1870 
1871 #endif
1872 
1874 #endif
Class for parsing and evaluation of expressions (formerly called "search strings").
Layer tree group node serves as a container for layers and further groups.
The class is used as a container of context for various read/write operations on other objects...
Base class for all map layer types.
Definition: qgsmaplayer.h:79
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
Manages storage of a set of QgsAnnotation annotation objects.
Helper functions for various unit types.
Definition: qgsunittypes.h:38
Class providing some utility methods to manage auxiliary storage.
Manages storage of a set of bookmarks.
#define SIP_INOUT
Definition: qgis_sip.h:71
const QgsCoordinateReferenceSystem & crs
An interface for classes which can visit style entity (e.g.
#define SIP_TRANSFERBACK
Definition: qgis_sip.h:48
QMap< QString, QString > QgsStringMap
Definition: qgis.h:612
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
T mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layerId converted to type T.
Definition: qgsproject.h:765
bool trustLayerMetadata() const
Returns true if the trust option is activated, false otherwise.
Definition: qgsproject.h:1039
ReadFlag
Flags which control project read behavior.
Definition: qgsproject.h:274
Namespace with helper functions for layer tree operations.
Definition: qgslayertree.h:32
CORE_EXPORT bool unzip(const QString &zip, const QString &dir, QStringList &files)
Unzip a zip file in an output directory.
Definition: qgsziputils.cpp:34
#define SIP_SKIP
Definition: qgis_sip.h:126
CORE_EXPORT QgsProjectVersion getVersion(QDomDocument const &doc)
Returns the version string found in the given DOM document.
Definition: qgsproject.cpp:893
A class to describe the version of a project.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
This is the class is providing tolerance value in map unit values.
Definition: qgstolerance.h:32
Listens to the updates in map layer registry and does changes in layer tree.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QList< QPair< QColor, QString > > QgsNamedColorList
List of colors paired with a friendly display name identifying the color.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
Definition: qgsproject.h:89
Single scope for storing variables and functions for use within a QgsExpressionContext.
An expression node for expression functions.
Contains information about the context in which a coordinate transform is executed.
const QgsProject * project(const QString &path)
If the project is not cached yet, then the project is read thanks to the path.
Wherever an object of this class is available, the derived translate function can be called from...
Manages storage of a set of layouts.
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
Used for the collecting of strings from projects for translation and creation of ts files...
Abstract interface for generating an expression context.
virtual QString translate(const QString &context, const QString &sourceText, const char *disambiguation=nullptr, int n=-1) const =0
The derived translate() translates with QTranslator and qm file the sourceText.
A registry / canonical manager of data providers.
Project property key node.
Cache for server configuration.
#define SIP_PYARGREMOVE
Definition: qgis_sip.h:146
QVector< T > layers() const
Returns a list of registered map layers with a specified layer type.
Definition: qgsproject.h:821
virtual QgsExpressionContextScope * createExpressionContextScope() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Abstract interface for generating an expression context scope.
This class manages a set of relations between layers.
Stores global configuration for labeling engine.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:442
This class represents a coordinate reference system (CRS).
This is a container for attribute editors, used to group them visually in the attribute form if it is...
Abstract interface for project storage - to be implemented by various backends and registered in QgsP...
QgsProjectDirtyBlocker(QgsProject *project)
Constructor for QgsProjectDirtyBlocker.
Definition: qgsproject.h:1815
Temporarily blocks QgsProject "dirtying" for the lifetime of the object.
Definition: qgsproject.h:1806
A storage object for map layers, in which the layers are owned by the store and have their lifetime b...
Container class that allows storage of map themes consisting of visible map layers and layer styles...
This is a container for configuration of the snapping of the project.
Resolves relative paths into absolute paths and vice versa.
Represents a vector layer which manages a vector based data sets.
CORE_EXPORT bool zip(const QString &zip, const QStringList &files)
Zip the list of files in the zip file.
Expression function for use within a QgsExpressionContextScope.
Interface for classes that handle missing layer files when reading project file.
QVector< T > mapLayersByShortName(const QString &shortName) const
Retrieves a list of matching registered layers by layer shortName with a specified layer type...
Definition: qgsproject.h:838
#define SIP_PYNAME(name)
Definition: qgis_sip.h:81
A structured metadata store for a map layer.