Sun, 30 Jan 2011 17:24:58 +0100
Added these refactoring functions:
- transform a module to a package
- encapsulate an attribute
- convert a local variable to an attribute
# -*- coding: utf-8 -*- # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing a dialog to create getter and setter method names. """ from PyQt4.QtCore import pyqtSlot from PyQt4.QtGui import QDialog from Ui_GetterSetterDialog import Ui_GetterSetterDialog class GetterSetterDialog(QDialog, Ui_GetterSetterDialog): """ Class implementing a dialog to create getter and setter method names. """ def __init__(self, fieldName, parent=None): """ Constructor @param fieldName name of the field to create getter and setter method names (string) @param parent parent widget of the dialog (QWidget) """ QDialog.__init__(self, parent) self.setupUi(self) self.__fieldName = fieldName self.on_typeCheckBox_toggled(False) @pyqtSlot(bool) def on_typeCheckBox_toggled(self, checked): """ Slot to react to changes of the type checkbox. @param checked state of the checkbox (boolean) """ if checked: self.getterEdit.setText("get_{0}".format(self.__fieldName)) self.setterEdit.setText("set_{0}".format(self.__fieldName)) else: self.getterEdit.setText( "get{0}{1}".format(self.__fieldName[0].upper(), self.__fieldName[1:])) self.setterEdit.setText( "set{0}{1}".format(self.__fieldName[0].upper(), self.__fieldName[1:])) def getData(self): """ Public method to return the getter and setter method names. @return tuple of two strings with getter and setter method names """ return (self.getterEdit.text(), self.setterEdit.text())