16#ifndef QGSPROCESSINGTOOLBOXMODEL_H
17#define QGSPROCESSINGTOOLBOXMODEL_H
21#include <QAbstractItemModel>
22#include <QSortFilterProxyModel>
29class QgsProcessingToolboxModelGroupNode;
30class QgsProcessingRecentAlgorithmLog;
40class GUI_EXPORT QgsProcessingToolboxModelNode :
public QObject
46 if ( sipCpp->inherits(
"QgsProcessingToolboxModelNode" ) )
48 sipType = sipType_QgsProcessingToolboxModelNode;
49 QgsProcessingToolboxModelNode *node = qobject_cast<QgsProcessingToolboxModelNode *>( sipCpp );
50 if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeType::Provider )
51 sipType = sipType_QgsProcessingToolboxModelProviderNode;
52 else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeType::Group )
53 sipType = sipType_QgsProcessingToolboxModelGroupNode;
54 else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeType::Algorithm )
55 sipType = sipType_QgsProcessingToolboxModelAlgorithmNode;
56 else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeType::Recent )
57 sipType = sipType_QgsProcessingToolboxModelRecentNode;
79 ~QgsProcessingToolboxModelNode()
override;
84 virtual NodeType nodeType()
const = 0;
89 QgsProcessingToolboxModelNode *parent() {
return mParent; }
94 QList<QgsProcessingToolboxModelNode *> children() {
return mChildren; }
100 QList<QgsProcessingToolboxModelNode *> children()
const {
return mChildren; }
SIP_SKIP
106 QgsProcessingToolboxModelNode *takeChild( QgsProcessingToolboxModelNode *node );
113 QgsProcessingToolboxModelGroupNode *getChildGroupNode(
const QString &
id );
119 void addChildNode( QgsProcessingToolboxModelNode *node
SIP_TRANSFER );
124 void deleteChildren();
128 NodeType mNodeType = NodeType::Provider;
129 QgsProcessingToolboxModelNode *mParent =
nullptr;
130 QList<QgsProcessingToolboxModelNode *> mChildren;
140class GUI_EXPORT QgsProcessingToolboxModelRecentNode :
public QgsProcessingToolboxModelNode
149 QgsProcessingToolboxModelRecentNode() =
default;
151 NodeType nodeType()
const override {
return NodeType::Recent; }
161class GUI_EXPORT QgsProcessingToolboxModelProviderNode :
public QgsProcessingToolboxModelNode
173 NodeType nodeType()
const override {
return NodeType::Provider; }
183 QString providerId()
const {
return mProviderId; }
193 QPointer< QgsProcessingProvider > mProvider;
203class GUI_EXPORT QgsProcessingToolboxModelGroupNode :
public QgsProcessingToolboxModelNode
216 QgsProcessingToolboxModelGroupNode(
const QString &
id,
const QString &name );
218 NodeType nodeType()
const override {
return NodeType::Group; }
223 QString id()
const {
return mId; }
228 QString name()
const {
return mName; }
242class GUI_EXPORT QgsProcessingToolboxModelAlgorithmNode :
public QgsProcessingToolboxModelNode
254 NodeType nodeType()
const override {
return NodeType::Algorithm; }
317 QgsProcessingRecentAlgorithmLog *recentLog =
nullptr );
319 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
320 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
321 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
322 int columnCount(
const QModelIndex & = QModelIndex() )
const override;
323 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
324 QModelIndex parent(
const QModelIndex &index )
const override;
325 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
331 QgsProcessingToolboxModelNode *index2node(
const QModelIndex &index )
const;
337 QModelIndex node2index( QgsProcessingToolboxModelNode *node )
const;
355 QString providerIdForIndex(
const QModelIndex &index )
const;
371 bool isAlgorithm(
const QModelIndex &index )
const;
377 QModelIndex indexForProvider(
const QString &providerId )
const;
382 QModelIndex indexOfParentTreeNode( QgsProcessingToolboxModelNode *parentNode )
const;
394 void repopulateRecentAlgorithms(
bool resetting =
false );
395 void providerAdded(
const QString &
id );
396 void providerRemoved(
const QString &
id );
400 QPointer< QgsProcessingRegistry > mRegistry;
401 QPointer< QgsProcessingRecentAlgorithmLog > mRecentLog;
403 std::unique_ptr< QgsProcessingToolboxModelGroupNode > mRootNode;
404 QgsProcessingToolboxModelRecentNode *mRecentNode =
nullptr;
412 static bool isTopLevelProvider(
const QString &providerId );
464 QgsProcessingRecentAlgorithmLog *recentLog =
nullptr );
503 void setFilterString(
const QString &filter );
512 bool filterAcceptsRow(
int sourceRow,
const QModelIndex &sourceParent )
const override;
513 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
514 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
519 Filters mFilters = Filters();
520 QString mFilterString;
521 QPointer<QgsVectorLayer> mInPlaceLayer;
Abstract base class for processing algorithms.
Abstract base class for processing providers.
Registry for various processing components, including providers, algorithms and various parameters an...
Represents a vector layer which manages a vector based data sets.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_ENUM_BASETYPE(type)
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsTextRendererUtils::CurvedTextFlags)