'Create the context menu for the diff display.'

def contextMenuEvent(self, event):

    menu = qtutils.create_menu(N_(u'Actions'), self)
    s = selection.selection()
    filename = selection.filename()
    if (self.model.stageable() or self.model.unstageable()):
        if self.model.stageable():
            self.stage_or_unstage.setText(N_(u'Stage'))
        else:
            self.stage_or_unstage.setText(N_(u'Unstage'))
        menu.addAction(self.stage_or_unstage)
    if (s.modified and self.model.stageable()):
        if (s.modified[0] in main.model().submodules):
            action = menu.addAction(icons.add(), cmds.Stage.name(), cmds.run(cmds.Stage, s.modified))
            action.setShortcut(hotkeys.STAGE_SELECTION)
            menu.addAction(icons.cola(), N_(u'Launch    git-cola'), cmds.run(cmds.OpenRepo, core.abspath(s.modified[0])))
        elif (s.modified[0] not in main.model().unstaged_deleted):
            if self.has_selection():
                apply_text = N_(u'Stage    Selected    Lines')
                revert_text = N_(u'Revert    Selected    Lines...')
            else:
                apply_text = N_(u'Stage    Diff    Hunk')
                revert_text = N_(u'Revert    Diff    Hunk...')
            self.action_apply_selection.setText(apply_text)
            self.action_apply_selection.setIcon(icons.add())
            self.action_revert_selection.setText(revert_text)
            menu.addAction(self.action_apply_selection)
            menu.addAction(self.action_revert_selection)
    if (s.staged and self.model.unstageable()):
        if (s.staged[0] in main.model().submodules):
            action = menu.addAction(icons.remove(), cmds.Unstage.name(), cmds.do(cmds.Unstage, s.staged))
            action.setShortcut(hotkeys.STAGE_SELECTION)
            menu.addAction(icons.cola(), N_(u'Launch    git-cola'), cmds.do(cmds.OpenRepo, core.abspath(s.staged[0])))
        elif (s.staged[0] not in main.model().staged_deleted):
            if self.has_selection():
                apply_text = N_(u'Unstage    Selected    Lines')
            else:
                apply_text = N_(u'Unstage    Diff    Hunk')
            self.action_apply_selection.setText(apply_text)
            self.action_apply_selection.setIcon(icons.remove())
            menu.addAction(self.action_apply_selection)
    if (self.model.stageable() or self.model.unstageable()):
        if (filename and core.exists(filename)):
            menu.addSeparator()
            menu.addAction(self.launch_editor)
        menu.addAction(self.launch_difftool)
    menu.addSeparator()
    menu.addAction(self.move_up)
    menu.addAction(self.move_down)
    menu.addSeparator()
    action = menu.addAction(icons.copy(), N_(u'Copy'), self.copy)
    action.setShortcut(QtGui.QKeySequence.Copy)
    action = menu.addAction(icons.select_all(), N_(u'Select    All'), self.selectAll)
    action.setShortcut(QtGui.QKeySequence.SelectAll)
    menu.exec_(self.mapToGlobal(event.pos()))
