Plugins/VcsPlugins/vcsMercurial/HgExtensionProjectBrowserHelper.py

Wed, 12 Mar 2014 18:46:12 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 12 Mar 2014 18:46:12 +0100
changeset 3359
6b6c224d67d6
parent 3312
7535e5a5cbce
child 3484
645c12de6b0c
permissions
-rw-r--r--

Corrected some code style issues.

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

eric ide

mercurial