QGIS API Documentation 3.38.0-Grenoble (exported)
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 "qgis.h"
20#include "qgis_gui.h"
21#include "ui_qgsmodeldesignerdialogbase.h"
22
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
49#endif
50
57class GUI_EXPORT QgsModelDesignerDialog : public QMainWindow, public Ui::QgsModelDesignerDialogBase
58{
59 Q_OBJECT
60 public:
61
62 QgsModelDesignerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
63 ~QgsModelDesignerDialog() override;
64
65 void closeEvent( QCloseEvent *event ) override;
66
70 void beginUndoCommand( const QString &text, int id = 0 );
71
75 void endUndoCommand();
76
80 QgsProcessingModelAlgorithm *model();
81
87 void setModel( QgsProcessingModelAlgorithm *model SIP_TRANSFER );
88
92 void loadModel( const QString &path );
93
97 void setModelScene( QgsModelGraphicsScene *scene SIP_TRANSFER );
98
104 enum class SaveAction
105 {
106 SaveAsFile,
107 SaveInProject,
108 };
109
110 public slots:
111
117 void activate();
118
119 protected:
120
121 // cppcheck-suppress pureVirtualCall
122 virtual void repaintModel( bool showControls = true ) = 0;
123 virtual void addAlgorithm( const QString &algorithmId, const QPointF &pos ) = 0;
124 // cppcheck-suppress pureVirtualCall
125 virtual void addInput( const QString &inputId, const QPointF &pos ) = 0;
126 // cppcheck-suppress pureVirtualCall
127 virtual void exportAsScriptAlgorithm() = 0;
128 // cppcheck-suppress pureVirtualCall
129 virtual bool saveModel( bool saveAs = false ) = 0;
130 // cppcheck-suppress pureVirtualCall
131 virtual QgsProcessingAlgorithmDialogBase *createExecutionDialog() = 0 SIP_TRANSFERBACK;
132
133 QToolBar *toolbar() { return mToolbar; }
134 QAction *actionOpen() { return mActionOpen; }
135 QAction *actionSaveInProject() { return mActionSaveInProject; }
136 QAction *actionRun() { return mActionRun; }
137 QgsMessageBar *messageBar() { return mMessageBar; }
138 QGraphicsView *view() { return mView; }
139
140 void setDirty( bool dirty );
141
145 bool validateSave( SaveAction action );
146
152 bool checkForUnsavedChanges();
153
157 void setLastRunResult( const QgsProcessingModelResult &result );
158
166 void setModelName( const QString &name );
167
168 private slots:
169 void zoomIn();
170 void zoomOut();
171 void zoomActual();
172 void zoomFull();
173 void newModel();
174 void exportToImage();
175 void exportToPdf();
176 void exportToSvg();
177 void exportAsPython();
178 void toggleComments( bool show );
179 void updateWindowTitle();
180 void deleteSelected();
181 void populateZoomToMenu();
182 void validate();
183 void reorderInputs();
184 void reorderOutputs();
185 void setPanelVisibility( bool hidden );
186 void editHelp();
187 void runSelectedSteps();
188 void runFromChild( const QString &id );
189 void run( const QSet<QString> &childAlgorithmSubset = QSet<QString>() );
190 void showChildAlgorithmOutputs( const QString &childId );
191 void showChildAlgorithmLog( const QString &childId );
192
193 private:
194
195 enum UndoCommand
196 {
197 NameChanged = 1,
198 GroupChanged
199 };
200
201 std::unique_ptr< QgsProcessingModelAlgorithm > mModel;
202
203 QgsScreenHelper *mScreenHelper = nullptr;
204
205 QgsMessageBar *mMessageBar = nullptr;
206 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
207
208 QActionGroup *mToolsActionGroup = nullptr;
209
210 QgsModelViewToolPan *mPanTool = nullptr;
211 QgsModelViewToolSelect *mSelectTool = nullptr;
212 QgsModelGraphicsScene *mScene = nullptr;
213
214 bool mHasChanged = false;
215 QUndoStack *mUndoStack = nullptr;
216 std::unique_ptr< QgsModelUndoCommand > mActiveCommand;
217
218 QAction *mUndoAction = nullptr;
219 QAction *mRedoAction = nullptr;
220 QUndoView *mUndoView = nullptr;
221 QgsDockWidget *mUndoDock = nullptr;
222
223 QMenu *mGroupMenu = nullptr;
224
225 QAction *mActionCut = nullptr;
226 QAction *mActionCopy = nullptr;
227 QAction *mActionPaste = nullptr;
228 int mBlockUndoCommands = 0;
229 int mIgnoreUndoStackChanges = 0;
230
231 QString mTitle;
232
233 int mBlockRepaints = 0;
234
235 QgsProcessingModelResult mLastResult;
236
237 bool isDirty() const;
238
239 void fillInputsTree();
240 void updateVariablesGui();
241
242 struct PanelStatus
243 {
244 PanelStatus( bool visible = true, bool active = false )
245 : isVisible( visible )
246 , isActive( active )
247 {}
248 bool isVisible;
249 bool isActive;
250 };
251 QMap< QString, PanelStatus > mPanelStatus;
252
253 QgsProcessingContext mLayerStore;
254};
255
256
257
258class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
259{
260 Q_OBJECT
261
262 public:
263
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
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
QgsDockWidget subclass with more fine-grained control over how the widget is closed or opened.
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.
Contains information about the context in which a processing algorithm is executed.
Encapsulates the results of running a Processing model.
A sort/filter 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