PageRenderTime 25ms CodeModel.GetById 19ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tortoisehg/hgqt/qdelete.py

https://bitbucket.org/tortoisehg/hgtk/
Python | 61 lines | 43 code | 12 blank | 6 comment | 1 complexity | 1a311e3c3259fb0c645eb9ba7c2e257e MD5 | raw file
 1# qdelete.py - QDelete dialog for TortoiseHg
 2#
 3# Copyright 2010 Steve Borho <steve@borho.org>
 4#
 5# This software may be used and distributed according to the terms of the
 6# GNU General Public License version 2, incorporated herein by reference.
 7
 8import os
 9
10from PyQt4.QtCore import *
11from PyQt4.QtGui import *
12
13from tortoisehg.util import hglib
14from tortoisehg.hgqt.i18n import _
15from tortoisehg.hgqt import cmdui
16
17class QDeleteDialog(QDialog):
18    output = pyqtSignal(QString, QString)
19    makeLogVisible = pyqtSignal(bool)
20
21    def __init__(self, repo, patches, parent):
22        super(QDeleteDialog, self).__init__(parent)
23        self.setWindowTitle(_('Patch remove - %s') % repo.displayname)
24
25        f = self.windowFlags()
26        self.setWindowFlags(f & ~Qt.WindowContextHelpButtonHint)
27        self.repo = repo
28        self.patches = patches
29
30        self.setLayout(QVBoxLayout())
31
32        lbl = QLabel(_('<b>Remove patches from queue?<ul><li>%s</ul></b>') %
33                     '<li>'.join(patches))
34        self.layout().addWidget(lbl)
35
36        self.keepchk = QCheckBox(_('Keep patch files'))
37        self.keepchk.setChecked(True)
38        self.layout().addWidget(self.keepchk)
39
40        self.cmd = cmdui.Runner()
41        self.cmd.output.connect(self.output)
42        self.cmd.makeLogVisible.connect(self.makeLogVisible)
43
44        BB = QDialogButtonBox
45        bbox = QDialogButtonBox(BB.Ok|BB.Cancel)
46        bbox.accepted.connect(self.accept)
47        bbox.rejected.connect(self.reject)
48        self.layout().addWidget(bbox)
49        self.bbox = bbox
50
51    def accept(self):
52        def finished(ret):
53            self.repo.decrementBusyCount()
54            self.reject()
55        cmdline = ['qdelete', '--repository', self.repo.root]
56        if self.keepchk.isChecked():
57            cmdline += ['--keep']
58        cmdline += self.patches
59        self.repo.incrementBusyCount()
60        self.cmd.commandFinished.connect(finished)
61        self.cmd.run(cmdline)