QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "ui_qgsmodeldesignerdialogbase.h"
20
21#include "qgis.h"
22#include "qgis_gui.h"
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
79 void abortUndoCommand();
80
84 QgsProcessingModelAlgorithm *model();
85
91 void setModel( QgsProcessingModelAlgorithm *model SIP_TRANSFER );
92
96 void loadModel( const QString &path );
97
101 void setModelScene( QgsModelGraphicsScene *scene SIP_TRANSFER );
102
108 enum class SaveAction
109 {
110 SaveAsFile,
111 SaveInProject,
112 };
113
114 public slots:
115
121 void activate();
122
123 protected:
124 // cppcheck-suppress pureVirtualCall
125 virtual void repaintModel( bool showControls = true ) = 0;
126 virtual void addAlgorithm( const QString &algorithmId, const QPointF &pos ) = 0;
127 // cppcheck-suppress pureVirtualCall
128 virtual void addInput( const QString &inputId, const QPointF &pos ) = 0;
129 // cppcheck-suppress pureVirtualCall
130 virtual void exportAsScriptAlgorithm() = 0;
131 // cppcheck-suppress pureVirtualCall
132 virtual bool saveModel( bool saveAs = false ) = 0;
133 // cppcheck-suppress pureVirtualCall
134 virtual QgsProcessingAlgorithmDialogBase *createExecutionDialog() = 0 SIP_TRANSFERBACK;
135
136 QToolBar *toolbar() { return mToolbar; }
137 QAction *actionOpen() { return mActionOpen; }
138 QAction *actionSaveInProject() { return mActionSaveInProject; }
139 QAction *actionRun() { return mActionRun; }
140 QgsMessageBar *messageBar() { return mMessageBar; }
141 QGraphicsView *view() { return mView; }
142
143 void setDirty( bool dirty );
144
148 bool validateSave( SaveAction action );
149
155 bool checkForUnsavedChanges();
156
160 void setLastRunResult( const QgsProcessingModelResult &result );
161
169 void setModelName( const QString &name );
170
171 private slots:
172 void zoomIn();
173 void zoomOut();
174 void zoomActual();
175 void zoomFull();
176 void newModel();
177 void exportToImage();
178 void exportToPdf();
179 void exportToSvg();
180 void exportAsPython();
181 void toggleComments( bool show );
182 void updateWindowTitle();
183 void deleteSelected();
184 void populateZoomToMenu();
185 void validate();
186 void reorderInputs();
187 void reorderOutputs();
188 void setPanelVisibility( bool hidden );
189 void editHelp();
190 void runSelectedSteps();
191 void runFromChild( const QString &id );
192 void run( const QSet<QString> &childAlgorithmSubset = QSet<QString>() );
193 void showChildAlgorithmOutputs( const QString &childId );
194 void showChildAlgorithmLog( const QString &childId );
195
196 private:
197 enum UndoCommand
198 {
199 NameChanged = 1,
200 GroupChanged
201 };
202
203 std::unique_ptr<QgsProcessingModelAlgorithm> mModel;
204
205 QgsScreenHelper *mScreenHelper = nullptr;
206
207 QgsMessageBar *mMessageBar = nullptr;
208 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
209
210 QActionGroup *mToolsActionGroup = nullptr;
211
212 QgsModelViewToolPan *mPanTool = nullptr;
213 QgsModelViewToolSelect *mSelectTool = nullptr;
214 QgsModelGraphicsScene *mScene = nullptr;
215
216 bool mHasChanged = false;
217 QUndoStack *mUndoStack = nullptr;
218 std::unique_ptr<QgsModelUndoCommand> mActiveCommand;
219
220 QAction *mUndoAction = nullptr;
221 QAction *mRedoAction = nullptr;
222 QUndoView *mUndoView = nullptr;
223 QgsDockWidget *mUndoDock = nullptr;
224
225 QMenu *mGroupMenu = nullptr;
226
227 QAction *mActionCut = nullptr;
228 QAction *mActionCopy = nullptr;
229 QAction *mActionPaste = nullptr;
230 int mBlockUndoCommands = 0;
231 int mIgnoreUndoStackChanges = 0;
232
233 QString mTitle;
234
235 int mBlockRepaints = 0;
236
237 QgsProcessingModelResult mLastResult;
238
239 bool isDirty() const;
240
241 void fillInputsTree();
242 void updateVariablesGui();
243
244 struct PanelStatus
245 {
246 PanelStatus( bool visible = true, bool active = false )
247 : isVisible( visible )
248 , isActive( active )
249 {}
250 bool isVisible;
251 bool isActive;
252 };
253 QMap<QString, PanelStatus> mPanelStatus;
254
255 QgsProcessingContext mLayerStore;
256};
257
258
259class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
260{
261 Q_OBJECT
262
263 public:
264 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model, const QString &childId );
265 QList<QgsProcessingModelChildDependency> value() const { return mValue; }
266 void setValue( const QList<QgsProcessingModelChildDependency> &value );
267 private slots:
268
269 void showDialog();
270
271 private:
272 void updateSummaryText();
273
274 QLineEdit *mLineEdit = nullptr;
275 QToolButton *mToolButton = nullptr;
276
277 QgsProcessingModelAlgorithm *mModel = nullptr;
278 QString mChildId;
279
280 QList<QgsProcessingModelChildDependency> mValue;
281
282 friend class TestProcessingGui;
283};
285
286#endif // QGSMODELDESIGNERDIALOG_H
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.
A 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