QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
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;
77 
91 class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenerator, public QgsExpressionContextScopeGenerator, public QgsProjectTranslator
92 {
93  Q_OBJECT
94  Q_PROPERTY( QStringList nonIdentifiableLayers READ nonIdentifiableLayers WRITE setNonIdentifiableLayers NOTIFY nonIdentifiableLayersChanged )
95  Q_PROPERTY( QString fileName READ fileName WRITE setFileName NOTIFY fileNameChanged )
96  Q_PROPERTY( QString homePath READ homePath WRITE setPresetHomePath NOTIFY homePathChanged )
97  Q_PROPERTY( QgsCoordinateReferenceSystem crs READ crs WRITE setCrs NOTIFY crsChanged )
98  Q_PROPERTY( QgsCoordinateTransformContext transformContext READ transformContext WRITE setTransformContext NOTIFY transformContextChanged )
99  Q_PROPERTY( QString ellipsoid READ ellipsoid WRITE setEllipsoid NOTIFY ellipsoidChanged )
100  Q_PROPERTY( QgsMapThemeCollection *mapThemeCollection READ mapThemeCollection NOTIFY mapThemeCollectionChanged )
101  Q_PROPERTY( QgsSnappingConfig snappingConfig READ snappingConfig WRITE setSnappingConfig NOTIFY snappingConfigChanged )
102  Q_PROPERTY( QgsRelationManager *relationManager READ relationManager )
103  Q_PROPERTY( QList<QgsVectorLayer *> avoidIntersectionsLayers READ avoidIntersectionsLayers WRITE setAvoidIntersectionsLayers NOTIFY avoidIntersectionsLayersChanged )
104  Q_PROPERTY( QgsProjectMetadata metadata READ metadata WRITE setMetadata NOTIFY metadataChanged )
105  Q_PROPERTY( QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged )
106  Q_PROPERTY( QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged )
107 
108  public:
109 
115  {
116  FlagDontResolveLayers = 1 << 0,
117  FlagDontLoadLayouts = 1 << 1,
118  };
119  Q_DECLARE_FLAGS( ReadFlags, ReadFlag )
120 
121 
125  enum class FileFormat
126  {
127  Qgz,
128  Qgs,
129  };
130  Q_ENUM( FileFormat )
131 
132 
133  static QgsProject *instance();
134 
140  explicit QgsProject( QObject *parent SIP_TRANSFERTHIS = nullptr );
141 
142  ~QgsProject() override;
143 
153  void setTitle( const QString &title );
154 
161  QString title() const;
162 
170  QString saveUser() const;
171 
179  QString saveUserFullName() const;
180 
184  bool isDirty() const;
185 
192  void setFileName( const QString &name );
193 
200  QString fileName() const;
201 
212  Q_DECL_DEPRECATED QFileInfo fileInfo() const SIP_DEPRECATED;
213 
220  QgsProjectStorage *projectStorage() const;
221 
226  QDateTime lastModified() const;
227 
233  QString absoluteFilePath() const;
234 
240  QString absolutePath() const;
241 
246  QString baseName() const;
247 
255 
265  void setCrs( const QgsCoordinateReferenceSystem &crs, bool adjustEllipsoid = false );
266 
273  QString ellipsoid() const;
274 
281  void setEllipsoid( const QString &ellipsoid );
282 
283 
293  QgsCoordinateTransformContext transformContext() const;
294 
304  void setTransformContext( const QgsCoordinateTransformContext &context );
305 
311  void clear();
312 
319  bool read( const QString &filename, QgsProject::ReadFlags flags = nullptr );
320 
329  bool read( QgsProject::ReadFlags flags = nullptr );
330 
340  bool readLayer( const QDomNode &layerNode );
341 
350  bool write( const QString &filename );
351 
357  bool write();
358 
368  bool writeEntry( const QString &scope, const QString &key, bool value ) SIP_PYNAME( writeEntryBool );
369 
379  bool writeEntry( const QString &scope, const QString &key, double value ) SIP_PYNAME( writeEntryDouble );
380 
389  bool writeEntry( const QString &scope, const QString &key, int value );
390 
399  bool writeEntry( const QString &scope, const QString &key, const QString &value );
400 
409  bool writeEntry( const QString &scope, const QString &key, const QStringList &value );
410 
417  QStringList readListEntry( const QString &scope, const QString &key, const QStringList &def = QStringList(), bool *ok = nullptr ) const;
418 
419  QString readEntry( const QString &scope, const QString &key, const QString &def = QString(), bool *ok = nullptr ) const;
420  int readNumEntry( const QString &scope, const QString &key, int def = 0, bool *ok = nullptr ) const;
421  double readDoubleEntry( const QString &scope, const QString &key, double def = 0, bool *ok = nullptr ) const;
422  bool readBoolEntry( const QString &scope, const QString &key, bool def = false, bool *ok = nullptr ) const;
423 
424 
426  bool removeEntry( const QString &scope, const QString &key );
427 
428 
434  QStringList entryList( const QString &scope, const QString &key ) const;
435 
441  QStringList subkeyList( const QString &scope, const QString &key ) const;
442 
443 
447  // TODO Now slightly broken since re-factoring. Won't print out top-level key
448  // and redundantly prints sub-keys.
449  void dumpProperties() const;
450 
456  QgsPathResolver pathResolver() const;
457 
463  QString writePath( const QString &filename ) const;
464 
466  QString readPath( const QString &filename ) const;
467 
469  QString error() const;
470 
475  void setBadLayerHandler( QgsProjectBadLayerHandler *handler SIP_TRANSFER );
476 
478  QString layerIsEmbedded( const QString &id ) const;
479 
488  bool createEmbeddedLayer( const QString &layerId, const QString &projectFilePath, QList<QDomNode> &brokenNodes,
489  bool saveFlag = true, QgsProject::ReadFlags flags = nullptr ) SIP_SKIP;
490 
498  QgsLayerTreeGroup *createEmbeddedGroup( const QString &groupName, const QString &projectFilePath, const QStringList &invisibleLayers, QgsProject::ReadFlags flags = nullptr );
499 
501  void setTopologicalEditing( bool enabled );
502 
504  bool topologicalEditing() const;
505 
512  QgsUnitTypes::DistanceUnit distanceUnits() const;
513 
520  void setDistanceUnits( QgsUnitTypes::DistanceUnit unit );
521 
527  QgsUnitTypes::AreaUnit areaUnits() const;
528 
535  void setAreaUnits( QgsUnitTypes::AreaUnit unit );
536 
549  QString homePath() const;
550 
563  QString presetHomePath() const;
564 
565  QgsRelationManager *relationManager() const;
566 
573  const QgsLayoutManager *layoutManager() const SIP_SKIP;
574 
580  QgsLayoutManager *layoutManager();
581 
588  const QgsBookmarkManager *bookmarkManager() const SIP_SKIP;
589 
595  QgsBookmarkManager *bookmarkManager();
596 
604  const QgsProjectViewSettings *viewSettings() const SIP_SKIP;
605 
612  QgsProjectViewSettings *viewSettings();
613 
620  const QgsProjectDisplaySettings *displaySettings() const SIP_SKIP;
621 
627  QgsProjectDisplaySettings *displaySettings();
628 
633  QgsLayerTree *layerTreeRoot() const;
634 
639  QgsLayerTreeRegistryBridge *layerTreeRegistryBridge() const { return mLayerTreeRegistryBridge; }
640 
646  QgsMapThemeCollection *mapThemeCollection();
647 
652  QgsAnnotationManager *annotationManager();
653 
658  const QgsAnnotationManager *annotationManager() const SIP_SKIP;
659 
664  Q_DECL_DEPRECATED void setNonIdentifiableLayers( const QList<QgsMapLayer *> &layers );
665 
670  Q_DECL_DEPRECATED void setNonIdentifiableLayers( const QStringList &layerIds );
671 
676  Q_DECL_DEPRECATED QStringList nonIdentifiableLayers() const;
677 
685  bool autoTransaction() const;
686 
696  void setAutoTransaction( bool autoTransaction );
697 
706  QMap< QPair< QString, QString>, QgsTransactionGroup *> transactionGroups() SIP_SKIP;
707 
715  QgsTransactionGroup *transactionGroup( const QString &providerKey, const QString &connString );
716 
722  bool evaluateDefaultValues() const;
723 
729  void setEvaluateDefaultValues( bool evaluateDefaultValues );
730 
733 
739  QgsSnappingConfig snappingConfig() const;
740 
746  QList<QgsVectorLayer *> avoidIntersectionsLayers() const;
747 
753  void setAvoidIntersectionsLayers( const QList<QgsVectorLayer *> &layers );
754 
760  QVariantMap customVariables() const;
761 
766  void setCustomVariables( const QVariantMap &customVariables );
767 
772  void setLabelingEngineSettings( const QgsLabelingEngineSettings &settings );
773 
778  const QgsLabelingEngineSettings &labelingEngineSettings() const;
779 
780  //
781  // Functionality from QgsMapLayerRegistry
782  //
783 
788  QgsMapLayerStore *layerStore();
789 
794  SIP_SKIP const QgsMapLayerStore *layerStore() const;
795 
797  int count() const;
798 
800  int validCount() const;
801 
809  Q_INVOKABLE QgsMapLayer *mapLayer( const QString &layerId ) const;
810 
811 #ifndef SIP_RUN
812 
828  template <class T>
829  T mapLayer( const QString &layerId ) const
830  {
831  return qobject_cast<T>( mapLayer( layerId ) );
832  }
833 #endif
834 
842  QList<QgsMapLayer *> mapLayersByName( const QString &layerName ) const;
843 
853  QList<QgsMapLayer *> mapLayersByShortName( const QString &shortName ) const;
854 
855 
864  QMap<QString, QgsMapLayer *> mapLayers( const bool validOnly = false ) const;
865 
869  bool isZipped() const;
870 
871 #ifndef SIP_RUN
872 
884  template <typename T>
885  QVector<T> layers() const
886  {
887  return mLayerStore->layers<T>();
888  }
889 
901  template <typename T>
902  QVector<T> mapLayersByShortName( const QString &shortName ) const
903  {
904  QVector<T> layers;
905  const auto constMapLayers { mLayerStore->layers<T>() };
906  for ( const auto l : constMapLayers )
907  {
908  if ( ! l->shortName().isEmpty() )
909  {
910  if ( l->shortName() == shortName )
911  layers << l;
912  }
913  else if ( l->name() == shortName )
914  {
915  layers << l;
916  }
917  }
918  return layers;
919  }
920 
921 #endif
922 
948  QList<QgsMapLayer *> addMapLayers( const QList<QgsMapLayer *> &mapLayers SIP_TRANSFER,
949  bool addToLegend = true,
950  bool takeOwnership SIP_PYARGREMOVE = true );
951 
979  QgsMapLayer *addMapLayer( QgsMapLayer *mapLayer SIP_TRANSFER,
980  bool addToLegend = true,
981  bool takeOwnership SIP_PYARGREMOVE = true );
982 
997  void removeMapLayers( const QStringList &layerIds );
998 
999  //TODO QGIS 4.0 - add PyName alias to avoid list type conversion error
1000 
1014  void removeMapLayers( const QList<QgsMapLayer *> &layers );
1015 
1029  void removeMapLayer( const QString &layerId );
1030 
1044  void removeMapLayer( QgsMapLayer *layer );
1045 
1053  QgsMapLayer *takeMapLayer( QgsMapLayer *layer ) SIP_TRANSFERBACK;
1054 
1065  void removeAllMapLayers();
1066 
1072  void reloadAllLayers();
1073 
1078  QgsCoordinateReferenceSystem defaultCrsForNewLayers() const;
1079 
1091  void setTrustLayerMetadata( bool trust );
1092 
1103  bool trustLayerMetadata() const { return mTrustLayerMetadata; }
1104 
1110  const QgsAuxiliaryStorage *auxiliaryStorage() const SIP_SKIP;
1111 
1117  QgsAuxiliaryStorage *auxiliaryStorage();
1118 
1127  QString attachedFile( const QString &fileName ) const SIP_SKIP;
1128 
1138  QgsStringMap attachedFiles() const SIP_SKIP;
1139 
1146  const QgsProjectMetadata &metadata() const;
1147 
1154  void setMetadata( const QgsProjectMetadata &metadata );
1155 
1164  Q_DECL_DEPRECATED QSet<QgsMapLayer *> requiredLayers() const;
1165 
1174  Q_DECL_DEPRECATED void setRequiredLayers( const QSet<QgsMapLayer *> &layers );
1175 
1182  void setProjectColors( const QgsNamedColorList &colors );
1183 
1190  void setBackgroundColor( const QColor &color );
1191 
1198  QColor backgroundColor() const;
1199 
1206  void setSelectionColor( const QColor &color );
1207 
1214  QColor selectionColor() const;
1215 
1227  Q_DECL_DEPRECATED void setMapScales( const QVector<double> &scales ) SIP_DEPRECATED;
1228 
1240  Q_DECL_DEPRECATED QVector<double> mapScales() const SIP_DEPRECATED;
1241 
1250  Q_DECL_DEPRECATED void setUseProjectScales( bool enabled ) SIP_DEPRECATED;
1251 
1260  Q_DECL_DEPRECATED bool useProjectScales() const SIP_DEPRECATED;
1261 
1266  void generateTsFile( const QString &locale );
1267 
1278  QString translate( const QString &context, const QString &sourceText, const char *disambiguation = nullptr, int n = -1 ) const override;
1279 
1289  bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
1290 
1291 #ifdef SIP_RUN
1292  SIP_PYOBJECT __repr__();
1293  % MethodCode
1294  QString str = QStringLiteral( "<QgsProject: '%1'%2>" ).arg( sipCpp->fileName(),
1295  sipCpp == QgsProject::instance() ? QStringLiteral( " (singleton instance)" ) : QString() );
1296  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
1297  % End
1298 #endif
1299 
1300  signals:
1301 
1309  void cleared();
1310 
1314  void readProject( const QDomDocument & );
1315 
1319  void readProjectWithContext( const QDomDocument &, QgsReadWriteContext &context );
1320 
1324  void writeProject( QDomDocument & );
1325 
1334  void readMapLayer( QgsMapLayer *mapLayer, const QDomElement &layerNode );
1335 
1344  void writeMapLayer( QgsMapLayer *mapLayer, QDomElement &layerElem, QDomDocument &doc );
1345 
1349  void projectSaved();
1350 
1354  void oldProjectVersionWarning( const QString & );
1355 
1361  void layerLoaded( int i, int n );
1362 
1364  void loadingLayer( const QString &layerName );
1365 
1372  void loadingLayerMessageReceived( const QString &layerName, const QList<QgsReadWriteContext::ReadWriteMessage> &messages );
1373 
1378  Q_DECL_DEPRECATED void nonIdentifiableLayersChanged( QStringList nonIdentifiableLayers );
1379 
1381  void fileNameChanged();
1382 
1389  void homePathChanged();
1390 
1394  void snappingConfigChanged( const QgsSnappingConfig &config );
1395 
1400  void customVariablesChanged();
1401 
1407  void crsChanged();
1408 
1416  void ellipsoidChanged( const QString &ellipsoid );
1417 
1418 
1425  void transformContextChanged();
1426 
1431  void missingDatumTransforms( const QStringList &missingTransforms );
1432 
1439  void transactionGroupsChanged();
1440 
1446  void topologicalEditingChanged();
1447 
1453  void avoidIntersectionsLayersChanged();
1454 
1466  void mapThemeCollectionChanged();
1467 
1472  void labelingEngineSettingsChanged();
1473 
1480  void metadataChanged();
1481 
1488  void projectColorsChanged();
1489 
1496  void backgroundColorChanged();
1497 
1504  void selectionColorChanged();
1505 
1506  //
1507  // signals from QgsMapLayerRegistry
1508  //
1509 
1517  void layersWillBeRemoved( const QStringList &layerIds );
1518 
1526  void layersWillBeRemoved( const QList<QgsMapLayer *> &layers );
1527 
1537  void layerWillBeRemoved( const QString &layerId );
1538 
1548  void layerWillBeRemoved( QgsMapLayer *layer );
1549 
1556  void layersRemoved( const QStringList &layerIds );
1557 
1566  void layerRemoved( const QString &layerId );
1567 
1568  //TODO QGIS 4.0 - rename to past tense
1569 
1576  void removeAll();
1577 
1588  void layersAdded( const QList<QgsMapLayer *> &layers );
1589 
1596  void layerWasAdded( QgsMapLayer *layer );
1597 
1606  void legendLayersAdded( const QList<QgsMapLayer *> &layers );
1607 
1615  void isDirtyChanged( bool dirty );
1616 
1630  void collectAttachedFiles( QgsStringMap &files SIP_INOUT ) SIP_SKIP;
1631 
1640  Q_DECL_DEPRECATED void mapScalesChanged() SIP_DEPRECATED;
1641 
1642  public slots:
1643 
1649  void setSnappingConfig( const QgsSnappingConfig &snappingConfig );
1650 
1651  // TODO QGIS 4.0 - rename b to dirty
1652 
1660  void setDirty( bool b = true );
1661 
1670  void setPresetHomePath( const QString &path );
1671 
1681  void registerTranslatableContainers( QgsTranslationContext *translationContext, QgsAttributeEditorContainer *parent, const QString &layerId );
1682 
1689  void registerTranslatableObjects( QgsTranslationContext *translationContext );
1690 
1691  private slots:
1692  void onMapLayersAdded( const QList<QgsMapLayer *> &layers );
1693  void onMapLayersRemoved( const QList<QgsMapLayer *> &layers );
1694  void cleanTransactionGroups( bool force = false );
1695 
1696  private:
1697 
1698  static QgsProject *sProject;
1699 
1708  static void setInstance( QgsProject *project ) SIP_SKIP;
1709 
1718  bool _getMapLayers( const QDomDocument &doc, QList<QDomNode> &brokenNodes, QgsProject::ReadFlags flags = nullptr );
1719 
1724  void setError( const QString &errorMessage ) SIP_SKIP;
1725 
1730  void clearError() SIP_SKIP;
1731 
1739  bool addLayer( const QDomElement &layerElem, QList<QDomNode> &brokenNodes, QgsReadWriteContext &context, QgsProject::ReadFlags flags = nullptr ) SIP_SKIP;
1740 
1746  void initializeEmbeddedSubtree( const QString &projectFilePath, QgsLayerTreeGroup *group, QgsProject::ReadFlags flags = nullptr ) SIP_SKIP;
1747 
1752  bool loadEmbeddedNodes( QgsLayerTreeGroup *group, QgsProject::ReadFlags flags = nullptr ) SIP_SKIP;
1753 
1755  bool readProjectFile( const QString &filename, QgsProject::ReadFlags flags = nullptr );
1756 
1758  bool writeProjectFile( const QString &filename );
1759 
1761  bool unzip( const QString &filename, QgsProject::ReadFlags flags = nullptr );
1762 
1764  bool zip( const QString &filename );
1765 
1767  bool saveAuxiliaryStorage( const QString &filename = QString() );
1768 
1769  std::unique_ptr< QgsMapLayerStore > mLayerStore;
1770 
1771  QString mErrorMessage;
1772 
1773  QgsProjectBadLayerHandler *mBadLayerHandler = nullptr;
1774 
1780  QHash< QString, QPair< QString, bool> > mEmbeddedLayers;
1781 
1782  QgsSnappingConfig mSnappingConfig;
1783 
1784  QgsRelationManager *mRelationManager = nullptr;
1785 
1786  std::unique_ptr<QgsAnnotationManager> mAnnotationManager;
1787  std::unique_ptr<QgsLayoutManager> mLayoutManager;
1788 
1789  QgsBookmarkManager *mBookmarkManager = nullptr;
1790 
1791  QgsProjectViewSettings *mViewSettings = nullptr;
1792 
1793  QgsProjectDisplaySettings *mDisplaySettings = nullptr;
1794 
1795  QgsLayerTree *mRootGroup = nullptr;
1796 
1797  QgsLayerTreeRegistryBridge *mLayerTreeRegistryBridge = nullptr;
1798 
1800  QMap< QPair< QString, QString>, QgsTransactionGroup *> mTransactionGroups;
1801 
1802  std::unique_ptr<QgsMapThemeCollection> mMapThemeCollection;
1803 
1804  std::unique_ptr<QgsLabelingEngineSettings> mLabelingEngineSettings;
1805 
1806  QVariantMap mCustomVariables;
1807 
1808  std::unique_ptr<QgsProjectArchive> mArchive;
1809 
1810  std::unique_ptr<QgsAuxiliaryStorage> mAuxiliaryStorage;
1811 
1812  QFile mFile; // current physical project file
1813 
1814  QString mSaveUser; // last saved user.
1815  QString mSaveUserFull; // last saved user full name.
1816 
1821  QString mHomePath;
1822  mutable QString mCachedHomePath;
1823 
1824  QColor mBackgroundColor;
1825  QColor mSelectionColor;
1826 
1827  mutable QgsProjectPropertyKey mProperties; // property hierarchy, TODO: this shouldn't be mutable
1828  bool mAutoTransaction = false; // transaction grouped editing
1829  bool mEvaluateDefaultValues = false; // evaluate default values immediately
1831  bool mDirty = false; // project has been modified since it has been read or saved
1832  int mDirtyBlockCount = 0;
1833  bool mTrustLayerMetadata = false;
1834 
1835  QgsCoordinateTransformContext mTransformContext;
1836 
1837  QgsProjectMetadata mMetadata;
1838 
1839  std::unique_ptr< QTranslator > mTranslator;
1840 
1841  bool mIsBeingDeleted = false;
1842 
1843  mutable std::unique_ptr< QgsExpressionContextScope > mProjectScope;
1844 
1846 
1847  // Required to avoid creating a new project in it's destructor
1848  friend class QgsProviderRegistry;
1849 
1850  // Required by QGIS Server for switching the current project instance
1851  friend class QgsConfigCache;
1852 
1853  friend class TestQgsProject;
1854 };
1855 
1856 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProject::ReadFlags )
1857 
1858 
1879 class CORE_EXPORT QgsProjectDirtyBlocker
1880 {
1881  public:
1882 
1889  : mProject( project )
1890  {
1891  mProject->mDirtyBlockCount++;
1892  }
1893 
1895  QgsProjectDirtyBlocker( const QgsProjectDirtyBlocker &other ) = delete;
1896 
1898  QgsProjectDirtyBlocker &operator=( const QgsProjectDirtyBlocker &other ) = delete;
1899 
1901  {
1902  mProject->mDirtyBlockCount--;
1903  }
1904 
1905  private:
1906  QgsProject *mProject = nullptr;
1907 
1908 #ifdef SIP_RUN
1909  QgsProjectDirtyBlocker( const QgsProjectDirtyBlocker &other );
1910 #endif
1911 };
1912 
1918 CORE_EXPORT QgsProjectVersion getVersion( QDomDocument const &doc ) SIP_SKIP;
1919 
1920 
1921 
1923 #ifndef SIP_RUN
1924 class GetNamedProjectColor : public QgsScopedExpressionFunction
1925 {
1926  public:
1927  GetNamedProjectColor( const QgsProject *project );
1928 
1933  GetNamedProjectColor( const QHash< QString, QColor > &colors );
1934 
1935  QVariant func( const QVariantList &values, const QgsExpressionContext *, QgsExpression *, const QgsExpressionNodeFunction * ) override;
1936  QgsScopedExpressionFunction *clone() const override;
1937 
1938  private:
1939 
1940  QHash< QString, QColor > mColors;
1941 
1942 };
1943 
1944 #endif
1945 
1947 #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.
Class providing some utility methods to manage auxiliary storage.
#define SIP_MONKEYPATCH_SCOPEENUM
Definition: qgis_sip.h:251
Manages storage of a set of bookmarks.
#define SIP_INOUT
Definition: qgis_sip.h:71
QgsLayerTreeRegistryBridge * layerTreeRegistryBridge() const
Returns pointer to the helper class that synchronizes map layer registry with layer tree...
Definition: qgsproject.h:639
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:694
FileFormat
Flags which control project read behavior.
Definition: qgsproject.h:125
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:829
bool trustLayerMetadata() const
Returns true if the trust option is activated, false otherwise.
Definition: qgsproject.h:1103
ReadFlag
Flags which control project read behavior.
Definition: qgsproject.h:114
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:933
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:91
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.
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.
Contains settings and properties relating to how a QgsProject should be displayed inside map canvas...
A registry / canonical manager of data providers.
Project property key node.
DistanceUnit
Units of distance.
Definition: qgsunittypes.h:66
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:885
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:450
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:1888
Temporarily blocks QgsProject "dirtying" for the lifetime of the object.
Definition: qgsproject.h:1879
A storage object for map layers, in which the layers are owned by the store and have their lifetime b...
Contains settings and properties relating to how a QgsProject should display values such as map coord...
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.
AreaUnit
Units of area.
Definition: qgsunittypes.h:92
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:902
#define SIP_PYNAME(name)
Definition: qgis_sip.h:81
A structured metadata store for a map layer.