16#ifndef QGSMODELDESIGNERDIALOG_H
17#define QGSMODELDESIGNERDIALOG_H
19#include "ui_qgsmodeldesignerdialogbase.h"
30class QgsProcessingModelAlgorithm;
31class QgsModelUndoCommand;
36class QgsProcessingAlgorithmWidgetBase;
49 explicit QgsModelerToolboxModel( QObject *parent =
nullptr );
50 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
51 Qt::DropActions supportedDragActions()
const override;
62class GUI_EXPORT QgsModelDesignerDialog :
public QMainWindow,
public QgsProcessingFeedbackGenerator,
public Ui::QgsModelDesignerDialogBase
66 QgsModelDesignerDialog( QWidget *parent
SIP_TRANSFERTHIS =
nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
67 ~QgsModelDesignerDialog()
override;
69 void closeEvent( QCloseEvent *event )
override;
74 void beginUndoCommand(
const QString &text,
const QString &
id = QString(), QgsModelUndoCommand::CommandOperation operation
SIP_PYARGREMOVE = QgsModelUndoCommand::CommandOperation::Unknown );
79 void endUndoCommand();
85 void abortUndoCommand();
90 QgsProcessingModelAlgorithm *model();
97 void setModel( QgsProcessingModelAlgorithm *model
SIP_TRANSFER );
102 void loadModel(
const QString &path );
109 void setModelScene( QgsModelGraphicsScene *scene
SIP_TRANSFER );
117 QgsModelGraphicsScene *modelScene();
119 QgsProcessingFeedback *createFeedback() override
SIP_FACTORY;
126 enum class SaveAction
143 virtual void repaintModel(
bool showControls =
true ) = 0;
144 virtual void addAlgorithm(
const QString &algorithmId,
const QPointF &pos ) = 0;
146 virtual void addInput(
const QString &inputId,
const QPointF &pos ) = 0;
148 virtual void exportAsScriptAlgorithm() = 0;
150 virtual bool saveModel(
bool saveAs =
false ) = 0;
152 virtual QgsProcessingAlgorithmWidgetBase *createExecutionWidget() = 0
SIP_TRANSFERBACK;
157 virtual QgsProcessingParameterWidgetContext createWidgetContext() = 0;
163 void registerProcessingContextGenerator( QgsProcessingContextGenerator *generator );
165 QToolBar *toolbar() {
return mToolbar; }
166 QAction *actionOpen() {
return mActionOpen; }
167 QAction *actionSaveInProject() {
return mActionSaveInProject; }
168 QAction *actionRun() {
return mActionRun; }
169 QgsMessageBar *messageBar() {
return mMessageBar; }
170 QgsModelGraphicsView *view() {
return mView; }
172 void setDirty(
bool dirty );
177 bool validateSave( SaveAction action );
184 bool checkForUnsavedChanges();
189 void setLastRunResult(
const QgsProcessingModelResult &result );
198 void setModelName(
const QString &name );
206 void exportToImage();
209 void exportAsPython();
210 void toggleComments(
bool show );
211 void toggleFeatureCount(
bool show );
212 void updateWindowTitle();
213 void deleteSelected();
214 void populateZoomToMenu();
216 void reorderInputs();
217 void reorderOutputs();
218 void setPanelVisibility(
bool hidden );
220 void runSelectedSteps();
221 void runFromChild(
const QString &
id );
222 void run(
const QSet<QString> &childAlgorithmSubset = QSet<QString>() );
223 void showChildAlgorithmOutputs(
const QString &childId );
224 void showChildAlgorithmLog(
const QString &childId );
225 void onItemFocused( QgsModelComponentGraphicItem *item );
227 void cancelRunningModel();
230 std::unique_ptr<QgsProcessingModelAlgorithm> mModel;
232 QgsScreenHelper *mScreenHelper =
nullptr;
234 QgsMessageBar *mMessageBar =
nullptr;
235 QgsModelerToolboxModel *mAlgorithmsModel =
nullptr;
237 QPointer<QgsProcessingAlgorithmWidgetBase> mAlgorithmWidget;
239 QVector<QPointer<QgsProcessingAlgorithmWidgetBase>> mAlgorithmWidgetsToCleanUp;
241 QActionGroup *mToolsActionGroup =
nullptr;
243 QgsModelViewToolPan *mPanTool =
nullptr;
244 QObjectUniquePtr<QgsModelViewToolSelect> mSelectTool;
245 QgsModelGraphicsScene *mScene =
nullptr;
247 bool mHasChanged =
false;
248 QUndoStack *mUndoStack =
nullptr;
249 std::unique_ptr<QgsModelUndoCommand> mActiveCommand;
251 QAction *mUndoAction =
nullptr;
252 QAction *mRedoAction =
nullptr;
253 QUndoView *mUndoView =
nullptr;
254 QgsDockWidget *mUndoDock =
nullptr;
256 QMenu *mGroupMenu =
nullptr;
258 QAction *mActionCut =
nullptr;
259 QAction *mActionCopy =
nullptr;
260 QAction *mActionPaste =
nullptr;
261 int mBlockUndoCommands = 0;
262 int mIgnoreUndoStackChanges = 0;
264 QgsDockWidget *mConfigWidgetDock =
nullptr;
265 QgsModelDesignerConfigDockWidget *mConfigWidget =
nullptr;
267 QgsProcessingContextGenerator *mProcessingContextGenerator =
nullptr;
271 int mBlockRepaints = 0;
273 QgsProcessingModelResult mLastResult;
274 QSet< QString > mOutdatedChildResults;
276 bool isDirty()
const;
278 void fillInputsTree();
279 void updateVariablesGui();
283 PanelStatus(
bool visible =
true,
bool active =
false )
284 : isVisible( visible )
290 QMap<QString, PanelStatus> mPanelStatus;
292 QgsProcessingContext mLayerStore;
296class GUI_EXPORT QgsModelChildDependenciesWidget :
public QWidget
301 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model,
const QString &childId );
302 QList<QgsProcessingModelChildDependency> value()
const {
return mValue; }
303 void setValue(
const QList<QgsProcessingModelChildDependency> &value );
309 void updateSummaryText();
311 QLineEdit *mLineEdit =
nullptr;
312 QToolButton *mToolButton =
nullptr;
314 QgsProcessingModelAlgorithm *mModel =
nullptr;
317 QList<QgsProcessingModelChildDependency> mValue;
319 friend class TestProcessingGui;
A bar for displaying non-blocking messages to the user.
An interface for objects which can create Processing contexts.
Contains settings which reflect the context in which a Processing parameter widget is shown.
A utility class for dynamic handling of changes to screen properties.