CreateNewModelAction.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. """
  2. ***************************************************************************
  3. CreateNewModelAction.py
  4. ---------------------
  5. Date : August 2012
  6. Copyright : (C) 2012 by Victor Olaya
  7. Email : volayaf at gmail dot com
  8. ***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************
  16. """
  17. __author__ = 'Victor Olaya'
  18. __date__ = 'August 2012'
  19. __copyright__ = '(C) 2012, Victor Olaya'
  20. import os
  21. from qgis.PyQt.QtCore import QCoreApplication
  22. from qgis.core import QgsApplication
  23. from qgis.utils import iface
  24. from processing.gui.ToolboxAction import ToolboxAction
  25. from processing.modeler.ModelerDialog import ModelerDialog
  26. pluginPath = os.path.split(os.path.dirname(__file__))[0]
  27. class CreateNewModelAction(ToolboxAction):
  28. def __init__(self):
  29. self.name = QCoreApplication.translate('CreateNewModelAction', 'Create New Model…')
  30. self.group = self.tr('Tools')
  31. def getIcon(self):
  32. return QgsApplication.getThemeIcon("/processingModel.svg")
  33. def execute(self):
  34. dlg = ModelerDialog.create()
  35. dlg.update_model.connect(self.updateModel)
  36. dlg.show()
  37. def updateModel(self):
  38. QgsApplication.processingRegistry().providerById('model').refreshAlgorithms()