1# -*- coding: utf-8 -*-
2
3"""
4***************************************************************************
5    ProviderActions.py
6    -------------------
7    Date                 : April 2017
8    Copyright            : (C) 2017 by Nyall Dawson
9    Email                : nyall dot dawson at gmail dot com
10***************************************************************************
11*                                                                         *
12*   This program is free software; you can redistribute it and/or modify  *
13*   it under the terms of the GNU General Public License as published by  *
14*   the Free Software Foundation; either version 2 of the License, or     *
15*   (at your option) any later version.                                   *
16*                                                                         *
17***************************************************************************
18"""
19
20__author__ = 'Nyall Dawson'
21__date__ = 'April 2017'
22__copyright__ = '(C) 2017, Nyall Dason'
23
24
25class ProviderActions(object):
26    actions = {}
27
28    @staticmethod
29    def registerProviderActions(provider, actions):
30        """ Adds actions for a provider """
31        ProviderActions.actions[provider.id()] = actions
32
33    @staticmethod
34    def deregisterProviderActions(provider):
35        """ Removes actions for a provider """
36        if provider.id() in ProviderActions.actions:
37            del ProviderActions.actions[provider.id()]
38
39
40class ProviderContextMenuActions(object):
41    # All the registered context menu actions for the toolbox
42    actions = []
43
44    @staticmethod
45    def registerProviderContextMenuActions(actions):
46        """ Adds context menu actions for a provider """
47        ProviderContextMenuActions.actions.extend(actions)
48
49    @staticmethod
50    def deregisterProviderContextMenuActions(actions):
51        """ Removes context menu actions for a provider """
52        for act in actions:
53            ProviderContextMenuActions.actions.remove(act)
54