38 @param parent reference to the parent widget |
47 @param parent reference to the parent widget |
39 @type QWidget |
48 @type QWidget |
40 """ |
49 """ |
41 RefactoringDialogBase.__init__(self, refactoring, title, parent) |
50 RefactoringDialogBase.__init__(self, refactoring, title, parent) |
42 self.setupUi(self) |
51 self.setupUi(self) |
43 |
52 |
44 self._changeGroupName = "Extract" |
53 self._changeGroupName = "Extract" |
45 |
54 |
46 self.__filename = filename |
55 self.__filename = filename |
47 self.__startOffset = startOffset |
56 self.__startOffset = startOffset |
48 self.__endOffset = endOffset |
57 self.__endOffset = endOffset |
49 self.__extractionType = extractionType |
58 self.__extractionType = extractionType |
50 |
59 |
51 self.__okButton = self.buttonBox.button( |
60 self.__okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok) |
52 QDialogButtonBox.StandardButton.Ok) |
|
53 self.__okButton.setEnabled(False) |
61 self.__okButton.setEnabled(False) |
54 self.__previewButton = self.buttonBox.addButton( |
62 self.__previewButton = self.buttonBox.addButton( |
55 self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole) |
63 self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole |
|
64 ) |
56 self.__previewButton.setDefault(True) |
65 self.__previewButton.setDefault(True) |
57 self.__previewButton.setEnabled(False) |
66 self.__previewButton.setEnabled(False) |
58 |
67 |
59 msh = self.minimumSizeHint() |
68 msh = self.minimumSizeHint() |
60 self.resize(max(self.width(), msh.width()), msh.height()) |
69 self.resize(max(self.width(), msh.width()), msh.height()) |
61 |
70 |
62 @pyqtSlot(str) |
71 @pyqtSlot(str) |
63 def on_newNameEdit_textChanged(self, text): |
72 def on_newNameEdit_textChanged(self, text): |
64 """ |
73 """ |
65 Private slot to react to changes of the new name. |
74 Private slot to react to changes of the new name. |
66 |
75 |
67 @param text text entered into the edit |
76 @param text text entered into the edit |
68 @type str |
77 @type str |
69 """ |
78 """ |
70 self.__okButton.setEnabled(text != "") |
79 self.__okButton.setEnabled(text != "") |
71 self.__previewButton.setEnabled(text != "") |
80 self.__previewButton.setEnabled(text != "") |
72 |
81 |
73 @pyqtSlot(QAbstractButton) |
82 @pyqtSlot(QAbstractButton) |
74 def on_buttonBox_clicked(self, button): |
83 def on_buttonBox_clicked(self, button): |
75 """ |
84 """ |
76 Private slot to act on the button pressed. |
85 Private slot to act on the button pressed. |
77 |
86 |
78 @param button reference to the button pressed |
87 @param button reference to the button pressed |
79 @type QAbstractButton |
88 @type QAbstractButton |
80 """ |
89 """ |
81 if button == self.__previewButton: |
90 if button == self.__previewButton: |
82 self.requestPreview() |
91 self.requestPreview() |
83 elif button == self.__okButton: |
92 elif button == self.__okButton: |
84 self.applyChanges() |
93 self.applyChanges() |
85 |
94 |
86 def _calculateChanges(self): |
95 def _calculateChanges(self): |
87 """ |
96 """ |
88 Protected method to calculate the changes. |
97 Protected method to calculate the changes. |
89 """ |
98 """ |
90 self._refactoring.sendJson("CalculateExtractChanges", { |
99 self._refactoring.sendJson( |
91 "ChangeGroup": self._changeGroupName, |
100 "CalculateExtractChanges", |
92 "Title": self._title, |
101 { |
93 "FileName": self.__filename, |
102 "ChangeGroup": self._changeGroupName, |
94 "StartOffset": self.__startOffset, |
103 "Title": self._title, |
95 "EndOffset": self.__endOffset, |
104 "FileName": self.__filename, |
96 "Kind": self.__extractionType, |
105 "StartOffset": self.__startOffset, |
97 "NewName": self.newNameEdit.text(), |
106 "EndOffset": self.__endOffset, |
98 "Similar": self.similarCheckBox.isChecked(), |
107 "Kind": self.__extractionType, |
99 "Global": self.globalCheckBox.isChecked(), |
108 "NewName": self.newNameEdit.text(), |
100 }) |
109 "Similar": self.similarCheckBox.isChecked(), |
|
110 "Global": self.globalCheckBox.isChecked(), |
|
111 }, |
|
112 ) |