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 QgsProcessingToolboxModelNode *mParent =
nullptr;
133 QList<QgsProcessingToolboxModelNode *> mChildren;
143class GUI_EXPORT QgsProcessingToolboxModelRecentNode :
public QgsProcessingToolboxModelNode
149 QgsProcessingToolboxModelRecentNode() =
default;
151 NodeType nodeType()
const override {
return NodeType::Recent; }
161class GUI_EXPORT QgsProcessingToolboxModelFavoriteNode :
public QgsProcessingToolboxModelNode
167 QgsProcessingToolboxModelFavoriteNode() =
default;
169 NodeType nodeType()
const override {
return NodeType::Favorite; }
179class GUI_EXPORT QgsProcessingToolboxModelProviderNode :
public QgsProcessingToolboxModelNode
191 NodeType nodeType()
const override {
return NodeType::Provider; }
201 QString providerId()
const {
return mProviderId; }
211 QPointer< QgsProcessingProvider > mProvider;
221class GUI_EXPORT QgsProcessingToolboxModelGroupNode :
public QgsProcessingToolboxModelNode
234 QgsProcessingToolboxModelGroupNode(
const QString &
id,
const QString &name );
236 NodeType nodeType()
const override {
return NodeType::Group; }
241 QString id()
const {
return mId; }
246 QString name()
const {
return mName; }
260class GUI_EXPORT QgsProcessingToolboxModelAlgorithmNode :
public QgsProcessingToolboxModelNode
272 NodeType nodeType()
const override {
return NodeType::Algorithm; }
338 QgsProcessingRecentAlgorithmLog *recentLog =
nullptr,
339 QgsProcessingFavoriteAlgorithmManager *favoriteManager =
nullptr );
341 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
342 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
343 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
344 int columnCount(
const QModelIndex & = QModelIndex() )
const override;
345 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
346 QModelIndex parent(
const QModelIndex &index )
const override;
347 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
353 QgsProcessingToolboxModelNode *index2node(
const QModelIndex &index )
const;
359 QModelIndex node2index( QgsProcessingToolboxModelNode *node )
const;
377 QString providerIdForIndex(
const QModelIndex &index )
const;
393 bool isAlgorithm(
const QModelIndex &index )
const;
399 QModelIndex indexForProvider(
const QString &providerId )
const;
404 QModelIndex indexOfParentTreeNode( QgsProcessingToolboxModelNode *parentNode )
const;
421 void repopulateRecentAlgorithms(
bool resetting =
false );
422 void repopulateFavoriteAlgorithms(
bool resetting =
false );
423 void providerAdded(
const QString &
id );
424 void providerRemoved(
const QString &
id );
428 QPointer< QgsProcessingRegistry > mRegistry;
429 QPointer< QgsProcessingRecentAlgorithmLog > mRecentLog;
430 QPointer< QgsProcessingFavoriteAlgorithmManager > mFavoriteManager;
432 std::unique_ptr< QgsProcessingToolboxModelGroupNode > mRootNode;
433 QgsProcessingToolboxModelRecentNode *mRecentNode =
nullptr;
434 QgsProcessingToolboxModelFavoriteNode *mFavoriteNode =
nullptr;
442 static bool isTopLevelProvider(
const QString &providerId );
497 QgsProcessingRecentAlgorithmLog *recentLog =
nullptr,
498 QgsProcessingFavoriteAlgorithmManager *favoriteManager =
nullptr );
537 void setFilterString(
const QString &filter );
546 bool filterAcceptsRow(
int sourceRow,
const QModelIndex &sourceParent )
const override;
547 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
548 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
553 Filters mFilters = Filters();
554 QString mFilterString;
555 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)