eric6/Plugins/VcsPlugins/vcsMercurial/HgExtensionProjectBrowserHelper.py

Wed, 01 Jan 2020 11:57:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 01 Jan 2020 11:57:23 +0100
changeset 7360
9190402e4505
parent 7229
53054eb5b15a
child 7780
41420f82c0ac
permissions
-rw-r--r--

Updated copyright for 2020.

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
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
3 # Copyright (c) 2014 - 2020 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
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
12 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
13 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
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
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 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
17 """
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 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
19 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
20
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 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
22 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
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 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
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
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 """
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3359
diff changeset
32 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
33
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
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 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.
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 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
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
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
51
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
52 return {
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
53 'mainMenu': QMenu(),
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
54 'multiMenu': QMenu(),
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
55 'backMenu': QMenu(),
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
56 'dirMenu': QMenu(),
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
57 'dirMultiMenu': QMenu(),
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
58 }
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
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 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.
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
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.
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
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
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
71
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7165
diff changeset
72 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
73
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.
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
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.
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 @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.
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
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