QGIS API Documentation 3.99.0-Master (357b655ed83)
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 toggleFeatureCount( bool show );
183 void updateWindowTitle();
184 void deleteSelected();
185 void populateZoomToMenu();
186 void validate();
187 void reorderInputs();
188 void reorderOutputs();
189 void setPanelVisibility( bool hidden );
190 void editHelp();
191 void runSelectedSteps();
192 void runFromChild( const QString &id );
193 void run( const QSet<QString> &childAlgorithmSubset = QSet<QString>() );
194 void showChildAlgorithmOutputs( const QString &childId );
195 void showChildAlgorithmLog( const QString &childId );
196
197 private:
198 enum UndoCommand
199 {
200 NameChanged = 1,
201 GroupChanged
202 };
203
204 std::unique_ptr<QgsProcessingModelAlgorithm> mModel;
205
206 QgsScreenHelper *mScreenHelper = nullptr;
207
208 QgsMessageBar *mMessageBar = nullptr;
209 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
210
211 QActionGroup *mToolsActionGroup = nullptr;
212
213 QgsModelViewToolPan *mPanTool = nullptr;
214 QgsModelViewToolSelect *mSelectTool = nullptr;
215 QgsModelGraphicsScene *mScene = nullptr;
216
217 bool mHasChanged = false;
218 QUndoStack *mUndoStack = nullptr;
219 std::unique_ptr<QgsModelUndoCommand> mActiveCommand;
220
221 QAction *mUndoAction = nullptr;
222 QAction *mRedoAction = nullptr;
223 QUndoView *mUndoView = nullptr;
224 QgsDockWidget *mUndoDock = nullptr;
225
226 QMenu *mGroupMenu = nullptr;
227
228 QAction *mActionCut = nullptr;
229 QAction *mActionCopy = nullptr;
230 QAction *mActionPaste = nullptr;
231 int mBlockUndoCommands = 0;
232 int mIgnoreUndoStackChanges = 0;
233
234 QString mTitle;
235
236 int mBlockRepaints = 0;
237
238 QgsProcessingModelResult mLastResult;
239
240 bool isDirty() const;
241
242 void fillInputsTree();
243 void updateVariablesGui();
244
245 struct PanelStatus
246 {
247 PanelStatus( bool visible = true, bool active = false )
248 : isVisible( visible )
249 , isActive( active )
250 {}
251 bool isVisible;
252 bool isActive;
253 };
254 QMap<QString, PanelStatus> mPanelStatus;
255
256 QgsProcessingContext mLayerStore;
257};
258
259
260class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
261{
262 Q_OBJECT
263
264 public:
265 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model, const QString &childId );
266 QList<QgsProcessingModelChildDependency> value() const { return mValue; }
267 void setValue( const QList<QgsProcessingModelChildDependency> &value );
268 private slots:
269
270 void showDialog();
271
272 private:
273 void updateSummaryText();
274
275 QLineEdit *mLineEdit = nullptr;
276 QToolButton *mToolButton = nullptr;
277
278 QgsProcessingModelAlgorithm *mModel = nullptr;
279 QString mChildId;
280
281 QList<QgsProcessingModelChildDependency> mValue;
282
283 friend class TestProcessingGui;
284};
286
287#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