QGIS API Documentation 4.3.0-Master (0cef2469b72)
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 aboutToClose();
143
149 void modelUpdated();
150
151 protected:
152 QgsProcessingContext *processingContext() const override;
153
154 private slots:
155 void zoomIn();
156 void zoomOut();
157 void zoomActual();
158 void zoomFull();
159 void newModel();
160 void openModel();
161 void exportToImage();
162 void exportToPdf();
163 void exportToSvg();
164 void exportAsPython();
165 void toggleComments( bool show );
166 void toggleFeatureCount( bool show );
167 void updateWindowTitle();
168 void deleteSelected();
169 void populateZoomToMenu();
170 void validate();
171 void reorderInputs();
172 void reorderOutputs();
173 void setPanelVisibility( bool hidden );
174 void editHelp();
175 void runSelectedSteps();
176 void runFromChild( const QString &id );
177 void run( const QSet<QString> &childAlgorithmSubset = QSet<QString>() );
178 void showChildAlgorithmOutputs( const QString &childId );
179 void showChildAlgorithmLog( const QString &childId );
180 void onItemFocused( QgsModelComponentGraphicItem *item );
181
182 void cancelRunningModel();
183
184 private:
190 enum class SaveAction
191 {
192 SaveAsFile,
193 SaveInProject,
194 };
195
199 void beginUndoCommand( const QString &text, const QString &id = QString(), QgsModelUndoCommand::CommandOperation operation = QgsModelUndoCommand::CommandOperation::Unknown );
200
204 void endUndoCommand();
205
210 void abortUndoCommand();
211
212 void repaintModel( bool showControls = true );
213
214 void setDirty( bool dirty );
215
219 bool validateSave( SaveAction action );
220
226 bool checkForUnsavedChanges();
227
231 void setLastRunResult( const QgsProcessingModelResult &result );
232
240 void setModelName( const QString &name );
241
242 bool saveModel( bool saveAs = false );
243
244 QPointF getPositionForParameterItem() const;
245 QPointF getPositionForAlgorithmItem() const;
246
251 void autoGenerateParameterName( QgsProcessingParameterDefinition *parameter ) const;
252
253 void addAlgorithm( const QString &algorithmId, const QPointF &pos );
254 void addInput( const QString &parameterType, const QPointF &pos );
255
256 QgsProcessingAlgorithmWidget *createExecutionWidget();
257
258 void exportAsScriptAlgorithm();
259
260 std::unique_ptr< QgsProcessingContext > mContext;
261
262 std::unique_ptr<QgsProcessingModelAlgorithm> mModel;
263
264 QgsScreenHelper *mScreenHelper = nullptr;
265
266 QgsMessageBar *mMessageBar = nullptr;
267 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
268
269 QPointer<QgsProcessingAlgorithmWidget> mAlgorithmWidget;
270
271 QVector<QPointer<QgsProcessingAlgorithmWidget>> mAlgorithmWidgetsToCleanUp;
272
273 QActionGroup *mToolsActionGroup = nullptr;
274
275 QgsModelViewToolPan *mPanTool = nullptr;
276 QObjectUniquePtr<QgsModelViewToolSelect> mSelectTool;
277 QgsModelGraphicsScene *mScene = nullptr;
278
279 bool mHasChanged = false;
280 QUndoStack *mUndoStack = nullptr;
281 std::unique_ptr<QgsModelUndoCommand> mActiveCommand;
282
283 QAction *mUndoAction = nullptr;
284 QAction *mRedoAction = nullptr;
285 QUndoView *mUndoView = nullptr;
286 QgsDockWidget *mUndoDock = nullptr;
287
288 QMenu *mGroupMenu = nullptr;
289
290 QAction *mActionCut = nullptr;
291 QAction *mActionCopy = nullptr;
292 QAction *mActionPaste = nullptr;
293 int mBlockUndoCommands = 0;
294 int mIgnoreUndoStackChanges = 0;
295
296 QgsDockWidget *mConfigWidgetDock = nullptr;
297 QgsModelDesignerConfigDockWidget *mConfigWidget = nullptr;
298
299 QString mTitle;
300
301 int mBlockRepaints = 0;
302
303 QgsProcessingModelResult mLastResult;
304 QSet< QString > mOutdatedChildResults;
305
306 bool isDirty() const;
307
308 void fillInputsTree();
309 void updateVariablesGui();
310
311 struct PanelStatus
312 {
313 PanelStatus( bool visible = true, bool active = false )
314 : isVisible( visible )
315 , isActive( active )
316 {}
317 bool isVisible;
318 bool isActive;
319 };
320 QMap<QString, PanelStatus> mPanelStatus;
321
322 QgsProcessingContext mLayerStore;
323};
324
325#ifndef SIP_RUN
326
327class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
328{
329 Q_OBJECT
330
331 public:
332 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model, const QString &childId );
333 QList<QgsProcessingModelChildDependency> value() const { return mValue; }
334 void setValue( const QList<QgsProcessingModelChildDependency> &value );
335
336 signals:
337
343 void changed();
344
345 private slots:
346
347 void showDialog();
348
349 private:
350 void updateSummaryText();
351
352 QLineEdit *mLineEdit = nullptr;
353 QToolButton *mToolButton = nullptr;
354
355 QgsProcessingModelAlgorithm *mModel = nullptr;
356 QString mChildId;
357
358 QList<QgsProcessingModelChildDependency> mValue;
359
360 friend class TestProcessingGui;
361};
362#endif
364
365#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