16 #ifndef QGSPROCESSINGTOOLBOXMODEL_H 17 #define QGSPROCESSINGTOOLBOXMODEL_H 21 #include <QAbstractItemModel> 22 #include <QSortFilterProxyModel> 29 class QgsProcessingToolboxModelGroupNode;
30 class QgsProcessingRecentAlgorithmLog;
40 class 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::NodeProvider )
51 sipType = sipType_QgsProcessingToolboxModelProviderNode;
52 else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeGroup )
53 sipType = sipType_QgsProcessingToolboxModelGroupNode;
54 else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeAlgorithm )
55 sipType = sipType_QgsProcessingToolboxModelAlgorithmNode;
56 else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeRecent )
57 sipType = sipType_QgsProcessingToolboxModelRecentNode;
75 ~QgsProcessingToolboxModelNode()
override;
80 virtual NodeType nodeType()
const = 0;
85 QgsProcessingToolboxModelNode *parent() {
return mParent; }
90 QList<QgsProcessingToolboxModelNode *> children() {
return mChildren; }
96 QList<QgsProcessingToolboxModelNode *> children()
const {
return mChildren; }
SIP_SKIP 102 QgsProcessingToolboxModelNode *takeChild( QgsProcessingToolboxModelNode *node );
109 QgsProcessingToolboxModelGroupNode *getChildGroupNode(
const QString &
id );
115 void addChildNode( QgsProcessingToolboxModelNode *node
SIP_TRANSFER );
120 void deleteChildren();
125 QgsProcessingToolboxModelNode *mParent =
nullptr;
126 QList<QgsProcessingToolboxModelNode *> mChildren;
136 class GUI_EXPORT QgsProcessingToolboxModelRecentNode :
public QgsProcessingToolboxModelNode
145 QgsProcessingToolboxModelRecentNode() =
default;
147 NodeType nodeType()
const override {
return NodeRecent; }
157 class GUI_EXPORT QgsProcessingToolboxModelProviderNode :
public QgsProcessingToolboxModelNode
169 NodeType nodeType()
const override {
return NodeProvider; }
179 QString providerId()
const {
return mProviderId; }
189 QPointer< QgsProcessingProvider > mProvider;
199 class GUI_EXPORT QgsProcessingToolboxModelGroupNode :
public QgsProcessingToolboxModelNode
212 QgsProcessingToolboxModelGroupNode(
const QString &
id,
const QString &name );
214 NodeType nodeType()
const override {
return NodeGroup; }
219 QString id()
const {
return mId; }
224 QString name()
const {
return mName; }
238 class GUI_EXPORT QgsProcessingToolboxModelAlgorithmNode :
public QgsProcessingToolboxModelNode
250 NodeType nodeType()
const override {
return NodeAlgorithm; }
283 RoleNodeType = Qt::UserRole,
303 QgsProcessingRecentAlgorithmLog *recentLog =
nullptr );
305 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
306 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
307 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
308 int columnCount(
const QModelIndex & = QModelIndex() )
const override;
309 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
310 QModelIndex parent(
const QModelIndex &index )
const override;
311 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
317 QgsProcessingToolboxModelNode *index2node(
const QModelIndex &index )
const;
323 QModelIndex node2index( QgsProcessingToolboxModelNode *node )
const;
341 QString providerIdForIndex(
const QModelIndex &index )
const;
357 bool isAlgorithm(
const QModelIndex &index )
const;
363 QModelIndex indexForProvider(
const QString &providerId )
const;
368 QModelIndex indexOfParentTreeNode( QgsProcessingToolboxModelNode *parentNode )
const;
375 void recentAlgorithmAdded();
380 void repopulateRecentAlgorithms(
bool resetting =
false );
381 void providerAdded(
const QString &
id );
382 void providerRemoved(
const QString &
id );
386 QPointer< QgsProcessingRegistry > mRegistry;
387 QPointer< QgsProcessingRecentAlgorithmLog > mRecentLog;
389 std::unique_ptr< QgsProcessingToolboxModelGroupNode > mRootNode;
390 QgsProcessingToolboxModelRecentNode *mRecentNode =
nullptr;
398 static bool isTopLevelProvider(
const QString &providerId );
425 FilterToolbox = 1 << 1,
426 FilterModeler = 1 << 2,
427 FilterInPlace = 1 << 3,
428 FilterShowKnownIssues = 1 << 4,
430 Q_DECLARE_FLAGS( Filters,
Filter )
446 QgsProcessingRecentAlgorithmLog *recentLog =
nullptr );
457 void setFilters( QgsProcessingToolboxProxyModel::Filters filters );
479 void setFilterString(
const QString &filter );
488 bool filterAcceptsRow(
int sourceRow,
const QModelIndex &sourceParent )
const override;
489 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
494 Filters mFilters =
nullptr;
495 QString mFilterString;
496 QPointer<QgsVectorLayer> mInPlaceLayer;
500 #endif // QGSPROCESSINGTOOLBOXMODEL_H
Abstract base class for processing providers.
Abstract base class for processing algorithms.
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
Registry for various processing components, including providers, algorithms and various parameters an...
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Represents a vector layer which manages a vector based data sets.