Skip to content

Commit

Permalink
Port some more model designer Python code to c++
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 6, 2020
1 parent eefd04c commit a0e6a37
Show file tree
Hide file tree
Showing 14 changed files with 654 additions and 371 deletions.
Expand Up @@ -9,6 +9,7 @@




class QgsModelDesignerDialog : QMainWindow
{
%Docstring
Expand All @@ -26,11 +27,26 @@ Model designer dialog base class
%End
public:

QgsModelDesignerDialog( QWidget *parent = 0, Qt::WindowFlags flags = 0 );
QgsModelDesignerDialog( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags flags = 0 );

protected:

virtual void repaintModel( bool showControls = true ) = 0;
virtual QgsProcessingModelAlgorithm *model() = 0;
virtual void addAlgorithm( const QString &algorithmId, const QPointF &pos ) = 0;
virtual void addInput( const QString &inputId, const QPointF &pos ) = 0;

QToolBar *toolbar();
QAction *actionOpen();
QAction *actionSave();
QAction *actionSaveAs();
QAction *actionSaveInProject();
QAction *actionEditHelp();
QAction *actionRun();
QAction *actionExportImage();

QgsMessageBar *messageBar();
QGraphicsView *view();

};

Expand Down
@@ -0,0 +1,70 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/processing/models/qgsmodelgraphicsview.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsModelGraphicsView : QGraphicsView
{
%Docstring
QGraphicsView subclass representing the model designer.

.. warning::

Not stable API

.. versionadded:: 3.14
%End

%TypeHeaderCode
#include "qgsmodelgraphicsview.h"
%End
public:

QgsModelGraphicsView( QWidget *parent = 0 );
%Docstring
Constructor for QgsModelGraphicsView, with the specified ``parent`` widget.
%End

virtual void dragEnterEvent( QDragEnterEvent *event );

virtual void dropEvent( QDropEvent *event );

virtual void dragMoveEvent( QDragMoveEvent *event );

virtual void wheelEvent( QWheelEvent *event );

virtual void enterEvent( QEvent *event );

virtual void mousePressEvent( QMouseEvent *event );

virtual void mouseMoveEvent( QMouseEvent *event );


signals:

void algorithmDropped( const QString &algorithmId, const QPointF &pos );
%Docstring
Emitted when an algorithm is dropped onto the view.
%End

void inputDropped( const QString &inputId, const QPointF &pos );
%Docstring
Emitted when an input parameter is dropped onto the view.
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/processing/models/qgsmodelgraphicsview.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
1 change: 1 addition & 0 deletions python/gui/gui_auto.sip
Expand Up @@ -314,6 +314,7 @@
%Include auto_generated/processing/models/qgsmodeldesignerdialog.sip
%Include auto_generated/processing/models/qgsmodelgraphicitem.sip
%Include auto_generated/processing/models/qgsmodelgraphicsscene.sip
%Include auto_generated/processing/models/qgsmodelgraphicsview.sip
%Include auto_generated/raster/qgscolorrampshaderwidget.sip
%Include auto_generated/raster/qgshillshaderendererwidget.sip
%Include auto_generated/raster/qgsmultibandcolorrendererwidget.sip
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/ProcessingPlugin.py
Expand Up @@ -122,7 +122,7 @@ def runModel(self):
ProcessingDropHandler.runAlg(self.path())

def editModel(self):
dlg = ModelerDialog()
dlg = ModelerDialog.create()
dlg.loadModel(self.path())
dlg.show()

Expand Down Expand Up @@ -332,7 +332,7 @@ def toolboxVisibilityChanged(self, visible):
self.toolboxAction.setChecked(visible)

def openModeler(self):
dlg = ModelerDialog()
dlg = ModelerDialog.create()
dlg.update_model.connect(self.updateModel)
dlg.show()

Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/modeler/CreateNewModelAction.py
Expand Up @@ -26,6 +26,7 @@
from qgis.PyQt.QtCore import QCoreApplication

from qgis.core import QgsApplication
from qgis.utils import iface

from processing.gui.ToolboxAction import ToolboxAction
from processing.modeler.ModelerDialog import ModelerDialog
Expand All @@ -43,7 +44,7 @@ def getIcon(self):
return QgsApplication.getThemeIcon("/processingModel.svg")

def execute(self):
dlg = ModelerDialog()
dlg = ModelerDialog.create()
dlg.update_model.connect(self.updateModel)
dlg.show()

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/modeler/EditModelAction.py
Expand Up @@ -44,7 +44,7 @@ def execute(self):
if not ok:
iface.messageBar().pushMessage(QCoreApplication.translate('EditModelAction', 'Cannot edit model: {}').format(msg), level=Qgis.Warning)
else:
dlg = ModelerDialog(alg)
dlg = ModelerDialog.create(alg)
dlg.update_model.connect(self.updateModel)
dlg.show()

Expand Down

0 comments on commit a0e6a37

Please sign in to comment.