|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the project helper base for Mercurial extension interfaces. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtCore import QObject |
|
13 |
|
14 |
|
15 class HgExtensionProjectHelper(QObject): |
|
16 """ |
|
17 Class implementing the project helper base for Mercurial extension |
|
18 interfaces. |
|
19 |
|
20 Note: The methods initActions(), initMenu(mainMenu) and menuTitle() have |
|
21 to be reimplemented by derived classes. |
|
22 """ |
|
23 def __init__(self): |
|
24 """ |
|
25 Constructor |
|
26 """ |
|
27 super(HgExtensionProjectHelper, self).__init__() |
|
28 |
|
29 self.actions = [] |
|
30 |
|
31 self.initActions() |
|
32 |
|
33 def setObjects(self, vcsObject, projectObject): |
|
34 """ |
|
35 Public method to set references to the vcs and project objects. |
|
36 |
|
37 @param vcsObject reference to the vcs object |
|
38 @param projectObject reference to the project object |
|
39 """ |
|
40 self.vcs = vcsObject |
|
41 self.project = projectObject |
|
42 |
|
43 def getActions(self): |
|
44 """ |
|
45 Public method to get a list of all actions. |
|
46 |
|
47 @return list of all actions (list of E5Action) |
|
48 """ |
|
49 return self.actions[:] |
|
50 |
|
51 def initActions(self): |
|
52 """ |
|
53 Public method to generate the action objects. |
|
54 |
|
55 Note: Derived class must implement this method. |
|
56 |
|
57 @exception NotImplementedError raised if the class has not been |
|
58 reimplemented |
|
59 """ |
|
60 raise NotImplementedError |
|
61 |
|
62 def initMenu(self, mainMenu): |
|
63 """ |
|
64 Public method to generate the extension menu. |
|
65 |
|
66 Note: Derived class must implement this method. |
|
67 |
|
68 @param mainMenu reference to the main menu (QMenu) |
|
69 @ireturn populated menu (QMenu) |
|
70 @exception NotImplementedError raised if the class has not been |
|
71 reimplemented |
|
72 """ |
|
73 raise NotImplementedError |
|
74 |
|
75 def menuTitle(self): |
|
76 """ |
|
77 Public method to get the menu title. |
|
78 |
|
79 Note: Derived class must implement this method. |
|
80 |
|
81 @ireturn title of the menu (string) |
|
82 @exception NotImplementedError raised if the class has not been |
|
83 reimplemented |
|
84 """ |
|
85 raise NotImplementedError |
|
86 |
|
87 def shutdown(self): |
|
88 """ |
|
89 Public method to perform shutdown actions. |
|
90 |
|
91 Note: Derived class may implement this method if needed. |
|
92 """ |
|
93 pass |