ProviderActions.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """
  2. ***************************************************************************
  3. ProviderActions.py
  4. -------------------
  5. Date : April 2017
  6. Copyright : (C) 2017 by Nyall Dawson
  7. Email : nyall dot dawson 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__ = 'Nyall Dawson'
  18. __date__ = 'April 2017'
  19. __copyright__ = '(C) 2017, Nyall Dason'
  20. class ProviderActions:
  21. actions = {}
  22. @staticmethod
  23. def registerProviderActions(provider, actions):
  24. """ Adds actions for a provider """
  25. ProviderActions.actions[provider.id()] = actions
  26. @staticmethod
  27. def deregisterProviderActions(provider):
  28. """ Removes actions for a provider """
  29. if provider.id() in ProviderActions.actions:
  30. del ProviderActions.actions[provider.id()]
  31. class ProviderContextMenuActions:
  32. # All the registered context menu actions for the toolbox
  33. actions = []
  34. @staticmethod
  35. def registerProviderContextMenuActions(actions):
  36. """ Adds context menu actions for a provider """
  37. ProviderContextMenuActions.actions.extend(actions)
  38. @staticmethod
  39. def deregisterProviderContextMenuActions(actions):
  40. """ Removes context menu actions for a provider """
  41. for act in actions:
  42. ProviderContextMenuActions.actions.remove(act)