QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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 virtual void addInput( const QString &inputId, const QPointF &pos ) = 0;
124 virtual void exportAsScriptAlgorithm() = 0;
125 // cppcheck-suppress pureVirtualCall
126 virtual bool saveModel( bool saveAs = false ) = 0;
127
128 QToolBar *toolbar() { return mToolbar; }
129 QAction *actionOpen() { return mActionOpen; }
130 QAction *actionSaveInProject() { return mActionSaveInProject; }
131 QAction *actionRun() { return mActionRun; }
132 QgsMessageBar *messageBar() { return mMessageBar; }
133 QGraphicsView *view() { return mView; }
134
135 void setDirty( bool dirty );
136
140 bool validateSave( SaveAction action );
141
147 bool checkForUnsavedChanges();
148
152 void setLastRunChildAlgorithmResults( const QVariantMap &results );
153
157 void setLastRunChildAlgorithmInputs( const QVariantMap &inputs );
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 setPanelVisibility( bool hidden );
185 void editHelp();
186
187 private:
188
189 enum UndoCommand
190 {
191 NameChanged = 1,
192 GroupChanged
193 };
194
195 std::unique_ptr< QgsProcessingModelAlgorithm > mModel;
196
197 QgsScreenHelper *mScreenHelper = nullptr;
198
199 QgsMessageBar *mMessageBar = nullptr;
200 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
201
202 QActionGroup *mToolsActionGroup = nullptr;
203
204 QgsModelViewToolPan *mPanTool = nullptr;
205 QgsModelViewToolSelect *mSelectTool = nullptr;
206 QgsModelGraphicsScene *mScene = nullptr;
207
208 bool mHasChanged = false;
209 QUndoStack *mUndoStack = nullptr;
210 std::unique_ptr< QgsModelUndoCommand > mActiveCommand;
211
212 QAction *mUndoAction = nullptr;
213 QAction *mRedoAction = nullptr;
214 QUndoView *mUndoView = nullptr;
215 QgsDockWidget *mUndoDock = nullptr;
216
217 QMenu *mGroupMenu = nullptr;
218
219 QAction *mActionCut = nullptr;
220 QAction *mActionCopy = nullptr;
221 QAction *mActionPaste = nullptr;
222 int mBlockUndoCommands = 0;
223 int mIgnoreUndoStackChanges = 0;
224
225 QString mTitle;
226
227 int mBlockRepaints = 0;
228
229 QVariantMap mChildResults;
230 QVariantMap mChildInputs;
231
232 bool isDirty() const;
233
234 void fillInputsTree();
235 void updateVariablesGui();
236
237 struct PanelStatus
238 {
239 PanelStatus( bool visible = true, bool active = false )
240 : isVisible( visible )
241 , isActive( active )
242 {}
243 bool isVisible;
244 bool isActive;
245 };
246 QMap< QString, PanelStatus > mPanelStatus;
247};
248
249
250
251class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
252{
253 Q_OBJECT
254
255 public:
256
257 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model, const QString &childId );
258 QList< QgsProcessingModelChildDependency > value() const { return mValue; }
259 void setValue( const QList< QgsProcessingModelChildDependency > &value );
260 private slots:
261
262 void showDialog();
263
264 private:
265
266 void updateSummaryText();
267
268 QLineEdit *mLineEdit = nullptr;
269 QToolButton *mToolButton = nullptr;
270
271 QgsProcessingModelAlgorithm *mModel = nullptr;
272 QString mChildId;
273
274 QList< QgsProcessingModelChildDependency > mValue;
275
276 friend class TestProcessingGui;
277};
279
280#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