Plugins/VcsPlugins/vcsSubversion/ProjectBrowserHelper.py

changeset 0
de9c2efb9d02
child 13
1af94a91f439
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2005 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the VCS project browser helper for subversion.
8 """
9
10 import os
11
12 from PyQt4.QtCore import *
13 from PyQt4.QtGui import *
14
15 from E4Gui.E4Application import e4App
16
17 from VCS.ProjectBrowserHelper import VcsProjectBrowserHelper
18
19 from Project.ProjectBrowserModel import ProjectBrowserFileItem
20
21 import UI.PixmapCache
22
23 class SvnProjectBrowserHelper(VcsProjectBrowserHelper):
24 """
25 Class implementing the VCS project browser helper for subversion.
26 """
27 def __init__(self, vcsObject, browserObject, projectObject, isTranslationsBrowser,
28 parent = None, name = None):
29 """
30 Constructor
31
32 @param vcsObject reference to the vcs object
33 @param browserObject reference to the project browser object
34 @param projectObject reference to the project object
35 @param isTranslationsBrowser flag indicating, the helper is requested for the
36 translations browser (this needs some special treatment)
37 @param parent parent widget (QWidget)
38 @param name name of this object (string)
39 """
40 VcsProjectBrowserHelper.__init__(self, vcsObject, browserObject, projectObject,
41 isTranslationsBrowser, parent, name)
42
43 def showContextMenu(self, menu, standardItems):
44 """
45 Slot called before the context menu is shown.
46
47 It enables/disables the VCS menu entries depending on the overall
48 VCS status and the file status.
49
50 @param menu reference to the menu to be shown
51 @param standardItems array of standard items that need activation/deactivation
52 depending on the overall VCS status
53 """
54 if self.browser.currentItem().data(1) == self.vcs.vcsName():
55 for act in self.vcsMenuActions:
56 act.setEnabled(True)
57 for act in self.vcsAddMenuActions:
58 act.setEnabled(False)
59 for act in standardItems:
60 act.setEnabled(False)
61 if not hasattr(self.browser.currentItem(), 'fileName'):
62 self.blameAct.setEnabled(False)
63 else:
64 for act in self.vcsMenuActions:
65 act.setEnabled(False)
66 for act in self.vcsAddMenuActions:
67 act.setEnabled(True)
68 if 1 in self.browser.specialMenuEntries:
69 try:
70 name = self.browser.currentItem().fileName()
71 except AttributeError:
72 name = self.browser.currentItem().dirName()
73 if not os.path.isdir(name):
74 self.vcsMenuAddTree.setEnabled(False)
75 for act in standardItems:
76 act.setEnabled(True)
77
78 def showContextMenuMulti(self, menu, standardItems):
79 """
80 Slot called before the context menu (multiple selections) is shown.
81
82 It enables/disables the VCS menu entries depending on the overall
83 VCS status and the files status.
84
85 @param menu reference to the menu to be shown
86 @param standardItems array of standard items that need activation/deactivation
87 depending on the overall VCS status
88 """
89 vcsName = self.vcs.vcsName()
90 items = self.browser.getSelectedItems()
91 vcsItems = 0
92 # determine number of selected items under VCS control
93 for itm in items:
94 if itm.data(1) == vcsName:
95 vcsItems += 1
96
97 if vcsItems > 0:
98 if vcsItems != len(items):
99 for act in self.vcsMultiMenuActions:
100 act.setEnabled(False)
101 else:
102 for act in self.vcsMultiMenuActions:
103 act.setEnabled(True)
104 for act in self.vcsAddMultiMenuActions:
105 act.setEnabled(False)
106 for act in standardItems:
107 act.setEnabled(False)
108 else:
109 for act in self.vcsMultiMenuActions:
110 act.setEnabled(False)
111 for act in self.vcsAddMultiMenuActions:
112 act.setEnabled(True)
113 if 1 in self.browser.specialMenuEntries and \
114 self.__itemsHaveFiles(items):
115 self.vcsMultiMenuAddTree.setEnabled(False)
116 for act in standardItems:
117 act.setEnabled(True)
118
119 def showContextMenuDir(self, menu, standardItems):
120 """
121 Slot called before the context menu is shown.
122
123 It enables/disables the VCS menu entries depending on the overall
124 VCS status and the directory status.
125
126 @param menu reference to the menu to be shown
127 @param standardItems array of standard items that need activation/deactivation
128 depending on the overall VCS status
129 """
130 if self.browser.currentItem().data(1) == self.vcs.vcsName():
131 for act in self.vcsDirMenuActions:
132 act.setEnabled(True)
133 for act in self.vcsAddDirMenuActions:
134 act.setEnabled(False)
135 for act in standardItems:
136 act.setEnabled(False)
137 else:
138 for act in self.vcsDirMenuActions:
139 act.setEnabled(False)
140 for act in self.vcsAddDirMenuActions:
141 act.setEnabled(True)
142 for act in standardItems:
143 act.setEnabled(True)
144
145 def showContextMenuDirMulti(self, menu, standardItems):
146 """
147 Slot called before the context menu is shown.
148
149 It enables/disables the VCS menu entries depending on the overall
150 VCS status and the directory status.
151
152 @param menu reference to the menu to be shown
153 @param standardItems array of standard items that need activation/deactivation
154 depending on the overall VCS status
155 """
156 vcsName = self.vcs.vcsName()
157 items = self.browser.getSelectedItems()
158 vcsItems = 0
159 # determine number of selected items under VCS control
160 for itm in items:
161 if itm.data(1) == vcsName:
162 vcsItems += 1
163
164 if vcsItems > 0:
165 if vcsItems != len(items):
166 for act in self.vcsDirMultiMenuActions:
167 act.setEnabled(False)
168 else:
169 for act in self.vcsDirMultiMenuActions:
170 act.setEnabled(True)
171 for act in self.vcsAddDirMultiMenuActions:
172 act.setEnabled(False)
173 for act in standardItems:
174 act.setEnabled(False)
175 else:
176 for act in self.vcsDirMultiMenuActions:
177 act.setEnabled(False)
178 for act in self.vcsAddDirMultiMenuActions:
179 act.setEnabled(True)
180 for act in standardItems:
181 act.setEnabled(True)
182
183 ############################################################################
184 # Protected menu generation methods below
185 ############################################################################
186
187 def _addVCSMenu(self, mainMenu):
188 """
189 Protected method used to add the VCS menu to all project browsers.
190
191 @param mainMenu reference to the menu to be amended
192 """
193 self.vcsMenuActions = []
194 self.vcsAddMenuActions = []
195
196 menu = QMenu(self.trUtf8("Version Control"))
197
198 act = menu.addAction(
199 UI.PixmapCache.getIcon(
200 os.path.join("VcsPlugins", "vcsSubversion", "icons", "subversion.png")),
201 self.vcs.vcsName(), self._VCSInfoDisplay)
202 font = act.font()
203 font.setBold(True)
204 act.setFont(font)
205 menu.addSeparator()
206
207 act = menu.addAction(UI.PixmapCache.getIcon("vcsUpdate.png"),
208 self.trUtf8('Update from repository'), self._VCSUpdate)
209 self.vcsMenuActions.append(act)
210 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"),
211 self.trUtf8('Commit changes to repository...'),
212 self._VCSCommit)
213 self.vcsMenuActions.append(act)
214 menu.addSeparator()
215 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"),
216 self.trUtf8('Add to repository'),
217 self._VCSAdd)
218 self.vcsAddMenuActions.append(act)
219 if 1 in self.browser.specialMenuEntries:
220 self.vcsMenuAddTree = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"),
221 self.trUtf8('Add tree to repository'),
222 self._VCSAddTree)
223 self.vcsAddMenuActions.append(self.vcsMenuAddTree)
224 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"),
225 self.trUtf8('Remove from repository (and disk)'),
226 self._VCSRemove)
227 self.vcsMenuActions.append(act)
228 menu.addSeparator()
229 act = menu.addAction(self.trUtf8('Copy in repository'), self.__SVNCopy)
230 self.vcsMenuActions.append(act)
231 act = menu.addAction(self.trUtf8('Move in repository'), self.__SVNMove)
232 self.vcsMenuActions.append(act)
233 if self.vcs.versionStr >= '1.5.0':
234 menu.addSeparator()
235 act = menu.addAction(self.trUtf8("Add to Changelist"),
236 self.__SVNAddToChangelist)
237 self.vcsMenuActions.append(act)
238 act = menu.addAction(self.trUtf8("Remove from Changelist"),
239 self.__SVNRemoveFromChangelist)
240 self.vcsMenuActions.append(act)
241 menu.addSeparator()
242 act = menu.addAction(UI.PixmapCache.getIcon("vcsLog.png"),
243 self.trUtf8('Show log'), self._VCSLog)
244 self.vcsMenuActions.append(act)
245 if self.vcs.versionStr >= '1.2.0':
246 act = menu.addAction(UI.PixmapCache.getIcon("vcsLog.png"),
247 self.trUtf8('Show limited log'), self.__SVNLogLimited)
248 self.vcsMenuActions.append(act)
249 act = menu.addAction(UI.PixmapCache.getIcon("vcsLog.png"),
250 self.trUtf8('Show log browser'), self.__SVNLogBrowser)
251 self.vcsMenuActions.append(act)
252 menu.addSeparator()
253 act = menu.addAction(UI.PixmapCache.getIcon("vcsStatus.png"),
254 self.trUtf8('Show status'), self._VCSStatus)
255 self.vcsMenuActions.append(act)
256 menu.addSeparator()
257 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"),
258 self.trUtf8('Show difference'), self._VCSDiff)
259 self.vcsMenuActions.append(act)
260 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"),
261 self.trUtf8('Show difference (extended)'),
262 self.__SVNExtendedDiff)
263 self.vcsMenuActions.append(act)
264 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"),
265 self.trUtf8('Show difference (URLs)'),
266 self.__SVNUrlDiff)
267 self.vcsMenuActions.append(act)
268 self.blameAct = menu.addAction(self.trUtf8('Show annotated file'),
269 self.__SVNBlame)
270 self.vcsMenuActions.append(self.blameAct)
271 menu.addSeparator()
272 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"),
273 self.trUtf8('Revert changes'), self._VCSRevert)
274 self.vcsMenuActions.append(act)
275 act = menu.addAction(UI.PixmapCache.getIcon("vcsMerge.png"),
276 self.trUtf8('Merge changes'), self._VCSMerge)
277 self.vcsMenuActions.append(act)
278 act = menu.addAction(self.trUtf8('Resolve conflict'), self.__SVNResolve)
279 self.vcsMenuActions.append(act)
280 if self.vcs.versionStr >= '1.2.0':
281 menu.addSeparator()
282 act = menu.addAction(UI.PixmapCache.getIcon("vcsLock.png"),
283 self.trUtf8('Lock'), self.__SVNLock)
284 self.vcsMenuActions.append(act)
285 act = menu.addAction(UI.PixmapCache.getIcon("vcsUnlock.png"),
286 self.trUtf8('Unlock'), self.__SVNUnlock)
287 self.vcsMenuActions.append(act)
288 act = menu.addAction(UI.PixmapCache.getIcon("vcsUnlock.png"),
289 self.trUtf8('Break Lock'), self.__SVNBreakLock)
290 self.vcsMenuActions.append(act)
291 act = menu.addAction(UI.PixmapCache.getIcon("vcsUnlock.png"),
292 self.trUtf8('Steal Lock'), self.__SVNStealLock)
293 self.vcsMenuActions.append(act)
294 menu.addSeparator()
295 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp)
296 self.vcsMenuActions.append(act)
297 act = menu.addAction(self.trUtf8('List Properties'), self.__SVNListProps)
298 self.vcsMenuActions.append(act)
299 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp)
300 self.vcsMenuActions.append(act)
301 menu.addSeparator()
302 menu.addAction(self.trUtf8('Select all local file entries'),
303 self.browser.selectLocalEntries)
304 menu.addAction(self.trUtf8('Select all versioned file entries'),
305 self.browser.selectVCSEntries)
306 menu.addAction(self.trUtf8('Select all local directory entries'),
307 self.browser.selectLocalDirEntries)
308 menu.addAction(self.trUtf8('Select all versioned directory entries'),
309 self.browser.selectVCSDirEntries)
310 menu.addSeparator()
311 menu.addAction(self.trUtf8("Configure..."), self.__SVNConfigure)
312
313 mainMenu.addSeparator()
314 mainMenu.addMenu(menu)
315 self.menu = menu
316
317 def _addVCSMenuMulti(self, mainMenu):
318 """
319 Protected method used to add the VCS menu for multi selection to all
320 project browsers.
321
322 @param mainMenu reference to the menu to be amended
323 """
324 self.vcsMultiMenuActions = []
325 self.vcsAddMultiMenuActions = []
326
327 menu = QMenu(self.trUtf8("Version Control"))
328
329 act = menu.addAction(
330 UI.PixmapCache.getIcon(
331 os.path.join("VcsPlugins", "vcsSubversion", "icons", "subversion.png")),
332 self.vcs.vcsName(), self._VCSInfoDisplay)
333 font = act.font()
334 font.setBold(True)
335 act.setFont(font)
336 menu.addSeparator()
337
338 act = menu.addAction(UI.PixmapCache.getIcon("vcsUpdate.png"),
339 self.trUtf8('Update from repository'), self._VCSUpdate)
340 self.vcsMultiMenuActions.append(act)
341 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"),
342 self.trUtf8('Commit changes to repository...'),
343 self._VCSCommit)
344 self.vcsMultiMenuActions.append(act)
345 menu.addSeparator()
346 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"),
347 self.trUtf8('Add to repository'), self._VCSAdd)
348 self.vcsAddMultiMenuActions.append(act)
349 if 1 in self.browser.specialMenuEntries:
350 self.vcsMultiMenuAddTree = \
351 menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"),
352 self.trUtf8('Add tree to repository'), self._VCSAddTree)
353 self.vcsAddMultiMenuActions.append(self.vcsMultiMenuAddTree)
354 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"),
355 self.trUtf8('Remove from repository (and disk)'),
356 self._VCSRemove)
357 self.vcsMultiMenuActions.append(act)
358 self.vcsRemoveMultiMenuItem = act
359 if self.vcs.versionStr >= '1.5.0':
360 menu.addSeparator()
361 act = menu.addAction(self.trUtf8("Add to Changelist"),
362 self.__SVNAddToChangelist)
363 self.vcsMenuActions.append(act)
364 act = menu.addAction(self.trUtf8("Remove from Changelist"),
365 self.__SVNRemoveFromChangelist)
366 self.vcsMenuActions.append(act)
367 menu.addSeparator()
368 act = menu.addAction(UI.PixmapCache.getIcon("vcsStatus.png"),
369 self.trUtf8('Show status'), self._VCSStatus)
370 self.vcsMultiMenuActions.append(act)
371 menu.addSeparator()
372 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"),
373 self.trUtf8('Show difference'), self._VCSDiff)
374 self.vcsMultiMenuActions.append(act)
375 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"),
376 self.trUtf8('Show difference (extended)'),
377 self.__SVNExtendedDiff)
378 self.vcsMultiMenuActions.append(act)
379 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"),
380 self.trUtf8('Show difference (URLs)'),
381 self.__SVNUrlDiff)
382 self.vcsMultiMenuActions.append(act)
383 menu.addSeparator()
384 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"),
385 self.trUtf8('Revert changes'), self._VCSRevert)
386 self.vcsMultiMenuActions.append(act)
387 act = menu.addAction(self.trUtf8('Resolve conflict'), self.__SVNResolve)
388 self.vcsMultiMenuActions.append(act)
389 if self.vcs.versionStr >= '1.2.0':
390 menu.addSeparator()
391 act = menu.addAction(UI.PixmapCache.getIcon("vcsLock.png"),
392 self.trUtf8('Lock'), self.__SVNLock)
393 self.vcsMultiMenuActions.append(act)
394 act = menu.addAction(UI.PixmapCache.getIcon("vcsUnlock.png"),
395 self.trUtf8('Unlock'), self.__SVNUnlock)
396 self.vcsMultiMenuActions.append(act)
397 act = menu.addAction(UI.PixmapCache.getIcon("vcsUnlock.png"),
398 self.trUtf8('Break Lock'), self.__SVNBreakLock)
399 self.vcsMultiMenuActions.append(act)
400 act = menu.addAction(UI.PixmapCache.getIcon("vcsUnlock.png"),
401 self.trUtf8('Steal Lock'), self.__SVNStealLock)
402 self.vcsMultiMenuActions.append(act)
403 menu.addSeparator()
404 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp)
405 self.vcsMultiMenuActions.append(act)
406 act = menu.addAction(self.trUtf8('List Properties'), self.__SVNListProps)
407 self.vcsMultiMenuActions.append(act)
408 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp)
409 self.vcsMultiMenuActions.append(act)
410 menu.addSeparator()
411 menu.addAction(self.trUtf8('Select all local file entries'),
412 self.browser.selectLocalEntries)
413 menu.addAction(self.trUtf8('Select all versioned file entries'),
414 self.browser.selectVCSEntries)
415 menu.addAction(self.trUtf8('Select all local directory entries'),
416 self.browser.selectLocalDirEntries)
417 menu.addAction(self.trUtf8('Select all versioned directory entries'),
418 self.browser.selectVCSDirEntries)
419 menu.addSeparator()
420 menu.addAction(self.trUtf8("Configure..."), self.__SVNConfigure)
421
422 mainMenu.addSeparator()
423 mainMenu.addMenu(menu)
424 self.menuMulti = menu
425
426 def _addVCSMenuBack(self, mainMenu):
427 """
428 Protected method used to add the VCS menu to all project browsers.
429
430 @param mainMenu reference to the menu to be amended
431 """
432 menu = QMenu(self.trUtf8("Version Control"))
433
434 act = menu.addAction(
435 UI.PixmapCache.getIcon(
436 os.path.join("VcsPlugins", "vcsSubversion", "icons", "subversion.png")),
437 self.vcs.vcsName(), self._VCSInfoDisplay)
438 font = act.font()
439 font.setBold(True)
440 act.setFont(font)
441 menu.addSeparator()
442
443 menu.addAction(self.trUtf8('Select all local file entries'),
444 self.browser.selectLocalEntries)
445 menu.addAction(self.trUtf8('Select all versioned file entries'),
446 self.browser.selectVCSEntries)
447 menu.addAction(self.trUtf8('Select all local directory entries'),
448 self.browser.selectLocalDirEntries)
449 menu.addAction(self.trUtf8('Select all versioned directory entries'),
450 self.browser.selectVCSDirEntries)
451 menu.addSeparator()
452 menu.addAction(self.trUtf8("Configure..."), self.__SVNConfigure)
453
454 mainMenu.addSeparator()
455 mainMenu.addMenu(menu)
456 self.menuBack = menu
457
458 def _addVCSMenuDir(self, mainMenu):
459 """
460 Protected method used to add the VCS menu to all project browsers.
461
462 @param mainMenu reference to the menu to be amended
463 """
464 if mainMenu is None:
465 return
466
467 self.vcsDirMenuActions = []
468 self.vcsAddDirMenuActions = []
469
470 menu = QMenu(self.trUtf8("Version Control"))
471
472 act = menu.addAction(
473 UI.PixmapCache.getIcon(
474 os.path.join("VcsPlugins", "vcsSubversion", "icons", "subversion.png")),
475 self.vcs.vcsName(), self._VCSInfoDisplay)
476 font = act.font()
477 font.setBold(True)
478 act.setFont(font)
479 menu.addSeparator()
480
481 act = menu.addAction(UI.PixmapCache.getIcon("vcsUpdate.png"),
482 self.trUtf8('Update from repository'), self._VCSUpdate)
483 self.vcsDirMenuActions.append(act)
484 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"),
485 self.trUtf8('Commit changes to repository...'),
486 self._VCSCommit)
487 self.vcsDirMenuActions.append(act)
488 menu.addSeparator()
489 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"),
490 self.trUtf8('Add to repository'), self._VCSAdd)
491 self.vcsAddDirMenuActions.append(act)
492 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"),
493 self.trUtf8('Remove from repository (and disk)'),
494 self._VCSRemove)
495 self.vcsDirMenuActions.append(act)
496 menu.addSeparator()
497 act = menu.addAction(self.trUtf8('Copy in repository'), self.__SVNCopy)
498 self.vcsDirMenuActions.append(act)
499 act = menu.addAction(self.trUtf8('Move in repository'), self.__SVNMove)
500 self.vcsDirMenuActions.append(act)
501 if self.vcs.versionStr >= '1.5.0':
502 menu.addSeparator()
503 act = menu.addAction(self.trUtf8("Add to Changelist"),
504 self.__SVNAddToChangelist)
505 self.vcsMenuActions.append(act)
506 act = menu.addAction(self.trUtf8("Remove from Changelist"),
507 self.__SVNRemoveFromChangelist)
508 self.vcsMenuActions.append(act)
509 menu.addSeparator()
510 act = menu.addAction(UI.PixmapCache.getIcon("vcsLog.png"),
511 self.trUtf8('Show log'), self._VCSLog)
512 self.vcsDirMenuActions.append(act)
513 if self.vcs.versionStr >= '1.2.0':
514 act = menu.addAction(UI.PixmapCache.getIcon("vcsLog.png"),
515 self.trUtf8('Show limited log'), self.__SVNLogLimited)
516 self.vcsDirMenuActions.append(act)
517 act = menu.addAction(UI.PixmapCache.getIcon("vcsLog.png"),
518 self.trUtf8('Show log browser'), self.__SVNLogBrowser)
519 self.vcsDirMenuActions.append(act)
520 menu.addSeparator()
521 act = menu.addAction(UI.PixmapCache.getIcon("vcsStatus.png"),
522 self.trUtf8('Show status'), self._VCSStatus)
523 self.vcsDirMenuActions.append(act)
524 menu.addSeparator()
525 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"),
526 self.trUtf8('Show difference'), self._VCSDiff)
527 self.vcsDirMenuActions.append(act)
528 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"),
529 self.trUtf8('Show difference (extended)'),
530 self.__SVNExtendedDiff)
531 self.vcsDirMenuActions.append(act)
532 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"),
533 self.trUtf8('Show difference (URLs)'),
534 self.__SVNUrlDiff)
535 self.vcsDirMenuActions.append(act)
536 menu.addSeparator()
537 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"),
538 self.trUtf8('Revert changes'), self._VCSRevert)
539 self.vcsDirMenuActions.append(act)
540 act = menu.addAction(UI.PixmapCache.getIcon("vcsMerge.png"),
541 self.trUtf8('Merge changes'), self._VCSMerge)
542 self.vcsDirMenuActions.append(act)
543 act = menu.addAction(self.trUtf8('Resolve conflict'), self.__SVNResolve)
544 self.vcsDirMenuActions.append(act)
545 menu.addSeparator()
546 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp)
547 self.vcsDirMenuActions.append(act)
548 act = menu.addAction(self.trUtf8('List Properties'), self.__SVNListProps)
549 self.vcsDirMenuActions.append(act)
550 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp)
551 self.vcsDirMenuActions.append(act)
552 menu.addSeparator()
553 menu.addAction(self.trUtf8('Select all local file entries'),
554 self.browser.selectLocalEntries)
555 menu.addAction(self.trUtf8('Select all versioned file entries'),
556 self.browser.selectVCSEntries)
557 menu.addAction(self.trUtf8('Select all local directory entries'),
558 self.browser.selectLocalDirEntries)
559 menu.addAction(self.trUtf8('Select all versioned directory entries'),
560 self.browser.selectVCSDirEntries)
561 menu.addSeparator()
562 menu.addAction(self.trUtf8("Configure..."), self.__SVNConfigure)
563
564 mainMenu.addSeparator()
565 mainMenu.addMenu(menu)
566 self.menuDir = menu
567
568 def _addVCSMenuDirMulti(self, mainMenu):
569 """
570 Protected method used to add the VCS menu to all project browsers.
571
572 @param mainMenu reference to the menu to be amended
573 """
574 if mainMenu is None:
575 return
576
577 self.vcsDirMultiMenuActions = []
578 self.vcsAddDirMultiMenuActions = []
579
580 menu = QMenu(self.trUtf8("Version Control"))
581
582 act = menu.addAction(
583 UI.PixmapCache.getIcon(
584 os.path.join("VcsPlugins", "vcsSubversion", "icons", "subversion.png")),
585 self.vcs.vcsName(), self._VCSInfoDisplay)
586 font = act.font()
587 font.setBold(True)
588 act.setFont(font)
589 menu.addSeparator()
590
591 act = menu.addAction(UI.PixmapCache.getIcon("vcsUpdate.png"),
592 self.trUtf8('Update from repository'), self._VCSUpdate)
593 self.vcsDirMultiMenuActions.append(act)
594 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"),
595 self.trUtf8('Commit changes to repository...'),
596 self._VCSCommit)
597 self.vcsDirMultiMenuActions.append(act)
598 menu.addSeparator()
599 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"),
600 self.trUtf8('Add to repository'), self._VCSAdd)
601 self.vcsAddDirMultiMenuActions.append(act)
602 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"),
603 self.trUtf8('Remove from repository (and disk)'),
604 self._VCSRemove)
605 self.vcsDirMultiMenuActions.append(act)
606 if self.vcs.versionStr >= '1.5.0':
607 menu.addSeparator()
608 act = menu.addAction(self.trUtf8("Add to Changelist"),
609 self.__SVNAddToChangelist)
610 self.vcsMenuActions.append(act)
611 act = menu.addAction(self.trUtf8("Remove from Changelist"),
612 self.__SVNRemoveFromChangelist)
613 self.vcsMenuActions.append(act)
614 menu.addSeparator()
615 act = menu.addAction(UI.PixmapCache.getIcon("vcsStatus.png"),
616 self.trUtf8('Show status'), self._VCSStatus)
617 self.vcsDirMultiMenuActions.append(act)
618 menu.addSeparator()
619 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"),
620 self.trUtf8('Show difference'), self._VCSDiff)
621 self.vcsDirMultiMenuActions.append(act)
622 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"),
623 self.trUtf8('Show difference (extended)'),
624 self.__SVNExtendedDiff)
625 self.vcsDirMultiMenuActions.append(act)
626 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"),
627 self.trUtf8('Show difference (URLs)'),
628 self.__SVNUrlDiff)
629 self.vcsDirMultiMenuActions.append(act)
630 menu.addSeparator()
631 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"),
632 self.trUtf8('Revert changes'), self._VCSRevert)
633 self.vcsDirMenuActions.append(act)
634 act = menu.addAction(UI.PixmapCache.getIcon("vcsMerge.png"),
635 self.trUtf8('Merge changes'), self._VCSMerge)
636 self.vcsDirMenuActions.append(act)
637 act = menu.addAction(self.trUtf8('Resolve conflict'), self.__SVNResolve)
638 self.vcsDirMultiMenuActions.append(act)
639 menu.addSeparator()
640 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp)
641 self.vcsDirMultiMenuActions.append(act)
642 act = menu.addAction(self.trUtf8('List Properties'), self.__SVNListProps)
643 self.vcsDirMultiMenuActions.append(act)
644 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp)
645 self.vcsDirMultiMenuActions.append(act)
646 menu.addSeparator()
647 menu.addAction(self.trUtf8('Select all local file entries'),
648 self.browser.selectLocalEntries)
649 menu.addAction(self.trUtf8('Select all versioned file entries'),
650 self.browser.selectVCSEntries)
651 menu.addAction(self.trUtf8('Select all local directory entries'),
652 self.browser.selectLocalDirEntries)
653 menu.addAction(self.trUtf8('Select all versioned directory entries'),
654 self.browser.selectVCSDirEntries)
655 menu.addSeparator()
656 menu.addAction(self.trUtf8("Configure..."), self.__SVNConfigure)
657
658 mainMenu.addSeparator()
659 mainMenu.addMenu(menu)
660 self.menuDirMulti = menu
661
662 ############################################################################
663 # Menu handling methods below
664 ############################################################################
665
666 def __SVNCopy(self):
667 """
668 Private slot called by the context menu to copy the selected file.
669 """
670 itm = self.browser.currentItem()
671 try:
672 fn = itm.fileName()
673 except AttributeError:
674 fn = itm.dirName()
675 self.vcs.svnCopy(fn, self.project)
676
677 def __SVNMove(self):
678 """
679 Private slot called by the context menu to move the selected file.
680 """
681 itm = self.browser.currentItem()
682 try:
683 fn = itm.fileName()
684 except AttributeError:
685 fn = itm.dirName()
686 isFile = os.path.isfile(fn)
687 movefiles = self.browser.project.getFiles(fn)
688 if self.vcs.vcsMove(fn, self.project):
689 if isFile:
690 self.browser.emit(SIGNAL('closeSourceWindow'), fn)
691 else:
692 for mf in movefiles:
693 self.browser.emit(SIGNAL('closeSourceWindow'), mf)
694
695 def __SVNResolve(self):
696 """
697 Private slot called by the context menu to resolve conflicts of a file.
698 """
699 names = []
700 for itm in self.browser.getSelectedItems():
701 try:
702 names.append(itm.fileName())
703 except AttributeError:
704 names.append(itm.dirName())
705 self.vcs.svnResolve(names)
706
707 def __SVNListProps(self):
708 """
709 Private slot called by the context menu to list the subversion properties of
710 a file.
711 """
712 names = []
713 for itm in self.browser.getSelectedItems():
714 try:
715 names.append(itm.fileName())
716 except AttributeError:
717 names.append(itm.dirName())
718 self.vcs.svnListProps(names)
719
720 def __SVNSetProp(self):
721 """
722 Private slot called by the context menu to set a subversion property of a file.
723 """
724 names = []
725 for itm in self.browser.getSelectedItems():
726 try:
727 names.append(itm.fileName())
728 except AttributeError:
729 names.append(itm.dirName())
730 self.vcs.svnSetProp(names)
731
732 def __SVNDelProp(self):
733 """
734 Private slot called by the context menu to delete a subversion property of a file.
735 """
736 names = []
737 for itm in self.browser.getSelectedItems():
738 try:
739 names.append(itm.fileName())
740 except AttributeError:
741 names.append(itm.dirName())
742 self.vcs.svnDelProp(names)
743
744 def __SVNExtendedDiff(self):
745 """
746 Private slot called by the context menu to show the difference of a file to
747 the repository.
748
749 This gives the chance to enter the revisions to compare.
750 """
751 names = []
752 for itm in self.browser.getSelectedItems():
753 try:
754 names.append(itm.fileName())
755 except AttributeError:
756 names.append(itm.dirName())
757 self.vcs.svnExtendedDiff(names)
758
759 def __SVNUrlDiff(self):
760 """
761 Private slot called by the context menu to show the difference of a file of
762 two repository URLs.
763
764 This gives the chance to enter the repository URLs to compare.
765 """
766 names = []
767 for itm in self.browser.getSelectedItems():
768 try:
769 names.append(itm.fileName())
770 except AttributeError:
771 names.append(itm.dirName())
772 self.vcs.svnUrlDiff(names)
773
774 def __SVNLogLimited(self):
775 """
776 Private slot called by the context menu to show the limited log of a file.
777 """
778 itm = self.browser.currentItem()
779 try:
780 fn = itm.fileName()
781 except AttributeError:
782 fn = itm.dirName()
783 self.vcs.svnLogLimited(fn)
784
785 def __SVNLogBrowser(self):
786 """
787 Private slot called by the context menu to show the log browser for a file.
788 """
789 itm = self.browser.currentItem()
790 try:
791 fn = itm.fileName()
792 except AttributeError:
793 fn = itm.dirName()
794 self.vcs.svnLogBrowser(fn)
795
796 def __SVNBlame(self):
797 """
798 Private slot called by the context menu to show the blame of a file.
799 """
800 itm = self.browser.currentItem()
801 fn = itm.fileName()
802 self.vcs.svnBlame(fn)
803
804 def __SVNLock(self):
805 """
806 Private slot called by the context menu to lock files in the repository.
807 """
808 names = []
809 for itm in self.browser.getSelectedItems():
810 try:
811 names.append(itm.fileName())
812 except AttributeError:
813 names.append(itm.dirName())
814 self.vcs.svnLock(names)
815
816 def __SVNUnlock(self):
817 """
818 Private slot called by the context menu to unlock files in the repository.
819 """
820 names = []
821 for itm in self.browser.getSelectedItems():
822 try:
823 names.append(itm.fileName())
824 except AttributeError:
825 names.append(itm.dirName())
826 self.vcs.svnUnlock(names)
827
828 def __SVNBreakLock(self):
829 """
830 Private slot called by the context menu to break lock files in the repository.
831 """
832 names = []
833 for itm in self.browser.getSelectedItems():
834 try:
835 names.append(itm.fileName())
836 except AttributeError:
837 names.append(itm.dirName())
838 self.vcs.svnUnlock(names, breakIt = True)
839
840 def __SVNStealLock(self):
841 """
842 Private slot called by the context menu to steal lock files in the repository.
843 """
844 names = []
845 for itm in self.browser.getSelectedItems():
846 try:
847 names.append(itm.fileName())
848 except AttributeError:
849 names.append(itm.dirName())
850 self.vcs.svnLock(names, stealIt = True)
851
852 def __SVNConfigure(self):
853 """
854 Private method to open the configuration dialog.
855 """
856 e4App().getObject("UserInterface").showPreferences("zzz_subversionPage")
857
858 def __SVNAddToChangelist(self):
859 """
860 Private slot called by the context menu to add files to a changelist.
861 """
862 names = []
863 for itm in self.browser.getSelectedItems():
864 try:
865 names.append(itm.fileName())
866 except AttributeError:
867 names.append(itm.dirName())
868 self.vcs.svnAddToChangelist(names)
869
870 def __SVNRemoveFromChangelist(self):
871 """
872 Private slot called by the context menu to remove files from their changelist.
873 """
874 names = []
875 for itm in self.browser.getSelectedItems():
876 try:
877 names.append(itm.fileName())
878 except AttributeError:
879 names.append(itm.dirName())
880 self.vcs.svnRemoveFromChangelist(names)
881
882 ############################################################################
883 # Some private utility methods below
884 ############################################################################
885
886 def __itemsHaveFiles(self, items):
887 """
888 Private method to check, if items contain file type items.
889
890 @param items items to check (list of QTreeWidgetItems)
891 @return flag indicating items contain file type items (boolean)
892 """
893 for itm in items:
894 if isinstance(itm, ProjectBrowserFileItem):
895 return True
896 return False

eric ide

mercurial