QGIS API Documentation 4.3.0-Master (6313fb5bce0)
Loading...
Searching...
No Matches
qgsprocessingprovideractions.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingprovideractions.cpp
3 ----------------------------------
4 Date : September 2026
5 Copyright : (C) 2026 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include "qgsapplication.h"
19#include "qgsdockwidget.h"
20
21#include <QIcon>
22
23//
24// QgsProcessingActionContext
25//
26
28{
29 return mParentWidget;
30}
31
32void QgsProcessingActionContext::setParentWidget( QWidget *newParentWidget )
33{
34 mParentWidget = newParentWidget;
35}
36
38{
39 return mAlgorithmName;
40}
41
43{
44 mAlgorithmName = name;
45}
46
48{
49 return mProviderId;
50}
51
53{
54 mProviderId = id;
55}
56
57//
58// QgsProcessingToolboxAction
59//
60
61QgsProcessingToolboxAction::QgsProcessingToolboxAction( const QString &name, const QString &group )
62 : mName( name )
63 , mGroup( group )
64{}
65
67
69{
70 // either this or getIcon() may be called, so transparently fall back
71 // to the other method which may be implemented, but avoid endless loops
72 if ( mUseDeprecatedLoopBreak )
73 return QgsApplication::getThemeIcon( "/processingAlgorithm.svg" );
74
75 mUseDeprecatedLoopBreak = true;
77 const QIcon res = getIcon();
78 mUseDeprecatedLoopBreak = false;
80 return res;
81}
82
84{
85 // either this or getIcon() may be called, so transparently fall back
86 // to the other method which may be implemented, but avoid endless loops
87 if ( mUseDeprecatedLoopBreak )
88 return QgsApplication::getThemeIcon( "/processingAlgorithm.svg" );
89
90 mUseDeprecatedLoopBreak = true;
91 const QIcon res = icon();
92 mUseDeprecatedLoopBreak = false;
93 return res;
94}
95
97{
98 mToolboxDockWidget = widget;
99}
100
102{
103 if ( mUseDeprecatedLoopBreak )
104 return;
105
106 mUseDeprecatedLoopBreak = true;
108 execute();
110 mUseDeprecatedLoopBreak = false;
111}
112
114{
115 if ( mUseDeprecatedLoopBreak )
116 return;
117
118 mUseDeprecatedLoopBreak = true;
120 mUseDeprecatedLoopBreak = false;
121}
122
124{
125 return mToolboxDockWidget;
126}
127
128//
129// QgsProcessingToolboxContextAction
130//
131
133 : mName( name )
134{}
135
137
139{
140 return QIcon();
141}
142
144{
145 return true;
146}
147
154
156{
157 return mToolboxDockWidget;
158}
159
161{
162 mToolboxDockWidget = toolbox;
163}
164
169
171{
172 mAlgorithm = data;
173}
174
176{
177 mAlgorithm = data;
178 mToolboxDockWidget = toolbox;
179}
180
182{
183 if ( mUseDeprecatedLoopBreak )
184 return;
185
186 mUseDeprecatedLoopBreak = true;
188 mUseDeprecatedLoopBreak = false;
189}
190
192{
193 if ( mUseDeprecatedLoopBreak )
194 return;
195
196 mUseDeprecatedLoopBreak = true;
198 execute();
200 mUseDeprecatedLoopBreak = false;
201}
202
204{
205 return mIsSeparator;
206}
207
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
A QDockWidget subclass with more fine-grained control over how the widget is closed or opened.
Encapsulates the context in which a Processing action is executed.
void setAlgorithmName(const QString &name)
Sets the name of the algorithm associated with the action.
void setParentWidget(QWidget *widget)
Sets the parent widget to use for dialogs constructed when triggering the action.
QWidget * parentWidget() const
Returns the parent widget to use for dialogs constructed when triggering the action.
QString providerId() const
Returns the ID of the provider associated with the action.
void setProviderId(const QString &id)
Sets the ID of the provider associated with the action.
QString algorithmName() const
Returns the name of the algorithm associated with the action.
Abstract base class for processing algorithms.
virtual void trigger(const QgsProcessingActionContext &context)
Triggers the action.
virtual ~QgsProcessingToolboxAction()
virtual Q_DECL_DEPRECATED QIcon getIcon() const
Returns the icon to use for the action.
QgsProcessingToolboxAction(const QString &name=QString(), const QString &group=QString())
Constructor for QgsProcessingToolboxAction.
Q_DECL_DEPRECATED void setData(QgsDockWidget *widget)
Sets the parent toolbox widget the action will be shown in.
Q_DECL_DEPRECATED QgsDockWidget * data() const
Returns the parent toolbox widget the action will be shown in.
virtual QIcon icon() const
Returns the icon to use for the action.
virtual Q_DECL_DEPRECATED void execute()
Executes the action.
Q_DECL_DEPRECATED QgsProcessingAlgorithm * getItemData()
Returns the associated algorithm the action will be shown for.
Q_DECL_DEPRECATED void setData(QgsProcessingAlgorithm *data, QgsDockWidget *toolbox)
Sets the associated algorithm and toolbox the action will be shown for.
virtual QIcon icon() const
Returns the icon to use for the action.
Q_DECL_DEPRECATED void setItemData(QgsProcessingAlgorithm *data)
Sets the associated algorithm the action will be shown for.
virtual Q_DECL_DEPRECATED bool isEnabled() const
Returns true if the action is enabled.
virtual bool isCompatibleWithAlgorithm(const QString &providerId, const QString &algorithmName)
Returns true if the action is compatible with the specified provider and algorithm.
Q_DECL_DEPRECATED QgsDockWidget * getToolbox()
Returns the parent toolbox the action will be shown in.
bool isSeparator() const
Returns true if the action is a separator action.
void setIsSeparator(bool isSeparator)
Sets whether the action is a separator action.
QgsProcessingToolboxContextAction(const QString &name=QString())
Constructor for QgsProcessingToolboxContextAction.
Q_DECL_DEPRECATED void setToolbox(QgsDockWidget *toolbox)
Sets the parent toolbox the action will be shown in.
virtual void trigger(const QgsProcessingActionContext &context)
Triggers the action.
virtual Q_DECL_DEPRECATED void execute()
Executes the action.
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:8260
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:8259