--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RefactoringRope/ConfirmationDialog.py Sun Jan 30 17:02:15 2011 +0100 @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing the Confirmation dialog. +""" + +from PyQt4.QtCore import pyqtSlot +from PyQt4.QtGui import QDialog, QDialogButtonBox, QAbstractButton + +from Ui_ConfirmationDialog import Ui_ConfirmationDialog +from ChangesPreviewDialog import ChangesPreviewDialog + +import Utilities + + +class ConfirmationDialog(QDialog, Ui_ConfirmationDialog): + """ + Class implementing the Confirmation dialog. + """ + def __init__(self, changes, parent=None): + """ + Constructor + + @param changes reference to the Changes object + (rope.base.change.ChangeSet) + @param parent reference to the parent widget (QWidget) + """ + QDialog.__init__(self, parent) + self.setupUi(self) + + self.__changes = changes + + self.description.setText( + self.trUtf8("Shall the refactoring <b>{0}</b> be done?")\ + .format(Utilities.html_encode(self.__changes.description))) + + self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) + self.__previewButton = self.buttonBox.addButton( + self.trUtf8("Preview"), QDialogButtonBox.ActionRole) + self.__previewButton.setDefault(True) + + @pyqtSlot(QAbstractButton) + def on_buttonBox_clicked(self, button): + """ + Private slot to act on the button pressed. + + @param button reference to the button pressed (QAbstractButton) + """ + if button == self.__previewButton: + self.__previewChanges() + + def __previewChanges(self): + """ + Private method to preview the changes. + """ + dlg = ChangesPreviewDialog(self.__changes, self) + if dlg.exec_() == QDialog.Accepted: + self.accept()