35 QList<QgsMapLayer *> layersList;
39 const QMap<QString, QgsMapLayer *> mapLayers( project->
mapLayers() );
52 QList<QgsMapLayer *> layersList;
56 const QMap<QString, QgsMapLayer *> mapLayers( project->
mapLayers() );
59 if ( layer->providerType() != provider )
84 const QMap<QString, QgsMapLayer *> mapLayers( project->
mapLayers() );
103 if ( groupLayer->childLayers().contains( layer ) )
116 const QList< QgsLayerTreeNode * > children = group->
children();
119 if (
QgsLayerTreeGroup *childGroup = qobject_cast< QgsLayerTreeGroup * >( node ) )
121 if ( traverseTree( childGroup ) )
133 switch ( embeddedScriptMode )
152 QString absoluteFilePath;
153 QString absolutePath;
160 absoluteFilePath = fileInfo.absoluteFilePath();
161 absolutePath = fileInfo.absolutePath();
171 QFileInfo fileInfo( project->
fileName() );
172 absoluteFilePath = fileInfo.absoluteFilePath();
173 absolutePath = fileInfo.absolutePath();
177 for (
const QString &path : untrustedProjectsFolders )
179 if ( absoluteFilePath == path || absolutePath == path )
186 for (
const QString &path : trustedProjectsFolders )
188 if ( absoluteFilePath == path || absolutePath == path )
ProjectTrustStatus
Project trust status.
@ Untrusted
The project has been determined by the user as trusted.
@ Trusted
The project trust has not yet been determined by the user.
SourceHierarchyLevel
Defines the structural levels within a data source hierarchy.
EmbeddedScriptMode
Authorisation to run script embedded in projects.
@ Always
Embedded scripts are always run.
@ NotForThisSession
Embedded scripts will not be run for this session (only used prior to QGIS 4.0).
@ Never
Embedded scripts never run.
@ Ask
User is prompted before running scripts.
@ NeverAsk
The user is never prompted, embedded scripts are only run on trusted projects and folders.
@ SessionOnly
Only during this session (only used prior to QGIS 4.0).
static QgsProjectStorageRegistry * projectStorageRegistry()
Returns registry of available project storage implementations.
static QStringList temporarilyTrustedProjectsFolders()
Returns the list of projects and folders that have been temporarily determined as trusted by the user...
static QStringList temporarilyUntrustedProjectsFolders()
Returns the list of projects and folders that have been temporarily determined as untrusted by the us...
A map layer which consists of a set of child layers, where all component layers are rendered as a sin...
Layer tree group node serves as a container for layers and further groups.
QgsLayerTreeLayer * findLayer(QgsMapLayer *layer) const
Find layer node representing the map layer.
QgsGroupLayer * groupLayer()
Returns a reference to the associated group layer, if the layer tree group will be treated as group l...
Base class for nodes in a layer tree.
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
static bool updateLayerSourcePath(QgsMapLayer *layer, const QString &newPath)
Updates a layer's data source, replacing its data source with a path referring to newPath.
static bool layerRefersToUri(const QgsMapLayer *layer, const QString &uri, Qgis::SourceHierarchyLevel level=Qgis::SourceHierarchyLevel::Object)
Returns true if a layer and uri point to the same resource at the specified hierarchy level.
static bool layerSourceMatchesPath(const QgsMapLayer *layer, const QString &path)
Returns true if the source of the specified layer matches the given path.
Base class for all map layer types.
Custom exception class which is raised when an operation is not supported.
QgsProjectStorage * projectStorageFromUri(const QString &uri)
Returns storage implementation if the URI matches one. Returns nullptr otherwise (it is a normal file...
Abstract interface for project storage - to be implemented by various backends and registered in QgsP...
virtual QString filePath(const QString &uri)
Extracts and returns the file path from a storage backend uri, filesystem-based storage backends shou...
static bool updateLayerPath(QgsProject *project, const QString &oldPath, const QString &newPath)
Updates a project, replacing the data source for all layers which match the given oldPath with source...
static QList< QgsMapLayer * > layersMatchingUri(const QgsProject *project, const QString &provider, const QString &uri, Qgis::SourceHierarchyLevel level=Qgis::SourceHierarchyLevel::Object)
Returns a list of all layers in the specified project point to the same uri resource at the specified...
static Qgis::ProjectTrustStatus checkUserTrust(QgsProject *project)
Returns the current trust status of the specified project.
static bool layerIsContainedInGroupLayer(QgsProject *project, QgsMapLayer *layer)
Returns true if the specified layer is a child layer from any QgsGroupLayer in the given project.
static QList< QgsMapLayer * > layersMatchingPath(const QgsProject *project, const QString &path)
Returns a list of all layers in the specified project which match the given path.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QVector< T > layers() const
Returns a list of registered map layers with a specified layer type.
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.
QMap< QString, QgsMapLayer * > mapLayers(const bool validOnly=false) const
Returns a map of all registered layers by layer ID.
static const QgsSettingsEntryStringList * settingsCodeExecutionTrustedProjectsFolders
Settings entry for projects and folders that are allowed execution of embedded scripts across session...
static const QgsSettingsEntryStringList * settingsCodeExecutionUntrustedProjectsFolders
Settings entry for projects and folders that are denied execution of embedded scripts across sessions...
static const QgsSettingsEntryEnumFlag< Qgis::EmbeddedScriptMode > * settingsCodeExecutionBehaviorUndeterminedProjects
Settings entry for behavior handling embedded scripts within projects.