Plugins/VcsPlugins/vcsMercurial/TransplantExtension/ProjectHelper.py

changeset 1078
aeee8401e2ce
child 1087
fb8cd56819a9
equal deleted inserted replaced
1076:6fb76985422b 1078:aeee8401e2ce
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the transplant extension project helper.
8 """
9
10 from PyQt4.QtCore import QObject
11 from PyQt4.QtGui import QMenu
12
13 from E5Gui.E5Action import E5Action
14 from E5Gui import E5MessageBox
15
16
17 class TransplantProjectHelper(QObject):
18 """
19 Class implementing the transplant extension project helper.
20 """
21 def __init__(self):
22 """
23 Constructor
24 """
25 QObject.__init__(self)
26
27 self.actions = []
28
29 self.initActions()
30
31 def setObjects(self, vcsObject, projectObject):
32 """
33 Public method to set references to the vcs and project objects.
34
35 @param vcsObject reference to the vcs object
36 @param projectObject reference to the project object
37 """
38 self.vcs = vcsObject
39 self.project = projectObject
40
41 def getActions(self):
42 """
43 Public method to get a list of all actions.
44
45 @return list of all actions (list of E5Action)
46 """
47 return self.actions[:]
48
49 def initActions(self):
50 """
51 Public method to generate the action objects.
52 """
53 self.hgTransplantAct = E5Action(self.trUtf8('Transplant Changesets'),
54 self.trUtf8('Transplant Changesets'),
55 0, 0, self, 'mercurial_transplant')
56 self.hgTransplantAct.setStatusTip(self.trUtf8(
57 'Transplant changesets from another branch'
58 ))
59 self.hgTransplantAct.setWhatsThis(self.trUtf8(
60 """<b>Transplant Changesets</b>"""
61 """<p>This transplants changesets from another branch on top of the"""
62 """ current working directory with the log of the original changeset.</p>"""
63 ))
64 self.hgTransplantAct.triggered[()].connect(self.__hgTransplant)
65 self.actions.append(self.hgTransplantAct)
66
67 self.hgTransplantContinueAct = E5Action(
68 self.trUtf8('Continue'),
69 self.trUtf8('Continue'),
70 0, 0, self, 'mercurial_transplant_continue')
71 self.hgTransplantContinueAct.setStatusTip(self.trUtf8(
72 'Continue the last transplant session after repair'
73 ))
74 self.hgTransplantContinueAct.setWhatsThis(self.trUtf8(
75 """<b>Continue</b>"""
76 """<p>This continues the last transplant session after repair.</p>"""
77 ))
78 self.hgTransplantContinueAct.triggered[()].connect(self.__hgTransplantContinue)
79 self.actions.append(self.hgTransplantContinueAct)
80
81 def initMenu(self, mainMenu):
82 """
83 Public method to generate the extension menu.
84
85 @param mainMenu reference to the main menu (QMenu)
86 @return populated menu (QMenu)
87 """
88 menu = QMenu(self.menuTitle(), mainMenu)
89 menu.setTearOffEnabled(True)
90
91 menu.addAction(self.hgTransplantAct)
92 menu.addAction(self.hgTransplantContinueAct)
93
94 return menu
95
96 def menuTitle(self):
97 """
98 Public method to get the menu title.
99 """
100 return self.trUtf8("Transplant")
101
102 def __hgTransplant(self):
103 """
104 Private slot used to transplant changesets from another branch.
105 """
106 shouldReopen = self.vcs.getExtensionObject("transplant")\
107 .hgTransplant(self.project.getProjectPath())
108 if shouldReopen:
109 res = E5MessageBox.yesNo(None,
110 self.trUtf8("Transplant Changesets"),
111 self.trUtf8("""The project should be reread. Do this now?"""),
112 yesDefault=True)
113 if res:
114 self.project.reopenProject()
115
116 def __hgTransplantContinue(self):
117 """
118 Private slot used to continue the last transplant session after repair.
119 """
120 shouldReopen = self.vcs.getExtensionObject("transplant")\
121 .hgTransplantContinue(self.project.getProjectPath())
122 if shouldReopen:
123 res = E5MessageBox.yesNo(None,
124 self.trUtf8("Transplant Changesets (Continue)"),
125 self.trUtf8("""The project should be reread. Do this now?"""),
126 yesDefault=True)
127 if res:
128 self.project.reopenProject()

eric ide

mercurial