18 |
18 |
19 class ConfirmationDialog(RefactoringDialogBase, Ui_ConfirmationDialog): |
19 class ConfirmationDialog(RefactoringDialogBase, Ui_ConfirmationDialog): |
20 """ |
20 """ |
21 Class implementing the Confirmation dialog. |
21 Class implementing the Confirmation dialog. |
22 """ |
22 """ |
23 def __init__(self, refactoring, title, changeGroupName, method, parameters, |
23 |
24 parent=None): |
24 def __init__( |
|
25 self, refactoring, title, changeGroupName, method, parameters, parent=None |
|
26 ): |
25 """ |
27 """ |
26 Constructor |
28 Constructor |
27 |
29 |
28 @param refactoring reference to the main refactoring object |
30 @param refactoring reference to the main refactoring object |
29 @type RefactoringServer |
31 @type RefactoringServer |
30 @param title title of the dialog |
32 @param title title of the dialog |
31 @type str |
33 @type str |
32 @param changeGroupName name of the change group |
34 @param changeGroupName name of the change group |
38 @param parent reference to the parent widget |
40 @param parent reference to the parent widget |
39 @type QWidget |
41 @type QWidget |
40 """ |
42 """ |
41 RefactoringDialogBase.__init__(self, refactoring, title, parent) |
43 RefactoringDialogBase.__init__(self, refactoring, title, parent) |
42 self.setupUi(self) |
44 self.setupUi(self) |
43 |
45 |
44 self._changeGroupName = changeGroupName |
46 self._changeGroupName = changeGroupName |
45 |
47 |
46 self.__okButton = self.buttonBox.button( |
48 self.__okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok) |
47 QDialogButtonBox.StandardButton.Ok) |
|
48 self.__previewButton = self.buttonBox.addButton( |
49 self.__previewButton = self.buttonBox.addButton( |
49 self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole) |
50 self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole |
|
51 ) |
50 self.__previewButton.setDefault(True) |
52 self.__previewButton.setDefault(True) |
51 |
53 |
52 self.__method = method |
54 self.__method = method |
53 self.__parameters = parameters |
55 self.__parameters = parameters |
54 |
56 |
55 self._calculateChanges() |
57 self._calculateChanges() |
56 |
58 |
57 def __processChangeDescription(self, data): |
59 def __processChangeDescription(self, data): |
58 """ |
60 """ |
59 Private method to process the change description data sent by the |
61 Private method to process the change description data sent by the |
60 refactoring client in order to polish the dialog. |
62 refactoring client in order to polish the dialog. |
61 |
63 |
62 @param data dictionary containing the data |
64 @param data dictionary containing the data |
63 @type dict |
65 @type dict |
64 """ |
66 """ |
65 changeDescription = data["Description"] |
67 changeDescription = data["Description"] |
66 if changeDescription: |
68 if changeDescription: |
67 self.description.setText( |
69 self.description.setText( |
68 self.tr("Shall the refactoring <b>{0}</b> be done?") |
70 self.tr("Shall the refactoring <b>{0}</b> be done?").format( |
69 .format(Utilities.html_encode(changeDescription))) |
71 Utilities.html_encode(changeDescription) |
|
72 ) |
|
73 ) |
70 else: |
74 else: |
71 self.description.setText( |
75 self.description.setText( |
72 self.tr("The selected refactoring did not produce any" |
76 self.tr("The selected refactoring did not produce any" " changes.") |
73 " changes.")) |
77 ) |
74 self.__okButton.setEnabled(False) |
78 self.__okButton.setEnabled(False) |
75 self.__previewButton.setEnabled(False) |
79 self.__previewButton.setEnabled(False) |
76 |
80 |
77 msh = self.minimumSizeHint() |
81 msh = self.minimumSizeHint() |
78 self.resize(max(self.width(), msh.width()), msh.height()) |
82 self.resize(max(self.width(), msh.width()), msh.height()) |
79 |
83 |
80 @pyqtSlot(QAbstractButton) |
84 @pyqtSlot(QAbstractButton) |
81 def on_buttonBox_clicked(self, button): |
85 def on_buttonBox_clicked(self, button): |
82 """ |
86 """ |
83 Private slot to act on the button pressed. |
87 Private slot to act on the button pressed. |
84 |
88 |
85 @param button reference to the button pressed |
89 @param button reference to the button pressed |
86 @type QAbstractButton |
90 @type QAbstractButton |
87 """ |
91 """ |
88 if button == self.__previewButton: |
92 if button == self.__previewButton: |
89 self.requestPreview() |
93 self.requestPreview() |
90 elif button == self.__okButton: |
94 elif button == self.__okButton: |
91 self.applyChanges() |
95 self.applyChanges() |
92 |
96 |
93 def _calculateChanges(self): |
97 def _calculateChanges(self): |
94 """ |
98 """ |
95 Protected method to initiate the calculation of the changes. |
99 Protected method to initiate the calculation of the changes. |
96 """ |
100 """ |
97 if "ChangeGroup" not in self.__parameters: |
101 if "ChangeGroup" not in self.__parameters: |
98 self.__parameters["ChangeGroup"] = self._changeGroupName |
102 self.__parameters["ChangeGroup"] = self._changeGroupName |
99 if "Title" not in self.__parameters: |
103 if "Title" not in self.__parameters: |
100 self.__parameters["Title"] = self._title |
104 self.__parameters["Title"] = self._title |
101 |
105 |
102 self._refactoring.sendJson(self.__method, self.__parameters) |
106 self._refactoring.sendJson(self.__method, self.__parameters) |
103 |
107 |
104 def processChangeData(self, data): |
108 def processChangeData(self, data): |
105 """ |
109 """ |
106 Public method to process the change data sent by the refactoring |
110 Public method to process the change data sent by the refactoring |
107 client. |
111 client. |
108 |
112 |
109 @param data dictionary containing the change data |
113 @param data dictionary containing the change data |
110 @type dict |
114 @type dict |
111 """ |
115 """ |
112 subcommand = data["Subcommand"] |
116 subcommand = data["Subcommand"] |
113 if subcommand == "ChangeDescription": |
117 if subcommand == "ChangeDescription": |