RefactoringRope/ConfirmationDialog.py

Tue, 13 Aug 2013 21:13:02 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Tue, 13 Aug 2013 21:13:02 +0200
branch
Py2 comp.
changeset 50
a29c3d2e6dc0
parent 46
a726d19facfc
child 63
c02061242598
permissions
-rw-r--r--

rope for Python2 projects enabled, if running on Python2

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

# Copyright (c) 2010 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing the Confirmation dialog.
"""

from __future__ import unicode_literals    # __IGNORE_WARNING__

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