Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Start creation of a c++ base class for modeler dialog
  • Loading branch information
nyalldawson committed Mar 6, 2020
1 parent 9335508 commit eefd04c
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 42 deletions.
@@ -0,0 +1,44 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/processing/models/qgsmodeldesignerdialog.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsModelDesignerDialog : QMainWindow
{
%Docstring
Model designer dialog base class

.. warning::

Not stable API

.. versionadded:: 3.14
%End

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

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

protected:

QToolBar *toolbar();

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/processing/models/qgsmodeldesignerdialog.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 @@ -311,6 +311,7 @@
%Include auto_generated/processing/qgsprocessingwidgetwrapper.sip
%Include auto_generated/processing/models/qgsmodelarrowitem.sip
%Include auto_generated/processing/models/qgsmodelcomponentgraphicitem.sip
%Include auto_generated/processing/models/qgsmodeldesignerdialog.sip
%Include auto_generated/processing/models/qgsmodelgraphicitem.sip
%Include auto_generated/processing/models/qgsmodelgraphicsscene.sip
%Include auto_generated/raster/qgscolorrampshaderwidget.sip
Expand Down
44 changes: 5 additions & 39 deletions python/plugins/processing/modeler/ModelerDialog.py
Expand Up @@ -87,7 +87,8 @@
QgsProcessingParameterDefinitionDialog,
QgsVariableEditorWidget,
QgsProcessingParameterWidgetContext,
QgsModelGraphicsScene)
QgsModelGraphicsScene,
QgsModelDesignerDialog)
from processing.gui.HelpEditionDialog import HelpEditionDialog
from processing.gui.AlgorithmDialog import AlgorithmDialog
from processing.modeler.ModelerParameterDefinitionDialog import ModelerParameterDefinitionDialog
Expand All @@ -102,10 +103,6 @@


pluginPath = os.path.split(os.path.dirname(__file__))[0]
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgModeler.ui'))


class ModelerToolboxModel(QgsProcessingToolboxProxyModel):
Expand All @@ -124,7 +121,7 @@ def supportedDragActions(self):
return Qt.CopyAction


class ModelerDialog(BASE, WIDGET):
class ModelerDialog(QgsModelDesignerDialog):
ALG_ITEM = 'ALG_ITEM'
PROVIDER_ITEM = 'PROVIDER_ITEM'
GROUP_ITEM = 'GROUP_ITEM'
Expand All @@ -141,8 +138,6 @@ def __init__(self, model=None):
super().__init__(None)
self.setAttribute(Qt.WA_DeleteOnClose)

self.setupUi(self)

self._variables_scope = None

# LOTS of bug reports when we include the dock creation in the UI file
Expand Down Expand Up @@ -273,46 +268,17 @@ def __init__(self, model=None):
pass

if iface is not None:
self.mToolbar.setIconSize(iface.iconSize())
self.toolbar().setIconSize(iface.iconSize())
self.setStyleSheet(iface.mainWindow().styleSheet())

self.toolbutton_export_to_script = QToolButton()
self.toolbutton_export_to_script.setPopupMode(QToolButton.InstantPopup)
self.export_to_script_algorithm_action = QAction(QCoreApplication.translate('ModelerDialog', 'Export as Script Algorithm…'))
self.toolbutton_export_to_script.addActions([self.export_to_script_algorithm_action])
self.toolbutton_export_to_script.setDefaultAction(self.export_to_script_algorithm_action)
self.mToolbar.insertWidget(self.mActionExportImage, self.toolbutton_export_to_script)
self.toolbar().insertWidget(self.mActionExportImage, self.toolbutton_export_to_script)
self.export_to_script_algorithm_action.triggered.connect(self.export_as_script_algorithm)

