EditModelAction.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. """
  2. ***************************************************************************
  3. EditModelAction.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. from qgis.PyQt.QtCore import QCoreApplication
  21. from qgis.core import QgsApplication, QgsProcessingAlgorithm
  22. from processing.gui.ContextAction import ContextAction
  23. from processing.modeler.ModelerDialog import ModelerDialog
  24. from qgis.core import Qgis
  25. from qgis.utils import iface
  26. class EditModelAction(ContextAction):
  27. def __init__(self):
  28. super().__init__()
  29. self.name = QCoreApplication.translate('EditModelAction', 'Edit Model…')
  30. def isEnabled(self):
  31. return isinstance(self.itemData, QgsProcessingAlgorithm) and self.itemData.provider().id() in ("model", "project")
  32. def execute(self):
  33. alg = self.itemData
  34. dlg = ModelerDialog.create(alg)
  35. dlg.update_model.connect(self.updateModel)
  36. dlg.show()
  37. dlg.activate()
  38. def updateModel(self):
  39. QgsApplication.processingRegistry().providerById('model').refreshAlgorithms()