Sun, 16 May 2021 20:07:24 +0200
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
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 | |
7923
91e843545d9a
Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
3 | # Copyright (c) 2014 - 2021 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. |
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 | |
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 | """ |
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 | 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
|
24 | """ |
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 | 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
|
26 | |
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 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
|
28 | @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
|
29 | @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
|
30 | """ |
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
|
31 | super().__init__() |
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
|
32 | |
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.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
|
34 | 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
|
35 | 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
|
36 | |
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 | 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
|
38 | """ |
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 | 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
|
40 | |
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 | 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
|
42 | |
7165
375c077ef7e2
Changed some code documentation from '@ireturn' to '@return'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6942
diff
changeset
|
43 | @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
|
44 | 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
|
45 | 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
|
46 | @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
|
47 | 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
|
48 | """ |
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 | raise NotImplementedError |
7192
a22eee00b052
Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7165
diff
changeset
|
50 | |
a22eee00b052
Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7165
diff
changeset
|
51 | return { |
a22eee00b052
Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7165
diff
changeset
|
52 | 'mainMenu': QMenu(), |
a22eee00b052
Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7165
diff
changeset
|
53 | 'multiMenu': QMenu(), |
a22eee00b052
Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7165
diff
changeset
|
54 | 'backMenu': QMenu(), |
a22eee00b052
Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7165
diff
changeset
|
55 | 'dirMenu': QMenu(), |
a22eee00b052
Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7165
diff
changeset
|
56 | 'dirMultiMenu': QMenu(), |
a22eee00b052
Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7165
diff
changeset
|
57 | } |
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
|
58 | |
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 | 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
|
60 | """ |
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 | 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
|
62 | |
cf4f22a19dc6
Added support for the Mercurial shelve extension to the project browser VCS context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | 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
|
64 | |
7165
375c077ef7e2
Changed some code documentation from '@ireturn' to '@return'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6942
diff
changeset
|
65 | @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
|
66 | @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
|
67 | 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
|
68 | """ |
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 | raise NotImplementedError |
7192
a22eee00b052
Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7165
diff
changeset
|
70 | |
a22eee00b052
Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7165
diff
changeset
|
71 | return "" |
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
|
72 | |
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 | 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
|
74 | """ |
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 | 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
|
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 | 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
|
78 | 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
|
79 | |
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 | @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
|
81 | '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
|
82 | @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
|
83 | 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
|
84 | (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
|
85 | @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
|
86 | 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
|
87 | """ |
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 | 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
|
89 | |
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 | 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
|
91 | """ |
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 | 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
|
93 | |
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
|
94 | @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
|
95 | (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
|
96 | """ |
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 | self.project.getModel().updateVCSStatus(name) |