16#ifndef QGSPROCESSINGTOOLBOXMODEL_H
17#define QGSPROCESSINGTOOLBOXMODEL_H
21#include <QAbstractItemModel>
22#include <QSortFilterProxyModel>
29class QgsProcessingToolboxModelGroupNode;
30class QgsProcessingRecentAlgorithmLog;
31class QgsProcessingFavoriteAlgorithmManager;
41class GUI_EXPORT QgsProcessingToolboxModelNode :
public QObject
47 if ( sipCpp->inherits(
"QgsProcessingToolboxModelNode" ) )
49 sipType = sipType_QgsProcessingToolboxModelNode;
50 QgsProcessingToolboxModelNode *node = qobject_cast<QgsProcessingToolboxModelNode *>( sipCpp );
51 if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeType::Provider )
52 sipType = sipType_QgsProcessingToolboxModelProviderNode;
53 else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeType::Group )
54 sipType = sipType_QgsProcessingToolboxModelGroupNode;
55 else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeType::Algorithm )
56 sipType = sipType_QgsProcessingToolboxModelAlgorithmNode;
57 else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeType::Recent )
58 sipType = sipType_QgsProcessingToolboxModelRecentNode;
59 else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeType::Favorite )
60 sipType = sipType_QgsProcessingToolboxModelFavoriteNode;
83 ~QgsProcessingToolboxModelNode()
override;
88 virtual NodeType nodeType()
const = 0;
93 QgsProcessingToolboxModelNode *parent() {
return mParent; }
98 QList<QgsProcessingToolboxModelNode *> children() {
return mChildren; }
104 QList<QgsProcessingToolboxModelNode *> children()
const {
return mChildren; }
SIP_SKIP
110 QgsProcessingToolboxModelNode *takeChild( QgsProcessingToolboxModelNode *node );
117 QgsProcessingToolboxModelGroupNode *getChildGroupNode(
const QString &
id );
123 void addChildNode( QgsProcessingToolboxModelNode *node
SIP_TRANSFER );
128 void deleteChildren();
132 NodeType mNodeType = NodeType::Provider;
133 QgsProcessingToolboxModelNode *mParent =
nullptr;
134 QList<QgsProcessingToolboxModelNode *> mChildren;
144class GUI_EXPORT QgsProcessingToolboxModelRecentNode :
public QgsProcessingToolboxModelNode
150 QgsProcessingToolboxModelRecentNode() =
default;
152 NodeType nodeType()
const override {
return NodeType::Recent; }
162class GUI_EXPORT QgsProcessingToolboxModelFavoriteNode :
public QgsProcessingToolboxModelNode
168 QgsProcessingToolboxModelFavoriteNode() =
default;
170 NodeType nodeType()
const override {
return NodeType::Favorite; }
180class GUI_EXPORT QgsProcessingToolboxModelProviderNode :
public QgsProcessingToolboxModelNode
192 NodeType nodeType()
const override {
return NodeType::Provider; }
202 QString providerId()
const {
return mProviderId; }
212 QPointer< QgsProcessingProvider > mProvider;
222class GUI_EXPORT QgsProcessingToolboxModelGroupNode :
public QgsProcessingToolboxModelNode
235 QgsProcessingToolboxModelGroupNode(
const QString &
id,
const QString &name );
237 NodeType nodeType()
const override {
return NodeType::Group; }
242 QString id()
const {
return mId; }
247 QString name()
const {
return mName; }
261class GUI_EXPORT QgsProcessingToolboxModelAlgorithmNode :
public QgsProcessingToolboxModelNode
273 NodeType nodeType()
const override {
return NodeType::Algorithm; }
339 QgsProcessingRecentAlgorithmLog *recentLog =
nullptr,
340 QgsProcessingFavoriteAlgorithmManager *favoriteManager =
nullptr );
342 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
343 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
344 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
345 int columnCount(
const QModelIndex & = QModelIndex() )
const override;
346 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
347 QModelIndex parent(
const QModelIndex &index )
const override;
348 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
354 QgsProcessingToolboxModelNode *index2node(
const QModelIndex &index )
const;
360 QModelIndex node2index( QgsProcessingToolboxModelNode *node )
const;
378 QString providerIdForIndex(
const QModelIndex &index )
const;
394 bool isAlgorithm(
const QModelIndex &index )
const;
400 QModelIndex indexForProvider(
const QString &providerId )
const;
405 QModelIndex indexOfParentTreeNode( QgsProcessingToolboxModelNode *parentNode )
const;
422 void repopulateRecentAlgorithms(
bool resetting =
false );
423 void repopulateFavoriteAlgorithms(
bool resetting =
false );
424 void providerAdded(
const QString &
id );
425 void providerRemoved(
const QString &
id );
429 QPointer< QgsProcessingRegistry > mRegistry;
430 QPointer< QgsProcessingRecentAlgorithmLog > mRecentLog;
431 QPointer< QgsProcessingFavoriteAlgorithmManager > mFavoriteManager;
433 std::unique_ptr< QgsProcessingToolboxModelGroupNode > mRootNode;
434 QgsProcessingToolboxModelRecentNode *mRecentNode =
nullptr;
435 QgsProcessingToolboxModelFavoriteNode *mFavoriteNode =
nullptr;
443 static bool isTopLevelProvider(
const QString &providerId );
498 QgsProcessingRecentAlgorithmLog *recentLog =
nullptr,
499 QgsProcessingFavoriteAlgorithmManager *favoriteManager =
nullptr );
538 void setFilterString(
const QString &filter );
547 bool filterAcceptsRow(
int sourceRow,
const QModelIndex &sourceParent )
const override;
548 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
549 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
554 Filters mFilters = Filters();
555 QString mFilterString;
556 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)