src/eric7/Plugins/VcsPlugins/vcsMercurial/HgExtensionProjectBrowserHelper.py

Sat, 01 Oct 2022 19:42:50 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 01 Oct 2022 19:42:50 +0200
branch
eric7
changeset 9375
e21b51a3d990
parent 9221
bf71ee032bb4
child 9653
e67609152c5e
permissions
-rw-r--r--

Third Party packages
- upgraded pycodestyle to version 2.9.1

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
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
3 # Copyright (c) 2014 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
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
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
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
11 from PyQt6.QtCore import QObject
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
12 from PyQt6.QtWidgets import QMenu
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
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
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 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
16 """
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 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
18 interfaces.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
19
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
20 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
21 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
22 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
23
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
24 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
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 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
27
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
28 @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
29 @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
30 @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
31 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
32 super().__init__()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
33
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
34 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
35 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
36 self.project = projectObject
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
37
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
38 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
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 Public method to generate the extension menus.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
41
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
42 Note: Derived class must implement this method.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
43
7165
375c077ef7e2 Changed some code documentation from '@ireturn' to '@return'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
44 @return dictionary of populated menu (dict of QMenu). The dict
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 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
46 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
47 @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
48 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
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 raise NotImplementedError
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
51
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
52 return {
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
53 "mainMenu": QMenu(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
54 "multiMenu": QMenu(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
55 "backMenu": QMenu(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
56 "dirMenu": QMenu(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
57 "dirMultiMenu": QMenu(),
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
58 }
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
59
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
60 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
61 """
cf4f22a19dc6 Added support for the Mercurial shelve extension to the project browser VCS context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 Public method to get the menu title.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
63
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
64 Note: Derived class must implement this method.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
65
7165
375c077ef7e2 Changed some code documentation from '@ireturn' to '@return'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
66 @return title of the menu (string)
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
67 @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
68 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
69 """
cf4f22a19dc6 Added support for the Mercurial shelve extension to the project browser VCS context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 raise NotImplementedError
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
71
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
72 return ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
73
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
74 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
75 """
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 Public method to prepare the extension menu for display.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
77
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
78 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
79 enabled states of its menus.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
80
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
81 @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
82 '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
83 @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
84 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
85 (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
86 @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
87 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
88 """
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
89 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
90
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
91 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
92 """
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
93 Protected method to update the VCS status of an item.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
94
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
95 @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
96 (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
97 """
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
98 self.project.getModel().updateVCSStatus(name)

eric ide

mercurial