RefactoringRope/ConfirmationDialog.py

Sat, 23 Feb 2013 15:28:39 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 23 Feb 2013 15:28:39 +0100
changeset 46
a726d19facfc
parent 43
39924831c795
child 50
a29c3d2e6dc0
child 55
d501156be247
permissions
-rw-r--r--

Modified the code to do lazy import.

# -*- coding: utf-8 -*-

# Copyright (c) 2010 - 2013 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

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.
        """
        from ChangesPreviewDialog import ChangesPreviewDialog
        dlg = ChangesPreviewDialog(self.__changes, self)
        if dlg.exec_() == QDialog.Accepted:
            self.accept()

eric ide

mercurial