|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2014 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the project browser helper base for Mercurial extension |
|
8 interfaces. |
|
9 """ |
|
10 |
|
11 from __future__ import unicode_literals |
|
12 |
|
13 from PyQt4.QtCore import QObject |
|
14 |
|
15 |
|
16 class HgExtensionProjectBrowserHelper(QObject): |
|
17 """ |
|
18 Class implementing the project browser helper base for Mercurial extension |
|
19 interfaces. |
|
20 |
|
21 Note: The methods initMenus() and menuTitle() have to be reimplemented by |
|
22 derived classes. |
|
23 """ |
|
24 def __init__(self, vcsObject, browserObject, projectObject): |
|
25 """ |
|
26 Constructor |
|
27 |
|
28 @param vcsObject reference to the vcs object |
|
29 @param browserObject reference to the project browser object |
|
30 @param projectObject reference to the project object |
|
31 """ |
|
32 super(HgExtensionProjectBrowserHelper, self).__init__() |
|
33 |
|
34 self.vcs = vcsObject |
|
35 self.browser = browserObject |
|
36 self.project = projectObject |
|
37 |
|
38 def initMenus(self): |
|
39 """ |
|
40 Public method to generate the extension menus. |
|
41 |
|
42 Note: Derived class must implement this method. |
|
43 |
|
44 @ireturn dictionary of populated menu (dict of QMenu). The dict |
|
45 must have the keys 'mainMenu', 'multiMenu', 'backMenu', 'dirMenu' |
|
46 and 'dirMultiMenu'. |
|
47 @exception NotImplementedError raised if the class has not been |
|
48 reimplemented |
|
49 """ |
|
50 raise NotImplementedError |
|
51 |
|
52 def menuTitle(self): |
|
53 """ |
|
54 Public method to get the menu title. |
|
55 |
|
56 Note: Derived class must implement this method. |
|
57 |
|
58 @ireturn title of the menu (string) |
|
59 @exception NotImplementedError raised if the class has not been |
|
60 reimplemented |
|
61 """ |
|
62 raise NotImplementedError |
|
63 |
|
64 def showExtensionMenu(self, key, controlled): |
|
65 """ |
|
66 Public method to prepare the extension menu for display. |
|
67 |
|
68 Note: Derived class must implement this method to adjust the |
|
69 enabled states of its menus. |
|
70 |
|
71 @param key menu key (string, one of 'mainMenu', 'multiMenu', |
|
72 'backMenu', 'dirMenu' or 'dirMultiMenu') |
|
73 @param controlled flag indicating to prepare the menu for a |
|
74 version controlled entry or a non-version controlled entry |
|
75 (boolean) |
|
76 @exception NotImplementedError raised if the class has not been |
|
77 reimplemented |
|
78 """ |
|
79 raise NotImplementedError |
|
80 |
|
81 def _updateVCSStatus(self, name): |
|
82 """ |
|
83 Protected method to update the VCS status of an item. |
|
84 |
|
85 @param name filename or directoryname of the item to be updated |
|
86 (string) |
|
87 """ |
|
88 self.project.getModel().updateVCSStatus(name) |