30 if ( settings.
value( QStringLiteral(
"Processing/Configuration/VECTOR_FEATURE_COUNT" ),
false ).toBool() )
40 if ( !destinationProject )
48 const QString resultsGroupName = settings.
value( QStringLiteral(
"Processing/Configuration/RESULTS_GROUP_NAME" ), QString() ).toString();
50 if ( !resultsGroupName.isEmpty() )
90 QVector<ResultLayerDetails> sortedLayers = layers;
93 return a.sortKey < b.sortKey;
97 bool haveSetActiveLayer =
false;
104 int defaultTargetGroupIndex = 0;
105 if (
auto currentSelectedLayer = qobject_cast< QgsLayerTreeLayer * >( currentSelectedNode ) )
107 defaultTargetGroup = qobject_cast< QgsLayerTreeGroup * >( currentSelectedLayer->parent() );
108 if ( defaultTargetGroup )
109 defaultTargetGroupIndex = defaultTargetGroup->
children().indexOf( currentSelectedNode );
111 if (
auto currentSelectedGroup = qobject_cast< QgsLayerTreeGroup * >( currentSelectedNode ) )
113 defaultTargetGroup = currentSelectedGroup;
118 QgsProject *project = layerDetails.destinationProject;
123 std::optional< QgsLayerTreeRegistryBridge::InsertionPoint > previousInsertionPoint;
129 std::optional< QgsLayerTreeRegistryBridge::InsertionPoint > insertionPoint;
130 if ( layerDetails.targetLayerTreeGroup )
138 if ( defaultTargetGroup )
141 defaultTargetGroup, defaultTargetGroupIndex
152 if ( project && insertionPoint.has_value() )
164 if ( !haveSetActiveLayer && view )
167 haveSetActiveLayer =
true;
171 if ( project && previousInsertionPoint.has_value() )
174 *previousInsertionPoint
Layer tree group node serves as a container for layers and further groups.
QgsLayerTreeGroup * findGroup(const QString &name)
Find group node with specified name.
QgsLayerTreeGroup * insertGroup(int index, const QString &name)
Insert a new group node with given name at specified position.
QgsLayerTreeLayer * findLayer(QgsMapLayer *layer) const
Find layer node representing the map layer.
Layer tree node points to a map layer.
QgsMapLayer * layer() const
Returns the map layer associated with this node.
Base class for nodes in a layer tree.
void setCustomProperty(const QString &key, const QVariant &value)
Sets a custom property for the node. Properties are stored in a map and saved in project file.
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
void setExpanded(bool expanded)
Sets whether the node should be shown as expanded or collapsed in GUI.
Q_DECL_DEPRECATED void setLayerInsertionPoint(QgsLayerTreeGroup *parentGroup, int index)
Set where the new layers should be inserted - can be used to follow current selection.
InsertionPoint layerInsertionPoint() const
Returns the insertion point used to add layers to the tree.
Extends QTreeView and provides additional functionality when working with a layer tree.
void setCurrentLayer(QgsMapLayer *layer)
Sets the currently selected layer.
QgsLayerTreeNode * currentNode() const
Gets current node. May be nullptr.
Base class for all map layer types.
Details for layers to load into projects.
QString groupName
Optional name for a layer tree group under which to place the layer when loading it into a project.
QgsProject * project
Destination project.
Contains information about the context in which a processing algorithm is executed.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
Contains details of a layer result from running an algorithm.
static void addResultLayers(const QVector< QgsProcessingGuiUtils::ResultLayerDetails > &layers, const QgsProcessingContext &context, QgsLayerTreeView *view=nullptr)
Responsible for adding layers created by an algorithm to a project and the project's layer tree in th...
static void configureResultLayerTreeLayer(QgsLayerTreeLayer *layerTreeLayer)
Applies post-processing steps to the QgsLayerTreeLayer created for an algorithm's output.
static QgsLayerTreeGroup * layerTreeResultsGroup(const QgsProcessingContext::LayerDetails &layerDetails, const QgsProcessingContext &context)
Returns the destination layer tree group to store results in, or nullptr if there is no specific dest...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QgsLayerTreeRegistryBridge * layerTreeRegistryBridge() const
Returns pointer to the helper class that synchronizes map layer registry with layer tree.
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.
QgsMapLayer * addMapLayer(QgsMapLayer *mapLayer, bool addToLegend=true, bool takeOwnership=true)
Add a layer to the map of loaded layers.
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
A structure to define the insertion point to the layer tree.