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;
82 ~QgsProcessingToolboxModelNode()
override;
87 virtual NodeType nodeType()
const = 0;
92 QgsProcessingToolboxModelNode *parent() {
return mParent; }
97 QList<QgsProcessingToolboxModelNode *> children() {
return mChildren; }
103 QList<QgsProcessingToolboxModelNode *> children() const
SIP_SKIP
112 QgsProcessingToolboxModelNode *takeChild( QgsProcessingToolboxModelNode *node );
119 QgsProcessingToolboxModelGroupNode *getChildGroupNode(
const QString &
id );
125 void addChildNode( QgsProcessingToolboxModelNode *node
SIP_TRANSFER );
130 void deleteChildren();
133 QgsProcessingToolboxModelNode *mParent =
nullptr;
134 QList<QgsProcessingToolboxModelNode *> mChildren;
143class GUI_EXPORT QgsProcessingToolboxModelRecentNode :
public QgsProcessingToolboxModelNode
148 QgsProcessingToolboxModelRecentNode() =
default;
150 NodeType nodeType()
const override {
return NodeType::Recent; }
159class GUI_EXPORT QgsProcessingToolboxModelFavoriteNode :
public QgsProcessingToolboxModelNode
164 QgsProcessingToolboxModelFavoriteNode() =
default;
166 NodeType nodeType()
const override {
return NodeType::Favorite; }
175class GUI_EXPORT QgsProcessingToolboxModelProviderNode :
public QgsProcessingToolboxModelNode
186 NodeType nodeType()
const override {
return NodeType::Provider; }
196 QString providerId()
const {
return mProviderId; }
205 QPointer<QgsProcessingProvider> mProvider;
214class GUI_EXPORT QgsProcessingToolboxModelGroupNode :
public QgsProcessingToolboxModelNode
226 QgsProcessingToolboxModelGroupNode(
const QString &
id,
const QString &name );
228 NodeType nodeType()
const override {
return NodeType::Group; }
233 QString id()
const {
return mId; }
238 QString name()
const {
return mName; }
251class GUI_EXPORT QgsProcessingToolboxModelAlgorithmNode :
public QgsProcessingToolboxModelNode
262 NodeType nodeType()
const override {
return NodeType::Algorithm; }
326 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
327 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
328 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
329 int columnCount(
const QModelIndex & = QModelIndex() )
const override;
330 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
331 QModelIndex parent(
const QModelIndex &index )
const override;
332 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
338 QgsProcessingToolboxModelNode *index2node(
const QModelIndex &index )
const;
344 QModelIndex node2index( QgsProcessingToolboxModelNode *node )
const;
362 QString providerIdForIndex(
const QModelIndex &index )
const;
378 bool isAlgorithm(
const QModelIndex &index )
const;
384 QModelIndex indexForProvider(
const QString &providerId )
const;
389 QModelIndex indexOfParentTreeNode( QgsProcessingToolboxModelNode *parentNode )
const;
406 void repopulateRecentAlgorithms(
bool resetting =
false );
407 void repopulateFavoriteAlgorithms(
bool resetting =
false );
408 void providerAdded(
const QString &
id );
409 void providerRemoved(
const QString &
id );
412 QPointer<QgsProcessingRegistry> mRegistry;
413 QPointer<QgsProcessingRecentAlgorithmLog> mRecentLog;
414 QPointer<QgsProcessingFavoriteAlgorithmManager> mFavoriteManager;
416 std::unique_ptr<QgsProcessingToolboxModelGroupNode> mRootNode;
417 QgsProcessingToolboxModelRecentNode *mRecentNode =
nullptr;
418 QgsProcessingToolboxModelFavoriteNode *mFavoriteNode =
nullptr;
426 static bool isTopLevelProvider(
const QString &providerId );
516 void setFilterString(
const QString &filter );
525 bool filterAcceptsRow(
int sourceRow,
const QModelIndex &sourceParent )
const override;
526 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
527 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
531 Filters mFilters = Filters();
532 QString mFilterString;
533 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)