eric6/Plugins/VcsPlugins/vcsMercurial/HgExtensionProjectBrowserHelper.py

Sat, 31 Aug 2019 12:58:11 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 31 Aug 2019 12:58:11 +0200
branch
without_py2_and_pyqt4
changeset 7192
a22eee00b052
parent 7165
375c077ef7e2
child 7229
53054eb5b15a
permissions
-rw-r--r--

Started removing runtime support for Python2 and PyQt4.

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
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
3 # Copyright (c) 2014 - 2019 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
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3359
diff changeset
11 from __future__ import unicode_literals
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3359
diff changeset
12
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
13 from PyQt5.QtCore import QObject
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
14 from PyQt5.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
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
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 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
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 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
20 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
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 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
23 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
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 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
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 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
28
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 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
30 @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
31 @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
32 """
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3359
diff changeset
33 super(HgExtensionProjectBrowserHelper, self).__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
34
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.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
36 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
37 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
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 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
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 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
42
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 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
44
7165
375c077ef7e2 Changed some code documentation from '@ireturn' to '@return'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
45 @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
46 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
47 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
48 @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
49 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
50 """
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 raise NotImplementedError
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
52
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
53 return {
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
54 'mainMenu': QMenu(),
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
55 'multiMenu': QMenu(),
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
56 'backMenu': QMenu(),
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
57 'dirMenu': QMenu(),
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
58 'dirMultiMenu': QMenu(),
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
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
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 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
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 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
64
cf4f22a19dc6 Added support for the Mercurial shelve extension to the project browser VCS context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 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
66
7165
375c077ef7e2 Changed some code documentation from '@ireturn' to '@return'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
67 @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
68 @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
69 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
70 """
cf4f22a19dc6 Added support for the Mercurial shelve extension to the project browser VCS context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 raise NotImplementedError
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
72
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
73 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
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 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
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 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
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 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
80 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
81
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 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
83 '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
84 @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
85 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
86 (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
87 @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
88 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
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 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
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 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
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 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
95
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 @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
97 (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
98 """
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
99 self.project.getModel().updateVCSStatus(name)

eric ide

mercurial