Sun, 17 Sep 2017 20:03:39 +0200
Started implementing the distributed rename refactorings.
# -*- coding: utf-8 -*- # Copyright (c) 2010 - 2017 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing the Refactoring dialog base class. """ from __future__ import unicode_literals from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QDialog from E5Gui.E5Application import e5App class RefactoringDialogBase(QDialog): """ Class implementing the Refactoring dialog base class. """ def __init__(self, refactoring, title, parent=None): """ Constructor @param refactoring reference to the main refactoring object (Refactoring) @param title title of the dialog (string) @param parent reference to the parent widget (QWidget) """ QDialog.__init__(self, parent) self.setAttribute(Qt.WA_DeleteOnClose) self.setWindowTitle(title) self._refactoring = refactoring self._title = title def calculateChanges(self): """ Public method to initiate the calculation of changes. @exception NotImplementedError raised to indicate that this method must be overridden by subclasses """ raise NotImplementedError("_calculateChanges must be overridden.") def previewChanges(self, data): """ Public method to preview the changes. @param data dictionary containing the change data @type dict """ from ChangesPreviewDialog import ChangesPreviewDialog dlg = ChangesPreviewDialog( data["Description"], data["Changes"], self) if dlg.exec_() == QDialog.Accepted: self.applyChanges() def applyChanges(self): """ Public method to apply the changes. """ self._refactoring.sendJson("ApplyChanges", { "ChangeGroup": self._changeGroupName, }) ## if changes is not None: ## self.__createProgressHandle(False) ## try: ## self._refactoring.getProject().do(changes, self.__handle) ## except Exception as err: ## self._refactoring.handleRopeError( ## err, self._title, self.__handle) ## self.__handle.reset() ## self.__handle = None 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 """ subcommand = data["Subcommand"] if subcommand == "PreviewChanges": self.previewChanges(data) elif subcommand == "ChangesApplied": self._refactoring.refreshEditors(data["ChangedFiles"]) p = e5App().getObject("Project") if p.isDirty(): p.saveProject() self.accept() def closeEvent(self, evt): """ Protected method handling close events. @param evt reference to the close event object @type QCloseEvent """ self.__refactoring.sendJson("ClearChanges", { "ChangeGroup": self._changeGroupName, }) evt.accept()