QGIS API Documentation 4.3.0-Master (0cfde48c85b)
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
92#ifndef SIP_RUN
98 void setModelScene( QgsModelGraphicsScene *scene SIP_TRANSFER );
99
106 QgsModelGraphicsScene *modelScene();
107#endif
108
109 QgsProcessingFeedback *createFeedback() override SIP_FACTORY;
110 QgsProcessingParameterWidgetContext createWidgetContext() override;
111
112 public slots:
113
119 void activate();
120
126 void saveInProject();
127
128 signals:
129
135 void modelUpdated();
136
137 protected:
138 QgsProcessingContext *processingContext() const override;
139
140 private slots:
141 void zoomIn();
142 void zoomOut();
143 void zoomActual();
144 void zoomFull();
145 void newModel();
146 void openModel();
147 void exportToImage();
148 void exportToPdf();
149 void exportToSvg();
150 void exportAsPython();
151 void toggleComments( bool show );
152 void toggleFeatureCount( bool show );
153 void updateWindowTitle();
154 void deleteSelected();
155 void populateZoomToMenu();
156 void validate();
157 void reorderInputs();
158 void reorderOutputs();
159 void setPanelVisibility( bool hidden );
160 void editHelp();
161 void runSelectedSteps();
162 void runFromChild( const QString &id );
163 void run( const QSet<QString> &childAlgorithmSubset = QSet<QString>() );
164 void showChildAlgorithmOutputs( const QString &childId );
165 void showChildAlgorithmLog( const QString &childId );
166 void onItemFocused( QgsModelComponentGraphicItem *item );
167
168 void cancelRunningModel();
169
170 private:
176 enum class SaveAction
177 {
178 SaveAsFile,
179 SaveInProject,
180 };
181
185 void beginUndoCommand( const QString &text, const QString &id = QString(), QgsModelUndoCommand::CommandOperation operation = QgsModelUndoCommand::CommandOperation::Unknown );
186
190 void endUndoCommand();
191
196 void abortUndoCommand();
197
198 void repaintModel( bool showControls = true );
199
200 void setDirty( bool dirty );
201
205 bool validateSave( SaveAction action );
206
212 bool checkForUnsavedChanges();
213
217 void setLastRunResult( const QgsProcessingModelResult &result );
218
226 void setModelName( const QString &name );
227
228 bool saveModel( bool saveAs = false );
229
230 QPointF getPositionForParameterItem() const;
231 QPointF getPositionForAlgorithmItem() const;
232
237 void autoGenerateParameterName( QgsProcessingParameterDefinition *parameter ) const;
238
239 void addAlgorithm( const QString &algorithmId, const QPointF &pos );
240 void addInput( const QString &parameterType, const QPointF &pos );
241
242 QgsProcessingAlgorithmWidget *createExecutionWidget();
243
244 void exportAsScriptAlgorithm();
245
246 std::unique_ptr< QgsProcessingContext > mContext;
247
248 std::unique_ptr<QgsProcessingModelAlgorithm> mModel;
249
250 QgsScreenHelper *mScreenHelper = nullptr;
251
252 QgsMessageBar *mMessageBar = nullptr;
253 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
254
255 QPointer<QgsProcessingAlgorithmWidget> mAlgorithmWidget;
256
257 QVector<QPointer<QgsProcessingAlgorithmWidget>> mAlgorithmWidgetsToCleanUp;
258
259 QActionGroup *mToolsActionGroup = nullptr;
260
261 QgsModelViewToolPan *mPanTool = nullptr;
262 QObjectUniquePtr<QgsModelViewToolSelect> mSelectTool;
263 QgsModelGraphicsScene *mScene = nullptr;
264
265 bool mHasChanged = false;
266 QUndoStack *mUndoStack = nullptr;
267 std::unique_ptr<QgsModelUndoCommand> mActiveCommand;
268
269 QAction *mUndoAction = nullptr;
270 QAction *mRedoAction = nullptr;
271 QUndoView *mUndoView = nullptr;
272 QgsDockWidget *mUndoDock = nullptr;
273
274 QMenu *mGroupMenu = nullptr;
275
276 QAction *mActionCut = nullptr;
277 QAction *mActionCopy = nullptr;
278 QAction *mActionPaste = nullptr;
279 int mBlockUndoCommands = 0;
280 int mIgnoreUndoStackChanges = 0;
281
282 QgsDockWidget *mConfigWidgetDock = nullptr;
283 QgsModelDesignerConfigDockWidget *mConfigWidget = nullptr;
284
285 QString mTitle;
286
287 int mBlockRepaints = 0;
288
289 QgsProcessingModelResult mLastResult;
290 QSet< QString > mOutdatedChildResults;
291
292 bool isDirty() const;
293
294 void fillInputsTree();
295 void updateVariablesGui();
296
297 struct PanelStatus
298 {
299 PanelStatus( bool visible = true, bool active = false )
300 : isVisible( visible )
301 , isActive( active )
302 {}
303 bool isVisible;
304 bool isActive;
305 };
306 QMap<QString, PanelStatus> mPanelStatus;
307
308 QgsProcessingContext mLayerStore;
309};
310
311#ifndef SIP_RUN
312
313class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
314{
315 Q_OBJECT
316
317 public:
318 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model, const QString &childId );
319 QList<QgsProcessingModelChildDependency> value() const { return mValue; }
320 void setValue( const QList<QgsProcessingModelChildDependency> &value );
321
322 signals:
323
329 void changed();
330
331 private slots:
332
333 void showDialog();
334
335 private:
336 void updateSummaryText();
337
338 QLineEdit *mLineEdit = nullptr;
339 QToolButton *mToolButton = nullptr;
340
341 QgsProcessingModelAlgorithm *mModel = nullptr;
342 QString mChildId;
343
344 QList<QgsProcessingModelChildDependency> mValue;
345
346 friend class TestProcessingGui;
347};
348#endif
350
351#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_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83