Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesRenamePatchDialog.py

changeset 1035
2cd7817ac659
child 1131
7781e396c903
equal deleted inserted replaced
1034:8a7fa049e9d3 1035:2cd7817ac659
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the data to rename a patch.
8 """
9
10 from PyQt4.QtCore import pyqtSlot
11 from PyQt4.QtGui import QDialog, QDialogButtonBox
12
13 from .Ui_HgQueuesRenamePatchDialog import Ui_HgQueuesRenamePatchDialog
14
15
16 class HgQueuesRenamePatchDialog(QDialog, Ui_HgQueuesRenamePatchDialog):
17 """
18 Class implementing a dialog to enter the data to rename a patch.
19 """
20 def __init__(self, currentPatch, patchesList, parent=None):
21 """
22 Constructor
23
24 @param currentPatch name of the current patch (string)
25 @param patchesList list of patches to select from (list of strings)
26 @param parent reference to the parent widget (QWidget)
27 """
28 QDialog.__init__(self, parent)
29 self.setupUi(self)
30
31 self.currentButton.setText(
32 self.trUtf8("Current Patch ({0})").format(currentPatch))
33 self.nameCombo.addItems([""] + patchesList)
34
35 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
36
37 def __updateUI(self):
38 """
39 Private slot to update the UI.
40 """
41 enable = self.nameEdit.text() != ""
42 if self.namedButton.isChecked():
43 enable = enable and self.nameCombo.currentText() != ""
44
45 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
46
47 @pyqtSlot(str)
48 def on_nameEdit_textChanged(self, txt):
49 """
50 Private slot to handle changes of the new name.
51
52 @param txt text of the edit (string)
53 """
54 self.__updateUI()
55
56 @pyqtSlot(bool)
57 def on_namedButton_toggled(self, checked):
58 """
59 Private slot to handle changes of the selection method.
60
61 @param checked state of the check box (boolean)
62 """
63 self.__updateUI()
64
65 @pyqtSlot(str)
66 def on_nameCombo_currentIndexChanged(self, txt):
67 """
68 Private slot to handle changes of the selected patch name.
69
70 @param txt selected patch name (string)
71 """
72 self.__updateUI()
73
74 def getData(self):
75 """
76 Public method to retrieve the entered data.
77
78 @return tuple of new name and selected patch (string, string)
79 """
80 selectedPatch = ""
81 if self.namedButton.isChecked():
82 selectedPatch = self.nameCombo.currentText()
83
84 return self.nameEdit.text(), selectedPatch

eric ide

mercurial