12 |
12 |
13 from .Ui_ChangeOccurrencesDialog import Ui_ChangeOccurrencesDialog |
13 from .Ui_ChangeOccurrencesDialog import Ui_ChangeOccurrencesDialog |
14 from .RefactoringDialogBase import RefactoringDialogBase |
14 from .RefactoringDialogBase import RefactoringDialogBase |
15 |
15 |
16 |
16 |
17 class ChangeOccurrencesDialog(RefactoringDialogBase, |
17 class ChangeOccurrencesDialog(RefactoringDialogBase, Ui_ChangeOccurrencesDialog): |
18 Ui_ChangeOccurrencesDialog): |
|
19 """ |
18 """ |
20 Class implementing the Change Occurrences dialog. |
19 Class implementing the Change Occurrences 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 = "ChangeOccurrences" |
40 self._changeGroupName = "ChangeOccurrences" |
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 msh = self.minimumSizeHint() |
53 msh = self.minimumSizeHint() |
54 self.resize(max(self.width(), msh.width()), msh.height()) |
54 self.resize(max(self.width(), msh.width()), msh.height()) |
55 |
55 |
56 @pyqtSlot(str) |
56 @pyqtSlot(str) |
57 def on_replaceEdit_textChanged(self, text): |
57 def on_replaceEdit_textChanged(self, text): |
58 """ |
58 """ |
59 Private slot to react to changes of the new name. |
59 Private slot to react to changes of the new name. |
60 |
60 |
61 @param text text entered into the edit |
61 @param text text entered into the edit |
62 @type str |
62 @type str |
63 """ |
63 """ |
64 self.__okButton.setEnabled(text != "") |
64 self.__okButton.setEnabled(text != "") |
65 self.__previewButton.setEnabled(text != "") |
65 self.__previewButton.setEnabled(text != "") |
66 |
66 |
67 @pyqtSlot(QAbstractButton) |
67 @pyqtSlot(QAbstractButton) |
68 def on_buttonBox_clicked(self, button): |
68 def on_buttonBox_clicked(self, button): |
69 """ |
69 """ |
70 Private slot to act on the button pressed. |
70 Private slot to act on the button pressed. |
71 |
71 |
72 @param button reference to the button pressed |
72 @param button reference to the button pressed |
73 @type QAbstractButton |
73 @type QAbstractButton |
74 """ |
74 """ |
75 if button == self.__previewButton: |
75 if button == self.__previewButton: |
76 self.requestPreview() |
76 self.requestPreview() |
77 elif button == self.__okButton: |
77 elif button == self.__okButton: |
78 self.applyChanges() |
78 self.applyChanges() |
79 |
79 |
80 def _calculateChanges(self): |
80 def _calculateChanges(self): |
81 """ |
81 """ |
82 Protected method to initiate the calculation of the changes. |
82 Protected method to initiate the calculation of the changes. |
83 """ |
83 """ |
84 self._refactoring.sendJson("CalculateChangeOccurrencesChanges", { |
84 self._refactoring.sendJson( |
85 "ChangeGroup": self._changeGroupName, |
85 "CalculateChangeOccurrencesChanges", |
86 "Title": self._title, |
86 { |
87 "FileName": self.__filename, |
87 "ChangeGroup": self._changeGroupName, |
88 "Offset": self.__offset, |
88 "Title": self._title, |
89 "NewName": self.replaceEdit.text(), |
89 "FileName": self.__filename, |
90 "OnlyCalls": self.onlyCallsCheckBox.isChecked(), |
90 "Offset": self.__offset, |
91 "Reads": self.readsCheckBox.isChecked(), |
91 "NewName": self.replaceEdit.text(), |
92 "Writes": self.writesCheckBox.isChecked(), |
92 "OnlyCalls": self.onlyCallsCheckBox.isChecked(), |
93 }) |
93 "Reads": self.readsCheckBox.isChecked(), |
|
94 "Writes": self.writesCheckBox.isChecked(), |
|
95 }, |
|
96 ) |