Skip to content

Commit f6075ca

Browse files
committed
[processing] New class QgsProcessingToolboxModel which is
a QAbstractItemModel which represents the providers, groups and algorithms from the processing registry
1 parent 4c3aeb8 commit f6075ca

File tree

8 files changed

+1677
-0
lines changed

8 files changed

+1677
-0
lines changed
Lines changed: 319 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/gui/processing/qgsprocessingtoolboxmodel.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
13+
class QgsProcessingToolboxModelNode : QObject
14+
{
15+
%Docstring
16+
Abstract base class for nodes contained within a QgsProcessingToolboxModel.
17+
18+
.. warning::
19+
20+
Not part of stable API and may change in future QGIS releases.
21+
22+
.. versionadded:: 3.2
23+
%End
24+
25+
%TypeHeaderCode
26+
#include "qgsprocessingtoolboxmodel.h"
27+
%End
28+
%ConvertToSubClassCode
29+
if ( sipCpp->inherits( "QgsProcessingToolboxModelNode" ) )
30+
{
31+
sipType = sipType_QgsProcessingToolboxModelNode;
32+
QgsProcessingToolboxModelNode *node = qobject_cast<QgsProcessingToolboxModelNode *>( sipCpp );
33+
if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeProvider )
34+
sipType = sipType_QgsProcessingToolboxModelProviderNode;
35+
else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeGroup )
36+
sipType = sipType_QgsProcessingToolboxModelGroupNode;
37+
else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeAlgorithm )
38+
sipType = sipType_QgsProcessingToolboxModelAlgorithmNode;
39+
}
40+
else
41+
sipType = 0;
42+
%End
43+
public:
44+
45+
enum NodeType
46+
{
47+
NodeProvider,
48+
NodeGroup,
49+
NodeAlgorithm,
50+
};
51+
52+
~QgsProcessingToolboxModelNode();
53+
54+
virtual NodeType nodeType() const = 0;
55+
%Docstring
56+
Returns the node's type.
57+
%End
58+
59+
QgsProcessingToolboxModelNode *parent();
60+
%Docstring
61+
Returns the node's parent. If the node's parent is a null pointer, then the node is a root node.
62+
%End
63+
64+
QList<QgsProcessingToolboxModelNode *> children();
65+
%Docstring
66+
Returns a list of children belonging to the node.
67+
%End
68+
69+
70+
QgsProcessingToolboxModelGroupNode *getChildGroupNode( const QString &id );
71+
%Docstring
72+
Tries to find a child node belonging to this node, which corresponds to
73+
a group node with the given group ``id``. Returns None if no matching
74+
child group node was found.
75+
%End
76+
77+
void addChildNode( QgsProcessingToolboxModelNode *node /Transfer/ );
78+
%Docstring
79+
Adds a child ``node`` to this node, transferring ownership of the node
80+
to this node.
81+
%End
82+
83+
void deleteChildren();
84+
%Docstring
85+
Deletes all child nodes from this node.
86+
%End
87+
88+
};
89+
90+
class QgsProcessingToolboxModelProviderNode : QgsProcessingToolboxModelNode
91+
{
92+
%Docstring
93+
Processing toolbox model node corresponding to a Processing provider.
94+
95+
.. versionadded:: 3.2
96+
97+
.. warning::
98+
99+
Not part of stable API and may change in future QGIS releases.
100+
%End
101+
102+
%TypeHeaderCode
103+
#include "qgsprocessingtoolboxmodel.h"
104+
%End
105+
public:
106+
107+
QgsProcessingToolboxModelProviderNode( QgsProcessingProvider *provider );
108+
%Docstring
109+
Constructor for QgsProcessingToolboxModelProviderNode, linked to the
110+
specified ``provider``.
111+
%End
112+
113+
virtual NodeType nodeType() const;
114+
115+
QgsProcessingProvider *provider();
116+
%Docstring
117+
Returns the provider associated with this node.
118+
%End
119+
120+
};
121+
122+
class QgsProcessingToolboxModelGroupNode : QgsProcessingToolboxModelNode
123+
{
124+
%Docstring
125+
Processing toolbox model node corresponding to a group of algorithms.
126+
127+
.. versionadded:: 3.2
128+
129+
.. warning::
130+
131+
Not part of stable API and may change in future QGIS releases.
132+
%End
133+
134+
%TypeHeaderCode
135+
#include "qgsprocessingtoolboxmodel.h"
136+
%End
137+
public:
138+
139+
QgsProcessingToolboxModelGroupNode( const QString &id, const QString &name );
140+
%Docstring
141+
Constructor for QgsProcessingToolboxModelGroupNode.
142+
143+
The ``id`` argument specifies the group ID (unique and untranslated),
144+
and the ``name`` argument gives the translated, user-visible name
145+
of the group.
146+
%End
147+
148+
virtual NodeType nodeType() const;
149+
150+
QString id() const;
151+
%Docstring
152+
Returns the group's ID, which is unique and untranslated.
153+
%End
154+
155+
QString name() const;
156+
%Docstring
157+
Returns the group's name, which is translated and user-visible.
158+
%End
159+
160+
};
161+
162+
class QgsProcessingToolboxModelAlgorithmNode : QgsProcessingToolboxModelNode
163+
{
164+
%Docstring
165+
Processing toolbox model node corresponding to an algorithm.
166+
167+
.. versionadded:: 3.2
168+
169+
.. warning::
170+
171+
Not part of stable API and may change in future QGIS releases.
172+
%End
173+
174+
%TypeHeaderCode
175+
#include "qgsprocessingtoolboxmodel.h"
176+
%End
177+
public:
178+
179+
QgsProcessingToolboxModelAlgorithmNode( const QgsProcessingAlgorithm *algorithm );
180+
%Docstring
181+
Constructor for QgsProcessingToolboxModelAlgorithmNode, associated
182+
with the specified ``algorithm``.
183+
%End
184+
185+
virtual NodeType nodeType() const;
186+
187+
const QgsProcessingAlgorithm *algorithm() const;
188+
%Docstring
189+
Returns the algorithm associated with this node.
190+
%End
191+
192+
};
193+
194+
195+
class QgsProcessingToolboxModel : QAbstractItemModel
196+
{
197+
%Docstring
198+
A model for providers and algorithms shown within the Processing toolbox.
199+
200+
.. versionadded:: 3.2
201+
%End
202+
203+
%TypeHeaderCode
204+
#include "qgsprocessingtoolboxmodel.h"
205+
%End
206+
public:
207+
208+
enum Roles
209+
{
210+
RoleNodeType,
211+
RoleAlgorithmFlags,
212+
};
213+
214+
QgsProcessingToolboxModel( QObject *parent /TransferThis/ = 0, QgsProcessingRegistry *registry = 0 );
215+
%Docstring
216+
Constructor for QgsProcessingToolboxModel, with the given ``parent`` object.
217+
218+
If ``registry`` is specified then the model will show providers and algorithms
219+
from the given registry. If no registry is specified, then the processing
220+
registry attached to QgsApplication.processingRegistry() will be used
221+
by the model.
222+
%End
223+
224+
virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
225+
226+
virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
227+
228+
virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
229+
230+
virtual int columnCount( const QModelIndex & = QModelIndex() ) const;
231+
232+
virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
233+
234+
virtual QModelIndex parent( const QModelIndex &index ) const;
235+
236+
237+
QgsProcessingToolboxModelNode *index2node( const QModelIndex &index ) const;
238+
%Docstring
239+
Returns the model node corresponding to the given ``index``.
240+
241+
.. seealso:: :py:func:`node2index`
242+
%End
243+
244+
QModelIndex node2index( QgsProcessingToolboxModelNode *node ) const;
245+
%Docstring
246+
Returns the model index corresponding to the given ``node``.
247+
248+
.. seealso:: :py:func:`index2node`
249+
%End
250+
251+
QgsProcessingProvider *providerForIndex( const QModelIndex &index ) const;
252+
%Docstring
253+
Returns the provider which corresponds to a given ``index``, or
254+
a None if the index does not represent a provider.
255+
256+
.. seealso:: :py:func:`algorithmForIndex`
257+
258+
.. seealso:: :py:func:`indexForProvider`
259+
%End
260+
261+
const QgsProcessingAlgorithm *algorithmForIndex( const QModelIndex &index ) const;
262+
%Docstring
263+
Returns the algorithm which corresponds to a given ``index``, or
264+
a None if the index does not represent an algorithm.
265+
266+
.. seealso:: :py:func:`providerForIndex`
267+
%End
268+
269+
QModelIndex indexForProvider( QgsProcessingProvider *provider ) const;
270+
%Docstring
271+
Returns the index corresponding to the specified ``provider``.
272+
273+
.. seealso:: :py:func:`providerForIndex`
274+
%End
275+
276+
QModelIndex indexOfParentTreeNode( QgsProcessingToolboxModelNode *parentNode ) const;
277+
%Docstring
278+
Returns the index corresponding to the parent of a given node.
279+
%End
280+
281+
};
282+
283+
284+
class QgsProcessingToolboxProxyModel: QSortFilterProxyModel
285+
{
286+
%Docstring
287+
A sort/filter proxy model for providers and algorithms shown within the Processing toolbox.
288+
289+
.. versionadded:: 3.2
290+
%End
291+
292+
%TypeHeaderCode
293+
#include "qgsprocessingtoolboxmodel.h"
294+
%End
295+
public:
296+
297+
explicit QgsProcessingToolboxProxyModel( QObject *parent /TransferThis/ = 0, QgsProcessingRegistry *registry = 0 );
298+
%Docstring
299+
Constructor for QgsProcessingToolboxProxyModel, with the given ``parent`` object.
300+
301+
If ``registry`` is specified then the model will show providers and algorithms
302+
from the given registry. If no registry is specified, then the processing
303+
registry attached to QgsApplication.processingRegistry() will be used
304+
by the model.
305+
%End
306+
307+
virtual bool lessThan( const QModelIndex &left, const QModelIndex &right ) const;
308+
309+
310+
};
311+
312+
313+
/************************************************************************
314+
* This file has been generated automatically from *
315+
* *
316+
* src/gui/processing/qgsprocessingtoolboxmodel.h *
317+
* *
318+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
319+
************************************************************************/

python/gui/gui_auto.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,5 @@
316316
%Include auto_generated/processing/qgsprocessingalgorithmconfigurationwidget.sip
317317
%Include auto_generated/processing/qgsprocessingalgorithmdialogbase.sip
318318
%Include auto_generated/processing/qgsprocessingrecentalgorithmlog.sip
319+
%Include auto_generated/processing/qgsprocessingtoolboxmodel.sip
319320
%Include auto_generated/qgsadvanceddigitizingcanvasitem.sip

0 commit comments

Comments
 (0)