QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgsmodeldesignerdialog.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodeldesignerdialog.h
3 ------------------------
4 Date : March 2020
5 Copyright : (C) 2020 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
16#ifndef QGSMODELDESIGNERDIALOG_H
17#define QGSMODELDESIGNERDIALOG_H
18
19#include "qgis.h"
20#include "qgis_gui.h"
21#include "ui_qgsmodeldesignerdialogbase.h"
22
25
26class QgsMessageBar;
27class QgsProcessingModelAlgorithm;
28class QgsModelUndoCommand;
29class QUndoView;
32class QgsScreenHelper;
33class QgsProcessingAlgorithmDialogBase;
34
36
37#ifndef SIP_RUN
38
39class GUI_EXPORT QgsModelerToolboxModel : public QgsProcessingToolboxProxyModel
40{
41 Q_OBJECT
42 public:
43 explicit QgsModelerToolboxModel( QObject *parent = nullptr );
44 Qt::ItemFlags flags( const QModelIndex &index ) const override;
45 Qt::DropActions supportedDragActions() const override;
46};
47
48#endif
49
56class GUI_EXPORT QgsModelDesignerDialog : public QMainWindow, public Ui::QgsModelDesignerDialogBase
57{
58 Q_OBJECT
59 public:
60 QgsModelDesignerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
61 ~QgsModelDesignerDialog() override;
62
63 void closeEvent( QCloseEvent *event ) override;
64
68 void beginUndoCommand( const QString &text, int id = 0 );
69
73 void endUndoCommand();
74
78 QgsProcessingModelAlgorithm *model();
79
85 void setModel( QgsProcessingModelAlgorithm *model SIP_TRANSFER );
86
90 void loadModel( const QString &path );
91
95 void setModelScene( QgsModelGraphicsScene *scene SIP_TRANSFER );
96
102 enum class SaveAction
103 {
104 SaveAsFile,
105 SaveInProject,
106 };
107
108 public slots:
109
115 void activate();
116
117 protected:
118 // cppcheck-suppress pureVirtualCall
119 virtual void repaintModel( bool showControls = true ) = 0;
120 virtual void addAlgorithm( const QString &algorithmId, const QPointF &pos ) = 0;
121 // cppcheck-suppress pureVirtualCall
122 virtual void addInput( const QString &inputId, const QPointF &pos ) = 0;
123 // cppcheck-suppress pureVirtualCall
124 virtual void exportAsScriptAlgorithm() = 0;
125 // cppcheck-suppress pureVirtualCall
126 virtual bool saveModel( bool saveAs = false ) = 0;
127 // cppcheck-suppress pureVirtualCall
128 virtual QgsProcessingAlgorithmDialogBase *createExecutionDialog() = 0 SIP_TRANSFERBACK;
129
130 QToolBar *toolbar() { return mToolbar; }
131 QAction *actionOpen() { return mActionOpen; }
132 QAction *actionSaveInProject() { return mActionSaveInProject; }
133 QAction *actionRun() { return mActionRun; }
134 QgsMessageBar *messageBar() { return mMessageBar; }
135 QGraphicsView *view() { return mView; }
136
137 void setDirty( bool dirty );
138
142 bool validateSave( SaveAction action );
143
149 bool checkForUnsavedChanges();
150
154 void setLastRunResult( const QgsProcessingModelResult &result );
155
163 void setModelName( const QString &name );
164
165 private slots:
166 void zoomIn();
167 void zoomOut();
168 void zoomActual();
169 void zoomFull();
170 void newModel();
171 void exportToImage();
172 void exportToPdf();
173 void exportToSvg();
174 void exportAsPython();
175 void toggleComments( bool show );
176 void updateWindowTitle();
177 void deleteSelected();
178 void populateZoomToMenu();
179 void validate();
180 void reorderInputs();
181 void reorderOutputs();
182 void setPanelVisibility( bool hidden );
183 void editHelp();
184 void runSelectedSteps();
185 void runFromChild( const QString &id );
186 void run( const QSet<QString> &childAlgorithmSubset = QSet<QString>() );
187 void showChildAlgorithmOutputs( const QString &childId );
188 void showChildAlgorithmLog( const QString &childId );
189
190 private:
191 enum UndoCommand
192 {
193 NameChanged = 1,
194 GroupChanged
195 };
196
197 std::unique_ptr<QgsProcessingModelAlgorithm> mModel;
198
199 QgsScreenHelper *mScreenHelper = nullptr;
200
201 QgsMessageBar *mMessageBar = nullptr;
202 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
203
204 QActionGroup *mToolsActionGroup = nullptr;
205
206 QgsModelViewToolPan *mPanTool = nullptr;
207 QgsModelViewToolSelect *mSelectTool = nullptr;
208 QgsModelGraphicsScene *mScene = nullptr;
209
210 bool mHasChanged = false;
211 QUndoStack *mUndoStack = nullptr;
212 std::unique_ptr<QgsModelUndoCommand> mActiveCommand;
213
214 QAction *mUndoAction = nullptr;
215 QAction *mRedoAction = nullptr;
216 QUndoView *mUndoView = nullptr;
217 QgsDockWidget *mUndoDock = nullptr;
218
219 QMenu *mGroupMenu = nullptr;
220
221 QAction *mActionCut = nullptr;
222 QAction *mActionCopy = nullptr;
223 QAction *mActionPaste = nullptr;
224 int mBlockUndoCommands = 0;
225 int mIgnoreUndoStackChanges = 0;
226
227 QString mTitle;
228
229 int mBlockRepaints = 0;
230
231 QgsProcessingModelResult mLastResult;
232
233 bool isDirty() const;
234
235 void fillInputsTree();
236 void updateVariablesGui();
237
238 struct PanelStatus
239 {
240 PanelStatus( bool visible = true, bool active = false )
241 : isVisible( visible )
242 , isActive( active )
243 {}
244 bool isVisible;
245 bool isActive;
246 };
247 QMap<QString, PanelStatus> mPanelStatus;
248
249 QgsProcessingContext mLayerStore;
250};
251
252
253class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
254{
255 Q_OBJECT
256
257 public:
258 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model, const QString &childId );
259 QList<QgsProcessingModelChildDependency> value() const { return mValue; }
260 void setValue( const QList<QgsProcessingModelChildDependency> &value );
261 private slots:
262
263 void showDialog();
264
265 private:
266 void updateSummaryText();
267
268 QLineEdit *mLineEdit = nullptr;
269 QToolButton *mToolButton = nullptr;
270
271 QgsProcessingModelAlgorithm *mModel = nullptr;
272 QString mChildId;
273
274 QList<QgsProcessingModelChildDependency> mValue;
275
276 friend class TestProcessingGui;
277};
279
280#endif // QGSMODELDESIGNERDIALOG_H
QgsDockWidget subclass with more fine-grained control over how the widget is closed or opened.
A bar for displaying non-blocking messages to the user.
Model designer view tool for panning a model.
Model designer view tool for selecting items in the model.
Contains information about the context in which a processing algorithm is executed.
Encapsulates the results of running a Processing model.
A sort/filter proxy model for providers and algorithms shown within the Processing toolbox,...
A utility class for dynamic handling of changes to screen properties.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_TRANSFERBACK
Definition qgis_sip.h:48