Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0.3, 2.0.4, and 2.0.5

stable filelistview: Show a different context menu for subrepos and regular files

Currently the context menu for subrepos is empty (i.e. no context menu). The
patch has been tested with a dummy context menu and it works (i.e. it shows
the dummy context menu).

Proper subrepo context menu items will be added in a future patch.
This patch requries accessing ctx.substate each time that the context menu is
triggered. I assume that the cost should be negligible since ctx.substate must
have been populated earlier on when the file list was generated.

Changeset 3a221b088500

Parent d61d96a823d8

by Angel Ezquerra

Changes to one file · Browse files at 3a221b088500 Showing diff from parent d61d96a823d8 Diff from another changeset...

 
19
20
21
22
 
23
24
25
 
32
33
34
35
 
 
36
37
38
 
255
256
257
258
259
260
261
 
 
 
 
 
 
 
 
 
 
 
 
262
263
 
264
265
266
 
 
267
268
269
 
19
20
21
 
22
23
24
25
 
32
33
34
 
35
36
37
38
39
 
256
257
258
 
 
 
 
259
260
261
262
263
264
265
266
267
268
269
270
271
 
272
273
 
 
274
275
276
277
278
@@ -19,7 +19,7 @@
 from tortoisehg.util import hglib  from tortoisehg.hgqt.i18n import _  from tortoisehg.hgqt import qtlib -from tortoisehg.hgqt.filedialogs import FileLogDialog, FileDiffDialog +from tortoisehg.hgqt.filedialogs import FileLogDialog, FileDiffDialog  from tortoisehg.hgqt import visdiff, wctxactions, revert    from PyQt4.QtCore import * @@ -32,7 +32,8 @@
    fileRevSelected = pyqtSignal(object, object, object)   clearDisplay = pyqtSignal() - contextmenu = None + filecontextmenu = None + subrepocontextmenu = None     def __init__(self, parent=None):   QTableView.__init__(self, parent) @@ -255,15 +256,23 @@
  self.addAction(act)     def contextMenuEvent(self, event): - if not self.contextmenu: - self.contextmenu = QMenu(self) - for act in ['diff', 'ldiff', 'edit', 'ledit', 'revert', - 'navigate', 'diffnavigate']: + itemissubrepo = self.currentFile() in self.model()._ctx.substate.keys() + # Subrepos and regular items have different context menus + if itemissubrepo: + contextmenu = self.subrepocontextmenu + actionlist = [] + else: + contextmenu = self.filecontextmenu + actionlist = ['diff', 'ldiff', 'edit', 'ledit', 'revert', + 'navigate', 'diffnavigate'] + if not contextmenu: + contextmenu = QMenu(self) + for act in actionlist:   if act: - self.contextmenu.addAction(self._actions[act]) + contextmenu.addAction(self._actions[act])   else: - self.contextmenu.addSeparator() - self.contextmenu.exec_(event.globalPos()) + contextmenu.addSeparator() + contextmenu.exec_(event.globalPos())     def resizeEvent(self, event):   if self.model() is not None: