--- a/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py Sun Mar 30 22:00:14 2014 +0200 +++ b/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py Thu Apr 03 23:05:31 2014 +0200 @@ -14,7 +14,7 @@ import sys import json -from PyQt4.QtCore import QFileInfo, pyqtSlot, qVersion, QProcess, QByteArray +from PyQt4.QtCore import QFileInfo, pyqtSlot, QProcess, QByteArray from PyQt4.QtGui import QWidget, QDialog, QInputDialog, QApplication, \ QClipboard, QTextCursor, QDialogButtonBox, QVBoxLayout, QTableWidgetItem @@ -92,26 +92,26 @@ self.__pyqt5Available = True self.saveButton = self.buttonBox.addButton( - self.trUtf8("Save"), QDialogButtonBox.ActionRole) + self.tr("Save"), QDialogButtonBox.ActionRole) self.saveButton.setToolTip( - self.trUtf8("Save the regular expression to a file")) + self.tr("Save the regular expression to a file")) self.loadButton = self.buttonBox.addButton( - self.trUtf8("Load"), QDialogButtonBox.ActionRole) + self.tr("Load"), QDialogButtonBox.ActionRole) self.loadButton.setToolTip( - self.trUtf8("Load a regular expression from a file")) - if qVersion() >= "5.0.0" and self.__pyqt5Available: + self.tr("Load a regular expression from a file")) + if self.__pyqt5Available: self.validateButton = self.buttonBox.addButton( - self.trUtf8("Validate"), QDialogButtonBox.ActionRole) + self.tr("Validate"), QDialogButtonBox.ActionRole) self.validateButton.setToolTip( - self.trUtf8("Validate the regular expression")) + self.tr("Validate the regular expression")) self.executeButton = self.buttonBox.addButton( - self.trUtf8("Execute"), QDialogButtonBox.ActionRole) + self.tr("Execute"), QDialogButtonBox.ActionRole) self.executeButton.setToolTip( - self.trUtf8("Execute the regular expression")) + self.tr("Execute the regular expression")) self.nextButton = self.buttonBox.addButton( - self.trUtf8("Next match"), QDialogButtonBox.ActionRole) + self.tr("Next match"), QDialogButtonBox.ActionRole) self.nextButton.setToolTip( - self.trUtf8("Show the next match of the regular expression")) + self.tr("Show the next match of the regular expression")) self.nextButton.setEnabled(False) else: self.validateButton = None @@ -124,9 +124,9 @@ self.copyButton = None else: self.copyButton = self.buttonBox.addButton( - self.trUtf8("Copy"), QDialogButtonBox.ActionRole) + self.tr("Copy"), QDialogButtonBox.ActionRole) self.copyButton.setToolTip( - self.trUtf8("Copy the regular expression to the clipboard")) + self.tr("Copy the regular expression to the clipboard")) self.buttonBox.setStandardButtons(QDialogButtonBox.Close) self.variableLabel.hide() self.variableLineEdit.hide() @@ -166,9 +166,9 @@ if responseDict["error"]: E5MessageBox.critical( self, - self.trUtf8("Communication Error"), - self.trUtf8("""<p>The PyQt5 backend reported""" - """ an error.</p><p>{0}</p>""") + self.tr("Communication Error"), + self.tr("""<p>The PyQt5 backend reported""" + """ an error.</p><p>{0}</p>""") .format(responseDict["error"])) responseDict = {} @@ -281,14 +281,14 @@ if not names: E5MessageBox.information( self, - self.trUtf8("Named reference"), - self.trUtf8("""No named groups have been defined yet.""")) + self.tr("Named reference"), + self.tr("""No named groups have been defined yet.""")) return groupName, ok = QInputDialog.getItem( self, - self.trUtf8("Named reference"), - self.trUtf8("Select group name:"), + self.tr("Named reference"), + self.tr("Select group name:"), names, 0, True) if ok and groupName: @@ -397,9 +397,9 @@ """ fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( self, - self.trUtf8("Save regular expression"), + self.tr("Save regular expression"), "", - self.trUtf8("RegExp Files (*.rx);;All Files (*)"), + self.tr("RegExp Files (*.rx);;All Files (*)"), None, E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) if fname: @@ -411,9 +411,9 @@ if QFileInfo(fname).exists(): res = E5MessageBox.yesNo( self, - self.trUtf8("Save regular expression"), - self.trUtf8("<p>The file <b>{0}</b> already exists." - " Overwrite it?</p>").format(fname), + self.tr("Save regular expression"), + self.tr("<p>The file <b>{0}</b> already exists." + " Overwrite it?</p>").format(fname), icon=E5MessageBox.Warning) if not res: return @@ -426,9 +426,9 @@ except IOError as err: E5MessageBox.information( self, - self.trUtf8("Save regular expression"), - self.trUtf8("""<p>The regular expression could not""" - """ be saved.</p><p>Reason: {0}</p>""") + self.tr("Save regular expression"), + self.tr("""<p>The regular expression could not""" + """ be saved.</p><p>Reason: {0}</p>""") .format(str(err))) @pyqtSlot() @@ -438,9 +438,9 @@ """ fname = E5FileDialog.getOpenFileName( self, - self.trUtf8("Load regular expression"), + self.tr("Load regular expression"), "", - self.trUtf8("RegExp Files (*.rx);;All Files (*)")) + self.tr("RegExp Files (*.rx);;All Files (*)")) if fname: try: f = open( @@ -451,9 +451,9 @@ except IOError as err: E5MessageBox.information( self, - self.trUtf8("Save regular expression"), - self.trUtf8("""<p>The regular expression could not""" - """ be saved.</p><p>Reason: {0}</p>""") + self.tr("Save regular expression"), + self.tr("""<p>The regular expression could not""" + """ be saved.</p><p>Reason: {0}</p>""") .format(str(err))) @pyqtSlot() @@ -476,8 +476,8 @@ """ Private slot to validate the entered QRegularExpression. """ - if qVersion() < "5.0.0" or not self.__pyqt5Available: - # only available for Qt5 + if not self.__pyqt5Available: + # only available for PyQt5 return regexp = self.regexpTextEdit.toPlainText() @@ -504,14 +504,14 @@ if response["valid"]: E5MessageBox.information( self, - self.trUtf8("Validation"), - self.trUtf8( + self.tr("Validation"), + self.tr( """The regular expression is valid.""")) else: E5MessageBox.critical( self, - self.trUtf8("Error"), - self.trUtf8("""Invalid regular expression: {0}""") + self.tr("Error"), + self.tr("""Invalid regular expression: {0}""") .format(response["errorMessage"])) # move cursor to error offset offset = response["errorOffset"] @@ -523,20 +523,20 @@ else: E5MessageBox.critical( self, - self.trUtf8("Communication Error"), - self.trUtf8("""Invalid response received from""" - """ PyQt5 backend.""")) + self.tr("Communication Error"), + self.tr("""Invalid response received from""" + """ PyQt5 backend.""")) else: E5MessageBox.critical( self, - self.trUtf8("Communication Error"), - self.trUtf8("""Communication with PyQt5 backend""" - """ failed.""")) + self.tr("Communication Error"), + self.tr("""Communication with PyQt5 backend""" + """ failed.""")) else: E5MessageBox.critical( self, - self.trUtf8("Error"), - self.trUtf8("""A regular expression must be given.""")) + self.tr("Error"), + self.tr("""A regular expression must be given.""")) @pyqtSlot() def on_executeButton_clicked(self, startpos=0): @@ -549,8 +549,8 @@ @param startpos starting position for the QRegularExpression matching """ - if qVersion() < "5.0.0" or not self.__pyqt5Available: - # only available for Qt5 + if not self.__pyqt5Available: + # only available for PyQt5 return regexp = self.regexpTextEdit.toPlainText() @@ -579,8 +579,8 @@ if "valid" in response: E5MessageBox.critical( self, - self.trUtf8("Error"), - self.trUtf8("""Invalid regular expression: {0}""") + self.tr("Error"), + self.tr("""Invalid regular expression: {0}""") .format(response["errorMessage"])) # move cursor to error offset offset = response["errorOffset"] @@ -598,7 +598,7 @@ self.resultTable.setRowCount(0) self.resultTable.setRowCount(OFFSET) self.resultTable.setItem( - row, 0, QTableWidgetItem(self.trUtf8("Regexp"))) + row, 0, QTableWidgetItem(self.tr("Regexp"))) self.resultTable.setItem( row, 1, QTableWidgetItem(regexp)) if response["matched"]: @@ -610,7 +610,7 @@ row += 1 self.resultTable.setItem( row, 0, - QTableWidgetItem(self.trUtf8("Offset"))) + QTableWidgetItem(self.tr("Offset"))) self.resultTable.setItem( row, 1, QTableWidgetItem("{0:d}".format(offset))) @@ -618,7 +618,7 @@ row += 1 self.resultTable.setItem( row, 0, - QTableWidgetItem(self.trUtf8("Captures"))) + QTableWidgetItem(self.tr("Captures"))) self.resultTable.setItem( row, 1, QTableWidgetItem( @@ -626,15 +626,15 @@ row += 1 self.resultTable.setItem( row, 1, - QTableWidgetItem(self.trUtf8("Text"))) + QTableWidgetItem(self.tr("Text"))) self.resultTable.setItem( row, 2, - QTableWidgetItem(self.trUtf8("Characters"))) + QTableWidgetItem(self.tr("Characters"))) row += 1 self.resultTable.setItem( row, 0, - QTableWidgetItem(self.trUtf8("Match"))) + QTableWidgetItem(self.tr("Match"))) self.resultTable.setItem( row, 1, QTableWidgetItem(captures[0][0])) @@ -650,7 +650,7 @@ self.resultTable.setItem( row, 0, QTableWidgetItem( - self.trUtf8("Capture #{0}") + self.tr("Capture #{0}") .format(i))) self.resultTable.setItem( row, 1, @@ -674,12 +674,12 @@ self.resultTable.setItem( row, 0, QTableWidgetItem( - self.trUtf8("No more matches"))) + self.tr("No more matches"))) else: self.resultTable.setItem( row, 0, QTableWidgetItem( - self.trUtf8("No matches"))) + self.tr("No matches"))) # remove the highlight tc = self.textTextEdit.textCursor() @@ -693,21 +693,21 @@ else: E5MessageBox.critical( self, - self.trUtf8("Communication Error"), - self.trUtf8("""Invalid response received from""" - """ PyQt5 backend.""")) + self.tr("Communication Error"), + self.tr("""Invalid response received from""" + """ PyQt5 backend.""")) else: E5MessageBox.critical( self, - self.trUtf8("Communication Error"), - self.trUtf8("""Communication with PyQt5""" - """ backend failed.""")) + self.tr("Communication Error"), + self.tr("""Communication with PyQt5""" + """ backend failed.""")) else: E5MessageBox.critical( self, - self.trUtf8("Error"), - self.trUtf8("""A regular expression and a text must""" - """ be given.""")) + self.tr("Error"), + self.tr("""A regular expression and a text must""" + """ be given.""")) @pyqtSlot() def on_nextButton_clicked(self): @@ -796,8 +796,8 @@ self.resize(size) self.setWindowTitle(self.cw.windowTitle()) - self.cw.buttonBox.accepted[()].connect(self.accept) - self.cw.buttonBox.rejected[()].connect(self.reject) + self.cw.buttonBox.accepted.connect(self.accept) + self.cw.buttonBox.rejected.connect(self.reject) def getCode(self, indLevel, indString): """ @@ -844,8 +844,8 @@ self.setStyle( Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) - self.cw.buttonBox.accepted[()].connect(self.close) - self.cw.buttonBox.rejected[()].connect(self.close) + self.cw.buttonBox.accepted.connect(self.close) + self.cw.buttonBox.rejected.connect(self.close) def closeEvent(self, evt): """