27using namespace Qt::StringLiterals;
36 if ( settings.
value( u
"Processing/Configuration/VECTOR_FEATURE_COUNT"_s,
false ).toBool() )
46 if ( !destinationProject )
54 const QString resultsGroupName = settings.
value( u
"Processing/Configuration/RESULTS_GROUP_NAME"_s, QString() ).toString();
56 if ( !resultsGroupName.isEmpty() )
94 QVector<ResultLayerDetails> sortedLayers = layers;
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 )
148 if ( project && insertionPoint.has_value() )
160 if ( !haveSetActiveLayer && view )
163 haveSetActiveLayer =
true;
167 if ( project && previousInsertionPoint.has_value() )
178 {
"native:distancematrix",
179 "native:sumlinelengths",
180 "native:countpointsinpolygon",
181 "native:listuniquevalues",
182 "native:basicstatisticsforfields",
183 "native:nearestneighbouranalysis",
184 "native:meancoordinates",
185 "native:lineintersections" } },
187 {
"native:creategrid",
188 "native:randomselection",
189 "native:randomselectionwithinsubsets",
190 "native:randompointsinextent",
191 "qgis:randompointsinlayerbounds",
192 "native:randompointsinpolygons",
193 "qgis:randompointsinsidepolygons",
194 "native:randompointsonlines",
195 "qgis:regularpoints",
196 "native:selectbylocation",
197 "native:selectwithindistance",
198 "native:polygonfromlayerextent" } },
200 {
"native:buffer",
"native:convexhull",
"native:intersection",
"native:union",
"native:symmetricaldifference",
"native:clip",
"native:difference",
"native:dissolve",
"qgis:eliminateselectedpolygons" } },
202 {
"native:checkvalidity",
203 "native:exportaddgeometrycolumns",
205 "native:delaunaytriangulation",
206 "native:voronoipolygons",
207 "native:simplifygeometries",
208 "native:densifygeometries",
209 "native:multiparttosingleparts",
211 "native:polygonstolines",
212 "qgis:linestopolygons",
213 "native:extractvertices" } },
215 {
"native:reprojectlayer",
"native:joinattributesbylocation",
"native:splitvectorlayer",
"native:mergevectorlayers",
"native:createspatialindex" } },
224 "gdal:griddatametrics",
226 "gdal:gridinversedistance",
227 "gdal:gridnearestneighbor",
232 "gdal:tpitopographicpositionindex",
233 "gdal:triterrainruggednessindex" } },
@ RasterExtraction
Raster Extraction menu.
@ VectorAnalysis
Vector Analysis menu.
@ VectorGeometry
Vector Geometry menu.
@ VectorResearch
Vector Research menu.
@ RasterAnalysis
Raster Analysis menu.
@ RasterGeneral
Raster (top-level) menu.
@ RasterConversion
Raster Conversion menu.
@ RasterMiscellaneous
Raster Miscellaneous menu.
@ VectorDataManagement
Vector Data Management menu.
@ RasterProjections
Raster Projections menu.
@ VectorGeoprocessing
Vector Geoprocessing menu.
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.
QgsLayerTreeNode * currentNode() const
Returns the current node.
void setCurrentLayer(QgsMapLayer *layer)
Sets the currently selected layer.
Extends QTreeView and provides additional functionality when working with a layer tree.
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 QMap< int, QStringList > defaultProcessingMenuEntries()
Returns the map of Processing menus to a list of algorithm IDs to include by default in that menu.
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.