RefactoringRope/UseFunctionDialog.py

Sun, 06 Jul 2014 14:23:25 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 06 Jul 2014 14:23:25 +0200
changeset 87
1fbf5fdbe721
parent 76
936b2a98fe4e
child 88
e71619898d0f
child 94
03d6a17c66ac
permissions
-rw-r--r--

Ported to PyQt5 and eric6.

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

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

"""
Module implementing the Inline dialog.
"""

from __future__ import unicode_literals

from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QDialogButtonBox, QAbstractButton

from Ui_UseFunctionDialog import Ui_UseFunctionDialog
from RefactoringDialogBase import RefactoringDialogBase


class UseFunctionDialog(RefactoringDialogBase, Ui_UseFunctionDialog):
    """
    Class implementing the Inline dialog.
    """
    def __init__(self, refactoring, title, user, parent=None):
        """
        Constructor
        
        @param refactoring reference to the main refactoring object
            (Refactoring)
        @param title title of the dialog (string)
        @param user reference to the usefunction object
            (rope.refactor.usefunction.UseFunction)
        @param parent reference to the parent widget (QWidget)
        """
        RefactoringDialogBase.__init__(self, refactoring, title, parent)
        self.setupUi(self)
        
        self.__user = user
        
        self.description.setText(
            self.tr("Using Function <b>{0}</b>.")
                .format(self.__user.get_function_name()))
        
        self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
        self.__previewButton = self.buttonBox.addButton(
            self.tr("Preview"), QDialogButtonBox.ActionRole)
        self.__previewButton.setDefault(True)
        
        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 (QAbstractButton)
        """
        if button == self.__previewButton:
            self.previewChanges()
        elif button == self.__okButton:
            self.applyChanges()
    
    def _calculateChanges(self, handle):
        """
        Protected method to calculate the changes.
        
        @param handle reference to the task handle
            (rope.base.taskhandle.TaskHandle)
        @return reference to the Changes object (rope.base.change.ChangeSet)
        """
        try:
            changes = self.__user.get_changes(task_handle=handle)
            return changes
        except Exception as err:
            self._refactoring.handleRopeError(err, self._title, handle)
            return None

eric ide

mercurial