--- a/RefactoringRope/UseFunctionDialog.py Sat Jun 25 18:06:56 2022 +0200 +++ b/RefactoringRope/UseFunctionDialog.py Wed Sep 21 15:30:34 2022 +0200 @@ -18,10 +18,11 @@ """ Class implementing the Use Function dialog. """ + def __init__(self, refactoring, title, filename, offset, parent=None): """ Constructor - + @param refactoring reference to the main refactoring object @type RefactoringServer @param title title of the dialog @@ -35,49 +36,52 @@ """ RefactoringDialogBase.__init__(self, refactoring, title, parent) self.setupUi(self) - + self._changeGroupName = "UseFunction" - + self.__filename = filename self.__offset = offset - - self.__okButton = self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok) + + self.__okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok) self.__previewButton = self.buttonBox.addButton( - self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole) + self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole + ) self.__previewButton.setDefault(True) - - self._refactoring.sendJson("RequestUseFunction", { - "ChangeGroup": self._changeGroupName, - "Title": self._title, - "FileName": self.__filename, - "Offset": self.__offset, - }) - + + self._refactoring.sendJson( + "RequestUseFunction", + { + "ChangeGroup": self._changeGroupName, + "Title": self._title, + "FileName": self.__filename, + "Offset": self.__offset, + }, + ) + def __processUseFunctionName(self, data): """ Private method to process the function name data sent by the refactoring client in order to polish the dialog. - + @param data dictionary containing the inline type data @type dict """ self.description.setText( - self.tr("Using Function <b>{0}</b>.") - .format(data["FunctionName"])) - + self.tr("Using Function <b>{0}</b>.").format(data["FunctionName"]) + ) + if not data["FunctionName"]: self.__okButton.setEnabled(False) self.__previewButton.setEnabled(False) - + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) - + @pyqtSlot(QAbstractButton) def on_buttonBox_clicked(self, button): """ Private slot to act on the button pressed. - + @param button reference to the button pressed @type QAbstractButton """ @@ -85,23 +89,26 @@ self.requestPreview() elif button == self.__okButton: self.applyChanges() - + def _calculateChanges(self): """ Protected method to initiate the calculation of the changes. """ - self._refactoring.sendJson("CalculateUseFunctionChanges", { - "ChangeGroup": self._changeGroupName, - "Title": self._title, - "FileName": self.__filename, - "Offset": self.__offset, - }) - + self._refactoring.sendJson( + "CalculateUseFunctionChanges", + { + "ChangeGroup": self._changeGroupName, + "Title": self._title, + "FileName": self.__filename, + "Offset": self.__offset, + }, + ) + def processChangeData(self, data): """ Public method to process the change data sent by the refactoring client. - + @param data dictionary containing the change data @type dict """