12 |
12 |
13 from .Ui_MethodToMethodObjectDialog import Ui_MethodToMethodObjectDialog |
13 from .Ui_MethodToMethodObjectDialog import Ui_MethodToMethodObjectDialog |
14 from .RefactoringDialogBase import RefactoringDialogBase |
14 from .RefactoringDialogBase import RefactoringDialogBase |
15 |
15 |
16 |
16 |
17 class MethodToMethodObjectDialog(RefactoringDialogBase, |
17 class MethodToMethodObjectDialog(RefactoringDialogBase, Ui_MethodToMethodObjectDialog): |
18 Ui_MethodToMethodObjectDialog): |
|
19 """ |
18 """ |
20 Class implementing the Method To Method object dialog. |
19 Class implementing the Method To Method object dialog. |
21 """ |
20 """ |
|
21 |
22 def __init__(self, refactoring, title, filename, offset, parent=None): |
22 def __init__(self, refactoring, title, filename, offset, parent=None): |
23 """ |
23 """ |
24 Constructor |
24 Constructor |
25 |
25 |
26 @param refactoring reference to the main refactoring object |
26 @param refactoring reference to the main refactoring object |
27 @type RefactoringServer |
27 @type RefactoringServer |
28 @param title title of the dialog |
28 @param title title of the dialog |
29 @type str |
29 @type str |
30 @param filename file name to be worked on |
30 @param filename file name to be worked on |
34 @param parent reference to the parent widget |
34 @param parent reference to the parent widget |
35 @type QWidget |
35 @type QWidget |
36 """ |
36 """ |
37 RefactoringDialogBase.__init__(self, refactoring, title, parent) |
37 RefactoringDialogBase.__init__(self, refactoring, title, parent) |
38 self.setupUi(self) |
38 self.setupUi(self) |
39 |
39 |
40 self._changeGroupName = "MethodToMethodObject" |
40 self._changeGroupName = "MethodToMethodObject" |
41 |
41 |
42 self.__filename = filename |
42 self.__filename = filename |
43 self.__offset = offset |
43 self.__offset = offset |
44 |
44 |
45 self.__okButton = self.buttonBox.button( |
45 self.__okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok) |
46 QDialogButtonBox.StandardButton.Ok) |
|
47 self.__okButton.setEnabled(False) |
46 self.__okButton.setEnabled(False) |
48 self.__previewButton = self.buttonBox.addButton( |
47 self.__previewButton = self.buttonBox.addButton( |
49 self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole) |
48 self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole |
|
49 ) |
50 self.__previewButton.setDefault(True) |
50 self.__previewButton.setDefault(True) |
51 self.__previewButton.setEnabled(False) |
51 self.__previewButton.setEnabled(False) |
52 |
52 |
53 self.nameEdit.setText("_MethodObject") |
53 self.nameEdit.setText("_MethodObject") |
54 self.nameEdit.selectAll() |
54 self.nameEdit.selectAll() |
55 |
55 |
56 msh = self.minimumSizeHint() |
56 msh = self.minimumSizeHint() |
57 self.resize(max(self.width(), msh.width()), msh.height()) |
57 self.resize(max(self.width(), msh.width()), msh.height()) |
58 |
58 |
59 @pyqtSlot(str) |
59 @pyqtSlot(str) |
60 def on_nameEdit_textChanged(self, text): |
60 def on_nameEdit_textChanged(self, text): |
61 """ |
61 """ |
62 Private slot to react to changes of the name. |
62 Private slot to react to changes of the name. |
63 |
63 |
64 @param text text entered into the edit |
64 @param text text entered into the edit |
65 @type str |
65 @type str |
66 """ |
66 """ |
67 self.__okButton.setEnabled(bool(text)) |
67 self.__okButton.setEnabled(bool(text)) |
68 self.__previewButton.setEnabled(bool(text)) |
68 self.__previewButton.setEnabled(bool(text)) |
69 |
69 |
70 @pyqtSlot(QAbstractButton) |
70 @pyqtSlot(QAbstractButton) |
71 def on_buttonBox_clicked(self, button): |
71 def on_buttonBox_clicked(self, button): |
72 """ |
72 """ |
73 Private slot to act on the button pressed. |
73 Private slot to act on the button pressed. |
74 |
74 |
75 @param button reference to the button pressed |
75 @param button reference to the button pressed |
76 @type QAbstractButton |
76 @type QAbstractButton |
77 """ |
77 """ |
78 if button == self.__previewButton: |
78 if button == self.__previewButton: |
79 self.requestPreview() |
79 self.requestPreview() |
80 elif button == self.__okButton: |
80 elif button == self.__okButton: |
81 self.applyChanges() |
81 self.applyChanges() |
82 |
82 |
83 def _calculateChanges(self): |
83 def _calculateChanges(self): |
84 """ |
84 """ |
85 Protected method to initiate the calculation of the changes. |
85 Protected method to initiate the calculation of the changes. |
86 """ |
86 """ |
87 self._refactoring.sendJson("CalculateMethodObjectChanges", { |
87 self._refactoring.sendJson( |
88 "ChangeGroup": self._changeGroupName, |
88 "CalculateMethodObjectChanges", |
89 "Title": self._title, |
89 { |
90 "FileName": self.__filename, |
90 "ChangeGroup": self._changeGroupName, |
91 "Offset": self.__offset, |
91 "Title": self._title, |
92 "Name": self.nameEdit.text(), |
92 "FileName": self.__filename, |
93 }) |
93 "Offset": self.__offset, |
|
94 "Name": self.nameEdit.text(), |
|
95 }, |
|
96 ) |