Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/ProjectHelper.py

changeset 1011
0b118aefae5b
child 1017
919147f2b518
equal deleted inserted replaced
1010:06393b5f5330 1011:0b118aefae5b
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the bookmarks 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
15
16 class BookmarksProjectHelper(QObject):
17 """
18 Class implementing the bookmarks extension project helper.
19 """
20 def __init__(self):
21 """
22 Constructor
23 """
24 QObject.__init__(self)
25
26 self.actions = []
27
28 self.initActions()
29
30 def setObjects(self, vcsObject, projectObject):
31 """
32 Public method to set references to the vcs and project objects.
33
34 @param vcsObject reference to the vcs object
35 @param projectObject reference to the project object
36 """
37 self.vcs = vcsObject
38 self.project = projectObject
39
40 def getActions(self):
41 """
42 Public method to get a list of all actions.
43
44 @return list of all actions (list of E5Action)
45 """
46 return self.actions[:]
47
48 def initActions(self):
49 """
50 Public method to generate the action objects.
51 """
52 self.hgBookmarksListAct = E5Action(self.trUtf8('List bookmarks'),
53 self.trUtf8('List bookmarks...'),
54 0, 0, self, 'mercurial_list_bookmarks')
55 self.hgBookmarksListAct.setStatusTip(self.trUtf8(
56 'List bookmarks of the project'
57 ))
58 self.hgBookmarksListAct.setWhatsThis(self.trUtf8(
59 """<b>List bookmarks</b>"""
60 """<p>This lists the bookmarks of the project.</p>"""
61 ))
62 self.hgBookmarksListAct.triggered[()].connect(self.__hgBookmarksList)
63 self.actions.append(self.hgBookmarksListAct)
64
65 self.hgBookmarkDefineAct = E5Action(self.trUtf8('Define bookmark'),
66 self.trUtf8('Define bookmark...'),
67 0, 0, self, 'mercurial_define_bookmark')
68 self.hgBookmarkDefineAct.setStatusTip(self.trUtf8(
69 'Define a bookmark for the project'
70 ))
71 self.hgBookmarkDefineAct.setWhatsThis(self.trUtf8(
72 """<b>Define bookmark</b>"""
73 """<p>This defines a bookmark for the project.</p>"""
74 ))
75 self.hgBookmarkDefineAct.triggered[()].connect(self.__hgBookmarkDefine)
76 self.actions.append(self.hgBookmarkDefineAct)
77
78 self.hgBookmarkDeleteAct = E5Action(self.trUtf8('Delete bookmark'),
79 self.trUtf8('Delete bookmark...'),
80 0, 0, self, 'mercurial_delete_bookmark')
81 self.hgBookmarkDeleteAct.setStatusTip(self.trUtf8(
82 'Delete a bookmark of the project'
83 ))
84 self.hgBookmarkDeleteAct.setWhatsThis(self.trUtf8(
85 """<b>Delete bookmark</b>"""
86 """<p>This deletes a bookmark of the project.</p>"""
87 ))
88 self.hgBookmarkDeleteAct.triggered[()].connect(self.__hgBookmarkDelete)
89 self.actions.append(self.hgBookmarkDeleteAct)
90
91 self.hgBookmarkRenameAct = E5Action(self.trUtf8('Rename bookmark'),
92 self.trUtf8('Rename bookmark...'),
93 0, 0, self, 'mercurial_rename_bookmark')
94 self.hgBookmarkRenameAct.setStatusTip(self.trUtf8(
95 'Rename a bookmark of the project'
96 ))
97 self.hgBookmarkRenameAct.setWhatsThis(self.trUtf8(
98 """<b>Rename bookmark</b>"""
99 """<p>This renames a bookmark of the project.</p>"""
100 ))
101 self.hgBookmarkRenameAct.triggered[()].connect(self.__hgBookmarkRename)
102 self.actions.append(self.hgBookmarkRenameAct)
103
104 def initMenu(self, mainMenu):
105 """
106 Public method to generate the VCS menu.
107
108 @param mainMenu reference to the main menu (QMenu)
109 @return populated menu (QMenu)
110 """
111 menu = QMenu(self.trUtf8("Bookmarks"), mainMenu)
112
113 menu.addAction(self.hgBookmarkDefineAct)
114 menu.addAction(self.hgBookmarkDeleteAct)
115 menu.addAction(self.hgBookmarkRenameAct)
116 menu.addSeparator()
117 menu.addAction(self.hgBookmarksListAct)
118
119 return menu
120
121 def __hgBookmarksList(self):
122 """
123 Private slot used to list the bookmarks.
124 """
125 self.vcs.getExtensionObject("bookmarks")\
126 .hgListBookmarks(self.project.getProjectPath())
127
128 def __hgBookmarkDefine(self):
129 """
130 Private slot used to define a bookmark.
131 """
132 self.vcs.getExtensionObject("bookmarks")\
133 .hgBookmarkDefine(self.project.getProjectPath())
134
135 def __hgBookmarkDelete(self):
136 """
137 Private slot used to delete a bookmark.
138 """
139 self.vcs.getExtensionObject("bookmarks")\
140 .hgBookmarkDelete(self.project.getProjectPath())
141
142 def __hgBookmarkRename(self):
143 """
144 Private slot used to delete a bookmark.
145 """
146 self.vcs.getExtensionObject("bookmarks")\
147 .hgBookmarkRename(self.project.getProjectPath())

eric ide

mercurial