10 import os |
10 import os |
11 import re |
11 import re |
12 import sys |
12 import sys |
13 import json |
13 import json |
14 |
14 |
15 from PyQt4.QtCore import QFileInfo, pyqtSlot, qVersion, QProcess, QByteArray |
15 from PyQt4.QtCore import QFileInfo, pyqtSlot, QProcess, QByteArray |
16 from PyQt4.QtGui import QWidget, QDialog, QInputDialog, QApplication, \ |
16 from PyQt4.QtGui import QWidget, QDialog, QInputDialog, QApplication, \ |
17 QClipboard, QTextCursor, QDialogButtonBox, QVBoxLayout, QTableWidgetItem |
17 QClipboard, QTextCursor, QDialogButtonBox, QVBoxLayout, QTableWidgetItem |
18 |
18 |
19 from E5Gui import E5MessageBox, E5FileDialog |
19 from E5Gui import E5MessageBox, E5FileDialog |
20 from E5Gui.E5MainWindow import E5MainWindow |
20 from E5Gui.E5MainWindow import E5MainWindow |
95 self.trUtf8("Save the regular expression to a file")) |
95 self.trUtf8("Save the regular expression to a file")) |
96 self.loadButton = self.buttonBox.addButton( |
96 self.loadButton = self.buttonBox.addButton( |
97 self.trUtf8("Load"), QDialogButtonBox.ActionRole) |
97 self.trUtf8("Load"), QDialogButtonBox.ActionRole) |
98 self.loadButton.setToolTip( |
98 self.loadButton.setToolTip( |
99 self.trUtf8("Load a regular expression from a file")) |
99 self.trUtf8("Load a regular expression from a file")) |
100 if qVersion() >= "5.0.0" and self.__pyqt5Available: |
100 if self.__pyqt5Available: |
101 self.validateButton = self.buttonBox.addButton( |
101 self.validateButton = self.buttonBox.addButton( |
102 self.trUtf8("Validate"), QDialogButtonBox.ActionRole) |
102 self.trUtf8("Validate"), QDialogButtonBox.ActionRole) |
103 self.validateButton.setToolTip( |
103 self.validateButton.setToolTip( |
104 self.trUtf8("Validate the regular expression")) |
104 self.trUtf8("Validate the regular expression")) |
105 self.executeButton = self.buttonBox.addButton( |
105 self.executeButton = self.buttonBox.addButton( |
472 @pyqtSlot() |
472 @pyqtSlot() |
473 def on_validateButton_clicked(self): |
473 def on_validateButton_clicked(self): |
474 """ |
474 """ |
475 Private slot to validate the entered QRegularExpression. |
475 Private slot to validate the entered QRegularExpression. |
476 """ |
476 """ |
477 if qVersion() < "5.0.0" or not self.__pyqt5Available: |
477 if not self.__pyqt5Available: |
478 # only available for Qt5 |
478 # only available for PyQt5 |
479 return |
479 return |
480 |
480 |
481 regexp = self.regexpTextEdit.toPlainText() |
481 regexp = self.regexpTextEdit.toPlainText() |
482 if regexp: |
482 if regexp: |
483 options = [] |
483 options = [] |
545 This slot will execute the entered QRegularExpression on the entered |
545 This slot will execute the entered QRegularExpression on the entered |
546 test data and will display the result in the table part of the dialog. |
546 test data and will display the result in the table part of the dialog. |
547 |
547 |
548 @param startpos starting position for the QRegularExpression matching |
548 @param startpos starting position for the QRegularExpression matching |
549 """ |
549 """ |
550 if qVersion() < "5.0.0" or not self.__pyqt5Available: |
550 if not self.__pyqt5Available: |
551 # only available for Qt5 |
551 # only available for PyQt5 |
552 return |
552 return |
553 |
553 |
554 regexp = self.regexpTextEdit.toPlainText() |
554 regexp = self.regexpTextEdit.toPlainText() |
555 text = self.textTextEdit.toPlainText() |
555 text = self.textTextEdit.toPlainText() |
556 if regexp and text: |
556 if regexp and text: |