self.mActionOpen.setIcon(
QgsApplication.getThemeIcon('/mActionFileOpen.svg'))
self.mActionSave.setIcon(
QgsApplication.getThemeIcon('/mActionFileSave.svg'))
self.mActionSaveAs.setIcon(
QgsApplication.getThemeIcon('/mActionFileSaveAs.svg'))
self.mActionSaveInProject.setIcon(
QgsApplication.getThemeIcon('/mAddToProject.svg'))
self.mActionZoomActual.setIcon(
QgsApplication.getThemeIcon('/mActionZoomActual.svg'))
self.mActionZoomIn.setIcon(
QgsApplication.getThemeIcon('/mActionZoomIn.svg'))
self.mActionZoomOut.setIcon(
QgsApplication.getThemeIcon('/mActionZoomOut.svg'))
self.mActionExportImage.setIcon(
QgsApplication.getThemeIcon('/mActionSaveMapAsImage.svg'))
self.mActionZoomToItems.setIcon(
QgsApplication.getThemeIcon('/mActionZoomFullExtent.svg'))
self.mActionExportPdf.setIcon(
QgsApplication.getThemeIcon('/mActionSaveAsPDF.svg'))
self.mActionExportSvg.setIcon(
QgsApplication.getThemeIcon('/mActionSaveAsSVG.svg'))
self.toolbutton_export_to_script.setIcon(
QgsApplication.getThemeIcon('/mActionSaveAsPython.svg'))
self.mActionEditHelp.setIcon(
QgsApplication.getThemeIcon('/mActionEditHelpContent.svg'))
self.mActionRun.setIcon(
QgsApplication.getThemeIcon('/mActionStart.svg'))

self.addDockWidget(Qt.LeftDockWidgetArea, self.propertiesDock)
self.addDockWidget(Qt.LeftDockWidgetArea, self.inputsDock)
self.addDockWidget(Qt.LeftDockWidgetArea, self.algorithmsDock)
Expand Down
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Expand Up @@ -255,6 +255,7 @@ SET(QGIS_GUI_SRCS

processing/models/qgsmodelarrowitem.cpp
processing/models/qgsmodelcomponentgraphicitem.cpp
processing/models/qgsmodeldesignerdialog.cpp
processing/models/qgsmodelgraphicitem.cpp
processing/models/qgsmodelgraphicsscene.cpp

Expand Down Expand Up @@ -886,6 +887,7 @@ SET(QGIS_GUI_HDRS

processing/models/qgsmodelarrowitem.h
processing/models/qgsmodelcomponentgraphicitem.h
processing/models/qgsmodeldesignerdialog.h
processing/models/qgsmodelgraphicitem.h
processing/models/qgsmodelgraphicsscene.h

Expand Down
27 changes: 27 additions & 0 deletions src/gui/processing/models/qgsmodeldesignerdialog.cpp
@@ -0,0 +1,27 @@
/***************************************************************************
qgsmodeldesignerdialog.cpp
------------------------
Date : March 2020
Copyright : (C) 2020 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsmodeldesignerdialog.h"

///@cond NOT_STABLE

QgsModelDesignerDialog::QgsModelDesignerDialog( QWidget *parent, Qt::WindowFlags flags )
: QMainWindow( parent, flags )
{
setupUi( this );
}


///@endcond
45 changes: 45 additions & 0 deletions src/gui/processing/models/qgsmodeldesignerdialog.h
@@ -0,0 +1,45 @@
/***************************************************************************
qgsmodeldesignerdialog.h
------------------------
Date : March 2020
Copyright : (C) 2020 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSMODELDESIGNERDIALOG_H
#define QGSMODELDESIGNERDIALOG_H

#include "qgis.h"
#include "qgis_gui.h"
#include "ui_qgsmodeldesignerdialogbase.h"

///@cond NOT_STABLE

/**
* \ingroup gui
* \brief Model designer dialog base class
* \warning Not stable API
* \since QGIS 3.14
*/
class GUI_EXPORT QgsModelDesignerDialog : public QMainWindow, public Ui::QgsModelDesignerDialogBase
{
public:

QgsModelDesignerDialog( QWidget *parent = nullptr, Qt::WindowFlags flags = nullptr );

protected:

QToolBar *toolbar() { return mToolbar; }

};

///@endcond

#endif // QGSMODELDESIGNERDIALOG_H

0 comments on commit eefd04c

Please sign in to comment.