QGIS API Documentation 4.3.0-Master (16eddb2670e)
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"
23#include "qgsmodelundocommand.h"
27#include "qobjectuniqueptr.h"
28
29class QgsMessageBar;
30class QgsProcessingModelAlgorithm;
31class QgsModelUndoCommand;
32class QUndoView;
35class QgsScreenHelper;
36class QgsProcessingAlgorithmWidgetBase;
40
42
43#ifndef SIP_RUN
44
45class GUI_EXPORT QgsModelerToolboxModel : public QgsProcessingToolboxProxyModel
46{
47 Q_OBJECT
48 public:
49 explicit QgsModelerToolboxModel( QObject *parent = nullptr );
50 Qt::ItemFlags flags( const QModelIndex &index ) const override;
51 Qt::DropActions supportedDragActions() const override;
52};
53
54#endif
55
62class GUI_EXPORT QgsModelDesignerDialog : public QMainWindow,
63 public QgsProcessingFeedbackGenerator,
66 public Ui::QgsModelDesignerDialogBase
67{
68 Q_OBJECT
69 public:
70 QgsModelDesignerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
71 ~QgsModelDesignerDialog() override;
72
73 void closeEvent( QCloseEvent *event ) override;
74
78 QgsProcessingModelAlgorithm *model();
79
85 void setModel( QgsProcessingModelAlgorithm *model SIP_TRANSFER );
86
90 void loadModel( const QString &path );
91
97 void handleVersionMismatch( const QString &modelVersion ) const SIP_SKIP;
98
99#ifndef SIP_RUN
105 void setModelScene( QgsModelGraphicsScene *scene SIP_TRANSFER );
106
113 QgsModelGraphicsScene *modelScene();
114#endif
115
116 QgsProcessingFeedback *createFeedback() override SIP_FACTORY;
117 QgsProcessingParameterWidgetContext createWidgetContext() override;
118
119 public slots:
120
126 void activate();
127
133 void saveInProject();
134
135 signals:
136
142 void modelUpdated();
143
144 protected:
145 QgsProcessingContext *processingContext() const override;
146
147 private slots:
148 void zoomIn();
149 void zoomOut();
150 void zoomActual();
151 void zoomFull();
152 void newModel();
153 void openModel();
154 void exportToImage();
155 void exportToPdf();
156 void exportToSvg();
157 void exportAsPython();
158 void toggleComments( bool show );
159 void toggleFeatureCount( bool show );
160 void updateWindowTitle();
161 void deleteSelected();
162 void populateZoomToMenu();
163 void validate();
164 void reorderInputs();
165 void reorderOutputs();
166 void setPanelVisibility( bool hidden );
167 void editHelp();
168 void runSelectedSteps();
169 void runFromChild( const QString &id );
170 void run( const QSet<QString> &childAlgorithmSubset = QSet<QString>() );
171 void showChildAlgorithmOutputs( const QString &childId );
172 void showChildAlgorithmLog( const QString &childId );
173 void onItemFocused( QgsModelComponentGraphicItem *item );
174
175 void cancelRunningModel();
176
177 private:
183 enum class SaveAction
184 {
185 SaveAsFile,
186 SaveInProject,
187 };
188
192 void beginUndoCommand( const QString &text, const QString &id = QString(), QgsModelUndoCommand::CommandOperation operation = QgsModelUndoCommand::CommandOperation::Unknown );
193
197 void endUndoCommand();
198
203 void abortUndoCommand();
204
205 void repaintModel( bool showControls = true );
206
207 void setDirty( bool dirty );
208
212 bool validateSave( SaveAction action );
213
219 bool checkForUnsavedChanges();
220
224 void setLastRunResult( const QgsProcessingModelResult &result );
225
233 void setModelName( const QString &name );
234
235 bool saveModel( bool saveAs = false );
236
237 QPointF getPositionForParameterItem() const;
238 QPointF getPositionForAlgorithmItem() const;
239
244 void autoGenerateParameterName( QgsProcessingParameterDefinition *parameter ) const;
245
246 void addAlgorithm( const QString &algorithmId, const QPointF &pos );
247 void addInput( const QString &parameterType, const QPointF &pos );
248
249 QgsProcessingAlgorithmWidget *createExecutionWidget();
250
251 void exportAsScriptAlgorithm();
252
253 std::unique_ptr< QgsProcessingContext > mContext;
254
255 std::unique_ptr<QgsProcessingModelAlgorithm> mModel;
256
257 QgsScreenHelper *mScreenHelper = nullptr;
258
259 QgsMessageBar *mMessageBar = nullptr;
260 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
261
262 QPointer<QgsProcessingAlgorithmWidget> mAlgorithmWidget;
263
264 QVector<QPointer<QgsProcessingAlgorithmWidget>> mAlgorithmWidgetsToCleanUp;
265
266 QActionGroup *mToolsActionGroup = nullptr;
267
268 QgsModelViewToolPan *mPanTool = nullptr;
269 QObjectUniquePtr<QgsModelViewToolSelect> mSelectTool;
270 QgsModelGraphicsScene *mScene = nullptr;
271
272 bool mHasChanged = false;
273 QUndoStack *mUndoStack = nullptr;
274 std::unique_ptr<QgsModelUndoCommand> mActiveCommand;
275
276 QAction *mUndoAction = nullptr;
277 QAction *mRedoAction = nullptr;
278 QUndoView *mUndoView = nullptr;
279 QgsDockWidget *mUndoDock = nullptr;
280
281 QMenu *mGroupMenu = nullptr;
282
283 QAction *mActionCut = nullptr;
284 QAction *mActionCopy = nullptr;
285 QAction *mActionPaste = nullptr;
286 int mBlockUndoCommands = 0;
287 int mIgnoreUndoStackChanges = 0;
288
289 QgsDockWidget *mConfigWidgetDock = nullptr;
290 QgsModelDesignerConfigDockWidget *mConfigWidget = nullptr;
291
292 QString mTitle;
293
294 int mBlockRepaints = 0;
295
296 QgsProcessingModelResult mLastResult;
297 QSet< QString > mOutdatedChildResults;
298
299 bool isDirty() const;
300
301 void fillInputsTree();
302 void updateVariablesGui();
303
304 struct PanelStatus
305 {
306 PanelStatus( bool visible = true, bool active = false )
307 : isVisible( visible )
308 , isActive( active )
309 {}
310 bool isVisible;
311 bool isActive;
312 };
313 QMap<QString, PanelStatus> mPanelStatus;
314
315 QgsProcessingContext mLayerStore;
316};
317
318#ifndef SIP_RUN
319
320class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
321{
322 Q_OBJECT
323
324 public:
325 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model, const QString &childId );
326 QList<QgsProcessingModelChildDependency> value() const { return mValue; }
327 void setValue( const QList<QgsProcessingModelChildDependency> &value );
328
329 signals:
330
336 void changed();
337
338 private slots:
339
340 void showDialog();
341
342 private:
343 void updateSummaryText();
344
345 QLineEdit *mLineEdit = nullptr;
346 QToolButton *mToolButton = nullptr;
347
348 QgsProcessingModelAlgorithm *mModel = nullptr;
349 QString mChildId;
350
351 QList<QgsProcessingModelChildDependency> mValue;
352
353 friend class TestProcessingGui;
354};
355#endif
357
358#endif // QGSMODELDESIGNERDIALOG_H
A bar for displaying non-blocking messages to the user.
A dockable panel widget stack which allows users to specify the properties of a Processing model comp...
Model designer view tool for panning a model.
Model designer view tool for selecting items in the model.
An interface for objects which can create Processing contexts.
Contains settings which reflect the context in which a Processing parameter widget is shown.
A proxy model for providers and algorithms shown within the Processing toolbox.
An interface for objects which can create Processing widget contexts.
A utility class for dynamic handling of changes to screen properties.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_SKIP
Definition qgis_sip.h:138
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83