35 QList<QgsMapLayer *> layersList;
39 const QMap<QString, QgsMapLayer *> mapLayers( project->
mapLayers() );
56 const QMap<QString, QgsMapLayer *> mapLayers( project->
mapLayers() );
75 if ( groupLayer->childLayers().contains( layer ) )
88 const QList< QgsLayerTreeNode * > children = group->
children();
91 if (
QgsLayerTreeGroup *childGroup = qobject_cast< QgsLayerTreeGroup * >( node ) )
93 if ( traverseTree( childGroup ) )
105 switch ( embeddedScriptMode )
124 QString absoluteFilePath;
125 QString absolutePath;
132 absoluteFilePath = fileInfo.absoluteFilePath();
133 absolutePath = fileInfo.absolutePath();
143 QFileInfo fileInfo( project->
fileName() );
144 absoluteFilePath = fileInfo.absoluteFilePath();
145 absolutePath = fileInfo.absolutePath();
149 for (
const QString &path : untrustedProjectsFolders )
151 if ( absoluteFilePath == path || absolutePath == path )
158 for (
const QString &path : trustedProjectsFolders )
160 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.
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 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.
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 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.