QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
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;
33
35
36#ifndef SIP_RUN
37
38class GUI_EXPORT QgsModelerToolboxModel : public QgsProcessingToolboxProxyModel
39{
40 Q_OBJECT
41 public:
42 explicit QgsModelerToolboxModel( QObject *parent = nullptr );
43 Qt::ItemFlags flags( const QModelIndex &index ) const override;
44 Qt::DropActions supportedDragActions() const override;
45
46};
47
48#endif
49
56class GUI_EXPORT QgsModelDesignerDialog : public QMainWindow, public Ui::QgsModelDesignerDialogBase
57{
58 Q_OBJECT
59 public:
60
61 QgsModelDesignerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
62 ~QgsModelDesignerDialog() override;
63
64 void closeEvent( QCloseEvent *event ) override;
65
69 void beginUndoCommand( const QString &text, int id = 0 );
70
74 void endUndoCommand();
75
79 QgsProcessingModelAlgorithm *model();
80
86 void setModel( QgsProcessingModelAlgorithm *model SIP_TRANSFER );
87
91 void loadModel( const QString &path );
92
96 void setModelScene( QgsModelGraphicsScene *scene SIP_TRANSFER );
97
103 enum class SaveAction
104 {
105 SaveAsFile,
106 SaveInProject,
107 };
108
109 public slots:
110
116 void activate();
117
118 protected:
119
120 // cppcheck-suppress pureVirtualCall
121 virtual void repaintModel( bool showControls = true ) = 0;
122 virtual void addAlgorithm( const QString &algorithmId, const QPointF &pos ) = 0;
123 // cppcheck-suppress pureVirtualCall
124 virtual void addInput( const QString &inputId, const QPointF &pos ) = 0;
125 // cppcheck-suppress pureVirtualCall
126 virtual void exportAsScriptAlgorithm() = 0;
127 // cppcheck-suppress pureVirtualCall
128 virtual bool saveModel( bool saveAs = false ) = 0;
129
130 QToolBar *toolbar() { return mToolbar; }
131 QAction *actionOpen() { return mActionOpen; }
132 QAction *actionSaveInProject() { return mActionSaveInProject; }
133 QAction *actionRun() { return mActionRun; }
134 QgsMessageBar *messageBar() { return mMessageBar; }
135 QGraphicsView *view() { return mView; }
136
137 void setDirty( bool dirty );
138
142 bool validateSave( SaveAction action );
143
149 bool checkForUnsavedChanges();
150
154 void setLastRunChildAlgorithmResults( const QVariantMap &results );
155
159 void setLastRunChildAlgorithmInputs( const QVariantMap &inputs );
160
168 void setModelName( const QString &name );
169
170 private slots:
171 void zoomIn();
172 void zoomOut();
173 void zoomActual();
174 void zoomFull();
175 void newModel();
176 void exportToImage();
177 void exportToPdf();
178 void exportToSvg();
179 void exportAsPython();
180 void toggleComments( bool show );
181 void updateWindowTitle();
182 void deleteSelected();
183 void populateZoomToMenu();
184 void validate();
185 void reorderInputs();
186 void reorderOutputs();
187 void setPanelVisibility( bool hidden );
188 void editHelp();
189
190 private:
191
192 enum UndoCommand
193 {
194 NameChanged = 1,
195 GroupChanged
196 };
197
198 std::unique_ptr< QgsProcessingModelAlgorithm > mModel;
199
200 QgsScreenHelper *mScreenHelper = nullptr;
201
202 QgsMessageBar *mMessageBar = nullptr;
203 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
204
205 QActionGroup *mToolsActionGroup = nullptr;
206
207 QgsModelViewToolPan *mPanTool = nullptr;
208 QgsModelViewToolSelect *mSelectTool = nullptr;
209 QgsModelGraphicsScene *mScene = nullptr;
210
211 bool mHasChanged = false;
212 QUndoStack *mUndoStack = nullptr;
213 std::unique_ptr< QgsModelUndoCommand > mActiveCommand;
214
215 QAction *mUndoAction = nullptr;
216 QAction *mRedoAction = nullptr;
217 QUndoView *mUndoView = nullptr;
218 QgsDockWidget *mUndoDock = nullptr;
219
220 QMenu *mGroupMenu = nullptr;
221
222 QAction *mActionCut = nullptr;
223 QAction *mActionCopy = nullptr;
224 QAction *mActionPaste = nullptr;
225 int mBlockUndoCommands = 0;
226 int mIgnoreUndoStackChanges = 0;
227
228 QString mTitle;
229
230 int mBlockRepaints = 0;
231
232 QVariantMap mChildResults;
233 QVariantMap mChildInputs;
234
235 bool isDirty() const;
236
237 void fillInputsTree();
238 void updateVariablesGui();
239
240 struct PanelStatus
241 {
242 PanelStatus( bool visible = true, bool active = false )
243 : isVisible( visible )
244 , isActive( active )
245 {}
246 bool isVisible;
247 bool isActive;
248 };
249 QMap< QString, PanelStatus > mPanelStatus;
250};
251
252
253
254class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
255{
256 Q_OBJECT
257
258 public:
259
260 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model, const QString &childId );
261 QList< QgsProcessingModelChildDependency > value() const { return mValue; }
262 void setValue( const QList< QgsProcessingModelChildDependency > &value );
263 private slots:
264
265 void showDialog();
266
267 private:
268
269 void updateSummaryText();
270
271 QLineEdit *mLineEdit = nullptr;
272 QToolButton *mToolButton = nullptr;
273
274 QgsProcessingModelAlgorithm *mModel = nullptr;
275 QString mChildId;
276
277 QList< QgsProcessingModelChildDependency > mValue;
278
279 friend class TestProcessingGui;
280};
282
283#endif // QGSMODELDESIGNERDIALOG_H
QgsDockWidget subclass with more fine-grained control over how the widget is closed or opened.
Definition: qgsdockwidget.h:32
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
Model designer view tool for panning a model.
Model designer view tool for selecting items in the 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