eric6/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py

Wed, 29 May 2019 22:14:02 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Wed, 29 May 2019 22:14:02 +0200
branch
Variables Viewer
changeset 7030
73779c4c135a
parent 6942
2602857055c5
child 7229
53054eb5b15a
permissions
-rw-r--r--

Bugfix displaying to many characters as default_factory type.

2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
3 # Copyright (c) 2013 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the QRegularExpression wizard dialog.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3142
diff changeset
10 from __future__ import unicode_literals
2791
a9577f248f04 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2771
diff changeset
11
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import os
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import re
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
14 import sys
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
15 import json
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
17 from PyQt5.QtCore import QFileInfo, pyqtSlot, QProcess, QByteArray
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
18 from PyQt5.QtGui import QClipboard, QTextCursor
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
19 from PyQt5.QtWidgets import QWidget, QDialog, QInputDialog, QApplication, \
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
20 QDialogButtonBox, QVBoxLayout, QTableWidgetItem
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 from E5Gui import E5MessageBox, E5FileDialog
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 from E5Gui.E5MainWindow import E5MainWindow
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
25 from .Ui_QRegularExpressionWizardDialog import \
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
26 Ui_QRegularExpressionWizardDialog
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 import UI.PixmapCache
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 import Utilities
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 import Preferences
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
34 class QRegularExpressionWizardWidget(QWidget,
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
35 Ui_QRegularExpressionWizardDialog):
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 Class implementing the QRegularExpression wizard dialog.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 def __init__(self, parent=None, fromEric=True):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 Constructor
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 @param parent parent widget (QWidget)
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
44 @param fromEric flag indicating a call from within eric6
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
2791
a9577f248f04 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2771
diff changeset
46 super(QRegularExpressionWizardWidget, self).__init__(parent)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.setupUi(self)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 # initialize icons of the tool buttons
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.commentButton.setIcon(UI.PixmapCache.getIcon("comment.png"))
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.charButton.setIcon(UI.PixmapCache.getIcon("characters.png"))
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.anycharButton.setIcon(UI.PixmapCache.getIcon("anychar.png"))
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.repeatButton.setIcon(UI.PixmapCache.getIcon("repeat.png"))
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.nonGroupButton.setIcon(UI.PixmapCache.getIcon("nongroup.png"))
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
55 self.atomicGroupButton.setIcon(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
56 UI.PixmapCache.getIcon("atomicgroup.png"))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.groupButton.setIcon(UI.PixmapCache.getIcon("group.png"))
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.namedGroupButton.setIcon(UI.PixmapCache.getIcon("namedgroup.png"))
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
59 self.namedReferenceButton.setIcon(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
60 UI.PixmapCache.getIcon("namedreference.png"))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.altnButton.setIcon(UI.PixmapCache.getIcon("altn.png"))
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.beglineButton.setIcon(UI.PixmapCache.getIcon("begline.png"))
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.endlineButton.setIcon(UI.PixmapCache.getIcon("endline.png"))
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
64 self.wordboundButton.setIcon(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
65 UI.PixmapCache.getIcon("wordboundary.png"))
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
66 self.nonwordboundButton.setIcon(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
67 UI.PixmapCache.getIcon("nonwordboundary.png"))
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
68 self.poslookaheadButton.setIcon(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
69 UI.PixmapCache.getIcon("poslookahead.png"))
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
70 self.neglookaheadButton.setIcon(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
71 UI.PixmapCache.getIcon("neglookahead.png"))
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
72 self.poslookbehindButton.setIcon(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
73 UI.PixmapCache.getIcon("poslookbehind.png"))
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
74 self.neglookbehindButton.setIcon(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
75 UI.PixmapCache.getIcon("neglookbehind.png"))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.undoButton.setIcon(UI.PixmapCache.getIcon("editUndo.png"))
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.redoButton.setIcon(UI.PixmapCache.getIcon("editRedo.png"))
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.namedGroups = re.compile(r"""\(?P<([^>]+)>""").findall
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
81 # start the PyQt5 server part
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
82 self.__pyqt5Available = False
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
83 self.__pyqt5Server = QProcess(self)
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
84 self.__pyqt5Server.start(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
85 sys.executable, [os.path.join(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
86 os.path.dirname(__file__), "QRegularExpressionWizardServer.py")
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
87 ])
2771
281c9b30dd91 Changed all QProcess.waitForStarted() calls to use a 5s timeout (except the debugger interfaces, which have a 10s timeout).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2770
diff changeset
88 if self.__pyqt5Server.waitForStarted(5000):
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
89 self.__pyqt5Server.setReadChannel(QProcess.StandardOutput)
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
90 if self.__sendCommand("available"):
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
91 response = self.__receiveResponse()
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
92 if response and response["available"]:
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
93 self.__pyqt5Available = True
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
94
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
95 self.saveButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
96 self.tr("Save"), QDialogButtonBox.ActionRole)
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
97 self.saveButton.setToolTip(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
98 self.tr("Save the regular expression to a file"))
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
99 self.loadButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
100 self.tr("Load"), QDialogButtonBox.ActionRole)
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
101 self.loadButton.setToolTip(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
102 self.tr("Load a regular expression from a file"))
3213
95fbeca03619 Fixed a wrong behavior of the QRegularExpression wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
103 if self.__pyqt5Available:
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 self.validateButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
105 self.tr("Validate"), QDialogButtonBox.ActionRole)
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
106 self.validateButton.setToolTip(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
107 self.tr("Validate the regular expression"))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.executeButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
109 self.tr("Execute"), QDialogButtonBox.ActionRole)
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
110 self.executeButton.setToolTip(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
111 self.tr("Execute the regular expression"))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.nextButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
113 self.tr("Next match"), QDialogButtonBox.ActionRole)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.nextButton.setToolTip(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
115 self.tr("Show the next match of the regular expression"))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.nextButton.setEnabled(False)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 else:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.validateButton = None
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.executeButton = None
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.nextButton = None
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 if fromEric:
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
123 self.buttonBox.setStandardButtons(
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
124 QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 self.copyButton = None
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 else:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
127 self.copyButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
128 self.tr("Copy"), QDialogButtonBox.ActionRole)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.copyButton.setToolTip(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
130 self.tr("Copy the regular expression to the clipboard"))
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
131 self.buttonBox.setStandardButtons(QDialogButtonBox.Close)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 self.variableLabel.hide()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 self.variableLineEdit.hide()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 self.variableLine.hide()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.regexpTextEdit.setFocus()
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
136
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
137 def __sendCommand(self, command, **kw):
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
138 """
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
139 Private method to send a command to the PyQt5 server.
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
140
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
141 @param command dictionary with command string and related
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
142 data (dict)
2964
84b65fb9e780 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2893
diff changeset
143 @keyparam kw parameters for the command
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
144 @return flag indicating a successful transmission (boolean)
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
145 """
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
146 result = False
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
147 if command:
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
148 commandDict = {"command": command}
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
149 commandDict.update(kw)
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
150 commandStr = json.dumps(commandDict) + "\n"
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
151 data = QByteArray(commandStr.encode("utf-8"))
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
152 self.__pyqt5Server.write(data)
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
153 result = self.__pyqt5Server.waitForBytesWritten(10000)
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
154 return result
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
155
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
156 def __receiveResponse(self):
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
157 """
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
158 Private method to receive a response from the PyQt5 server.
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
159
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
160 @return response dictionary (dict)
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
161 """
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
162 responseDict = {}
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
163 if self.__pyqt5Server.waitForReadyRead(10000):
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
164 data = bytes(self.__pyqt5Server.readAllStandardOutput())
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
165 responseStr = data.decode("utf-8")
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
166 responseDict = json.loads(responseStr)
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
167 if responseDict["error"]:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
168 E5MessageBox.critical(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
169 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
170 self.tr("Communication Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
171 self.tr("""<p>The PyQt5 backend reported"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
172 """ an error.</p><p>{0}</p>""")
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
173 .format(responseDict["error"]))
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
174 responseDict = {}
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
175
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
176 return responseDict
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
177
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
178 def shutdown(self):
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
179 """
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
180 Public method to shut down the PyQt5 server part.
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
181 """
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
182 self.__sendCommand("exit")
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
183 self.__pyqt5Server.waitForFinished(5000)
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
184
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 def __insertString(self, s, steps=0):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 Private method to insert a string into line edit and move cursor.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 @param s string to be inserted into the regexp line edit
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 (string)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 @param steps number of characters to move the cursor (integer).
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 Negative steps moves cursor back, positives forward.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 self.regexpTextEdit.insertPlainText(s)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 tc = self.regexpTextEdit.textCursor()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 if steps != 0:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 if steps < 0:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 act = QTextCursor.Left
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 steps = abs(steps)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 else:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 act = QTextCursor.Right
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
202 for _ in range(steps):
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 tc.movePosition(act)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.regexpTextEdit.setTextCursor(tc)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 def on_commentButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 Private slot to handle the comment toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 self.__insertString("(?#)", -1)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 def on_charButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 Private slot to handle the characters toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 from .QRegularExpressionWizardCharactersDialog import \
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 QRegularExpressionWizardCharactersDialog
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 dlg = QRegularExpressionWizardCharactersDialog(self)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 if dlg.exec_() == QDialog.Accepted:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 self.__insertString(dlg.getCharacters())
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 def on_anycharButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 Private slot to handle the any character toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 self.__insertString(".")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 def on_repeatButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 Private slot to handle the repeat toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 from .QRegularExpressionWizardRepeatDialog import \
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 QRegularExpressionWizardRepeatDialog
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 dlg = QRegularExpressionWizardRepeatDialog(self)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 if dlg.exec_() == QDialog.Accepted:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 self.__insertString(dlg.getRepeat())
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 def on_nonGroupButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 Private slot to handle the non group toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 self.__insertString("(?:)", -1)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 def on_atomicGroupButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 Private slot to handle the atomic non group toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 self.__insertString("(?>)", -1)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 def on_groupButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 Private slot to handle the group toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 self.__insertString("()", -1)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 def on_namedGroupButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 Private slot to handle the named group toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 self.__insertString("(?P<>)", -2)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 def on_namedReferenceButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 Private slot to handle the named reference toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 # determine cursor position as length into text
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 length = self.regexpTextEdit.textCursor().position()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
278 # only present group names that occur before the current
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
279 # cursor position
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 regex = self.regexpTextEdit.toPlainText()[:length]
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 names = self.namedGroups(regex)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 if not names:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
283 E5MessageBox.information(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
284 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
285 self.tr("Named reference"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
286 self.tr("""No named groups have been defined yet."""))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 return
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 groupName, ok = QInputDialog.getItem(
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
291 self.tr("Named reference"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
292 self.tr("Select group name:"),
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 names,
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 0, True)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 if ok and groupName:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 self.__insertString("(?P={0})".format(groupName))
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 def on_altnButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 Private slot to handle the alternatives toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 self.__insertString("(|)", -2)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 def on_beglineButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 Private slot to handle the begin line toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 self.__insertString("^")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 def on_endlineButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 Private slot to handle the end line toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 self.__insertString("$")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 def on_wordboundButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 Private slot to handle the word boundary toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 self.__insertString("\\b")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 def on_nonwordboundButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 Private slot to handle the non word boundary toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 self.__insertString("\\B")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 def on_poslookaheadButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 Private slot to handle the positive lookahead toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 self.__insertString("(?=)", -1)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 def on_neglookaheadButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 Private slot to handle the negative lookahead toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 self.__insertString("(?!)", -1)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 def on_poslookbehindButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 Private slot to handle the positive lookbehind toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 self.__insertString("(?<=)", -1)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 def on_neglookbehindButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 Private slot to handle the negative lookbehind toolbutton.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 self.__insertString("(?<!)", -1)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 def on_undoButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 Private slot to handle the undo action.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 self.regexpTextEdit.document().undo()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 def on_redoButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 Private slot to handle the redo action.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 self.regexpTextEdit.document().redo()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 def on_buttonBox_clicked(self, button):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 Private slot called by a button of the button box clicked.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 @param button button that was clicked (QAbstractButton)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 if button == self.validateButton:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 self.on_validateButton_clicked()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 elif button == self.executeButton:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 self.on_executeButton_clicked()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 elif button == self.saveButton:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 self.on_saveButton_clicked()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 elif button == self.loadButton:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 self.on_loadButton_clicked()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 elif button == self.nextButton:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 self.on_nextButton_clicked()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 elif self.copyButton and button == self.copyButton:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 self.on_copyButton_clicked()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 def on_saveButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 Private slot to save the QRegularExpression to a file.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
401 self.tr("Save regular expression"),
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 "",
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
403 self.tr("RegExp Files (*.rx);;All Files (*)"),
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 None,
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 if fname:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 ext = QFileInfo(fname).suffix()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 if not ext:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 ex = selectedFilter.split("(*")[1].split(")")[0]
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 if ex:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 fname += ex
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 if QFileInfo(fname).exists():
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
413 res = E5MessageBox.yesNo(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
414 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
415 self.tr("Save regular expression"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
416 self.tr("<p>The file <b>{0}</b> already exists."
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
417 " Overwrite it?</p>").format(fname),
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 icon=E5MessageBox.Warning)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 if not res:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 return
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 try:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
423 f = open(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
424 Utilities.toNativeSeparators(fname), "w", encoding="utf-8")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 f.write(self.regexpTextEdit.toPlainText())
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 f.close()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 except IOError as err:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
428 E5MessageBox.information(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
429 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
430 self.tr("Save regular expression"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
431 self.tr("""<p>The regular expression could not"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
432 """ be saved.</p><p>Reason: {0}</p>""")
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
433 .format(str(err)))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 def on_loadButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 Private slot to load a QRegularExpression from a file.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 fname = E5FileDialog.getOpenFileName(
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
442 self.tr("Load regular expression"),
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 "",
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
444 self.tr("RegExp Files (*.rx);;All Files (*)"))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 if fname:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 try:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
447 f = open(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
448 Utilities.toNativeSeparators(fname), "r", encoding="utf-8")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 regexp = f.read()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 f.close()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 self.regexpTextEdit.setPlainText(regexp)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 except IOError as err:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
453 E5MessageBox.information(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
454 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
455 self.tr("Save regular expression"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
456 self.tr("""<p>The regular expression could not"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
457 """ be saved.</p><p>Reason: {0}</p>""")
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
458 .format(str(err)))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 def on_copyButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 Private slot to copy the QRegularExpression string into the clipboard.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
465 This slot is only available, if not called from within eric6.
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 escaped = self.regexpTextEdit.toPlainText()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 if escaped:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 escaped = escaped.replace("\\", "\\\\")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 cb = QApplication.clipboard()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 cb.setText(escaped, QClipboard.Clipboard)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 if cb.supportsSelection():
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 cb.setText(escaped, QClipboard.Selection)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 def on_validateButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 Private slot to validate the entered QRegularExpression.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 """
3213
95fbeca03619 Fixed a wrong behavior of the QRegularExpression wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
480 if not self.__pyqt5Available:
95fbeca03619 Fixed a wrong behavior of the QRegularExpression wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
481 # only available for PyQt5
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 return
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
484 regexp = self.regexpTextEdit.toPlainText()
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
485 if regexp:
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
486 options = []
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 if self.caseInsensitiveCheckBox.isChecked():
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
488 options.append("CaseInsensitiveOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 if self.multilineCheckBox.isChecked():
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
490 options.append("MultilineOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 if self.dotallCheckBox.isChecked():
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
492 options.append("DotMatchesEverythingOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 if self.extendedCheckBox.isChecked():
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
494 options.append("ExtendedPatternSyntaxOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 if self.greedinessCheckBox.isChecked():
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
496 options.append("InvertedGreedinessOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 if self.unicodeCheckBox.isChecked():
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
498 options.append("UseUnicodePropertiesOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 if self.captureCheckBox.isChecked():
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
500 options.append("DontCaptureOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
502 if self.__sendCommand("validate", options=options, regexp=regexp):
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
503 response = self.__receiveResponse()
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
504 if response and "valid" in response:
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
505 if response["valid"]:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
506 E5MessageBox.information(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
507 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
508 self.tr("Validation"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
509 self.tr(
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
510 """The regular expression is valid."""))
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
511 else:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
512 E5MessageBox.critical(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
513 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
514 self.tr("Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
515 self.tr("""Invalid regular expression: {0}""")
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
516 .format(response["errorMessage"]))
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
517 # move cursor to error offset
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
518 offset = response["errorOffset"]
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
519 tc = self.regexpTextEdit.textCursor()
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
520 tc.setPosition(offset)
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
521 self.regexpTextEdit.setTextCursor(tc)
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
522 self.regexpTextEdit.setFocus()
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
523 return
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
524 else:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
525 E5MessageBox.critical(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
526 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
527 self.tr("Communication Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
528 self.tr("""Invalid response received from"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
529 """ PyQt5 backend."""))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 else:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
531 E5MessageBox.critical(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
532 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
533 self.tr("Communication Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
534 self.tr("""Communication with PyQt5 backend"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
535 """ failed."""))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 else:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
537 E5MessageBox.critical(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
538 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
539 self.tr("Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
540 self.tr("""A regular expression must be given."""))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 def on_executeButton_clicked(self, startpos=0):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 """
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
545 Private slot to execute the entered QRegularExpression on the test
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
546 text.
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
548 This slot will execute the entered QRegularExpression on the entered
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
549 test data and will display the result in the table part of the dialog.
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 @param startpos starting position for the QRegularExpression matching
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 """
3213
95fbeca03619 Fixed a wrong behavior of the QRegularExpression wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
553 if not self.__pyqt5Available:
95fbeca03619 Fixed a wrong behavior of the QRegularExpression wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
554 # only available for PyQt5
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 return
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
557 regexp = self.regexpTextEdit.toPlainText()
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 text = self.textTextEdit.toPlainText()
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
559 if regexp and text:
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
560 options = []
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 if self.caseInsensitiveCheckBox.isChecked():
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
562 options.append("CaseInsensitiveOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 if self.multilineCheckBox.isChecked():
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
564 options.append("MultilineOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565 if self.dotallCheckBox.isChecked():
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
566 options.append("DotMatchesEverythingOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 if self.extendedCheckBox.isChecked():
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
568 options.append("ExtendedPatternSyntaxOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 if self.greedinessCheckBox.isChecked():
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
570 options.append("InvertedGreedinessOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 if self.unicodeCheckBox.isChecked():
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
572 options.append("UseUnicodePropertiesOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 if self.captureCheckBox.isChecked():
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
574 options.append("DontCaptureOption")
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
576 if self.__sendCommand("execute", options=options, regexp=regexp,
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
577 text=text, startpos=startpos):
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
578 response = self.__receiveResponse()
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
579 if response and ("valid" in response or "matched" in response):
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
580 if "valid" in response:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
581 E5MessageBox.critical(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
582 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
583 self.tr("Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
584 self.tr("""Invalid regular expression: {0}""")
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
585 .format(response["errorMessage"]))
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
586 # move cursor to error offset
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
587 offset = response["errorOffset"]
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
588 tc = self.regexpTextEdit.textCursor()
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
589 tc.setPosition(offset)
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
590 self.regexpTextEdit.setTextCursor(tc)
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
591 self.regexpTextEdit.setFocus()
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
592 return
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
593 else:
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
594 row = 0
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
595 OFFSET = 5
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
596
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
597 self.resultTable.setColumnCount(0)
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
598 self.resultTable.setColumnCount(3)
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
599 self.resultTable.setRowCount(0)
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
600 self.resultTable.setRowCount(OFFSET)
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
601 self.resultTable.setItem(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
602 row, 0, QTableWidgetItem(self.tr("Regexp")))
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
603 self.resultTable.setItem(
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
604 row, 1, QTableWidgetItem(regexp))
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
605 if response["matched"]:
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
606 captures = response["captures"]
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
607 # index 0 is the complete match
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
608 offset = captures[0][1]
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
609 self.lastMatchEnd = captures[0][2]
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
610 self.nextButton.setEnabled(True)
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
611 row += 1
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
612 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
613 row, 0,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
614 QTableWidgetItem(self.tr("Offset")))
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
615 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
616 row, 1,
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
617 QTableWidgetItem("{0:d}".format(offset)))
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
618
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
619 row += 1
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
620 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
621 row, 0,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
622 QTableWidgetItem(self.tr("Captures")))
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
623 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
624 row, 1,
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
625 QTableWidgetItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
626 "{0:d}".format(len(captures) - 1)))
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
627 row += 1
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
628 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
629 row, 1,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
630 QTableWidgetItem(self.tr("Text")))
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
631 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
632 row, 2,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
633 QTableWidgetItem(self.tr("Characters")))
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
634
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
635 row += 1
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
636 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
637 row, 0,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
638 QTableWidgetItem(self.tr("Match")))
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
639 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
640 row, 1,
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
641 QTableWidgetItem(captures[0][0]))
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
642 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
643 row, 2,
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
644 QTableWidgetItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
645 "{0:d}".format(captures[0][3])))
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
646
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
647 for i in range(1, len(captures)):
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
648 if captures[i][0]:
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
649 row += 1
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
650 self.resultTable.insertRow(row)
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
651 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
652 row, 0,
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
653 QTableWidgetItem(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
654 self.tr("Capture #{0}")
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
655 .format(i)))
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
656 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
657 row, 1,
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
658 QTableWidgetItem(captures[i][0]))
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
659 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
660 row, 2,
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
661 QTableWidgetItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
662 "{0:d}".format(captures[i][3])))
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
663
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
664 # highlight the matched text
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
665 tc = self.textTextEdit.textCursor()
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
666 tc.setPosition(offset)
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
667 tc.setPosition(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
668 self.lastMatchEnd, QTextCursor.KeepAnchor)
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
669 self.textTextEdit.setTextCursor(tc)
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
670 else:
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
671 self.nextButton.setEnabled(False)
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
672 self.resultTable.setRowCount(2)
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
673 row += 1
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
674 if startpos > 0:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
675 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
676 row, 0,
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
677 QTableWidgetItem(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
678 self.tr("No more matches")))
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
679 else:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
680 self.resultTable.setItem(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
681 row, 0,
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
682 QTableWidgetItem(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
683 self.tr("No matches")))
2748
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
684
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
685 # remove the highlight
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
686 tc = self.textTextEdit.textCursor()
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
687 tc.setPosition(0)
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
688 self.textTextEdit.setTextCursor(tc)
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
689
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
690 self.resultTable.resizeColumnsToContents()
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
691 self.resultTable.resizeRowsToContents()
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
692 self.resultTable.verticalHeader().hide()
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
693 self.resultTable.horizontalHeader().hide()
3731148a7cdf Completed the coding stuff of the QRegularExpression support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2747
diff changeset
694 else:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
695 E5MessageBox.critical(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
696 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
697 self.tr("Communication Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
698 self.tr("""Invalid response received from"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
699 """ PyQt5 backend."""))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
700 else:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
701 E5MessageBox.critical(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
702 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
703 self.tr("Communication Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
704 self.tr("""Communication with PyQt5"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
705 """ backend failed."""))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706 else:
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
707 E5MessageBox.critical(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
708 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
709 self.tr("Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
710 self.tr("""A regular expression and a text must"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
711 """ be given."""))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
712
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 def on_nextButton_clicked(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 Private slot to find the next match.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
717 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 self.on_executeButton_clicked(self.lastMatchEnd)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
720 @pyqtSlot()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
721 def on_regexpTextEdit_textChanged(self):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
722 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723 Private slot called when the regexp changes.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
724 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725 if self.nextButton:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726 self.nextButton.setEnabled(False)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 def getCode(self, indLevel, indString):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730 Public method to get the source code.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
731
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732 @param indLevel indentation level (int)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733 @param indString string used for indentation (space or tab) (string)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734 @return generated code (string)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 # calculate the indentation string
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737 i1string = (indLevel + 1) * indString
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 estring = os.linesep + indLevel * indString
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
740 # now generate the code
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 reVar = self.variableLineEdit.text()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 if not reVar:
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
743 reVar = "regexp"
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
744
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
745 regexp = self.regexpTextEdit.toPlainText()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 options = []
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748 if self.caseInsensitiveCheckBox.isChecked():
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749 options.append("QRegularExpression.CaseInsensitiveOption")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 if self.multilineCheckBox.isChecked():
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 options.append("QRegularExpression.MultilineOption")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 if self.dotallCheckBox.isChecked():
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753 options.append("QRegularExpression.DotMatchesEverythingOption")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754 if self.extendedCheckBox.isChecked():
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 options.append("QRegularExpression.ExtendedPatternSyntaxOption")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 if self.greedinessCheckBox.isChecked():
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757 options.append("QRegularExpression.InvertedGreedinessOption")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758 if self.unicodeCheckBox.isChecked():
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759 options.append("QRegularExpression.UseUnicodePropertiesOption")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760 if self.captureCheckBox.isChecked():
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 options.append("QRegularExpression.DontCaptureOption")
3119
8b19074bb239 Changed some wizards to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
762 options = " |{0}{1}".format(os.linesep, i1string).join(options)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763
3119
8b19074bb239 Changed some wizards to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
764 code = '{0} = QRegularExpression('.format(reVar)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765 if options:
3119
8b19074bb239 Changed some wizards to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
766 code += '{0}{1}r"""{2}""",'.format(
8b19074bb239 Changed some wizards to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
767 os.linesep, i1string, regexp.replace('"', '\\"'))
8b19074bb239 Changed some wizards to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
768 code += '{0}{1}{2}'.format(os.linesep, i1string, options)
8b19074bb239 Changed some wizards to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
769 else:
8b19074bb239 Changed some wizards to generate PEP-8 compliant code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
770 code += 'r"""{0}"""'.format(regexp.replace('"', '\\"'))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
771 code += '){0}'.format(estring)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772 return code
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
774
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 class QRegularExpressionWizardDialog(QDialog):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777 Class for the dialog variant.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779 def __init__(self, parent=None, fromEric=True):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781 Constructor
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
782
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 @param parent parent widget (QWidget)
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
784 @param fromEric flag indicating a call from within eric6
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 """
2791
a9577f248f04 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2771
diff changeset
786 super(QRegularExpressionWizardDialog, self).__init__(parent)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787 self.setModal(fromEric)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 self.setSizeGripEnabled(True)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790 self.__layout = QVBoxLayout(self)
2824
858412c29c34 Replaced the obsoleted method setMargin() with setContentsMargins().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
791 self.__layout.setContentsMargins(0, 0, 0, 0)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 self.setLayout(self.__layout)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
793
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 self.cw = QRegularExpressionWizardWidget(self, fromEric)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795 size = self.cw.size()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796 self.__layout.addWidget(self.cw)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797 self.resize(size)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 self.setWindowTitle(self.cw.windowTitle())
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3213
diff changeset
800 self.cw.buttonBox.accepted.connect(self.accept)
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3213
diff changeset
801 self.cw.buttonBox.rejected.connect(self.reject)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 def getCode(self, indLevel, indString):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 Public method to get the source code.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
806
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807 @param indLevel indentation level (int)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 @param indString string used for indentation (space or tab) (string)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 @return generated code (string)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811 return self.cw.getCode(indLevel, indString)
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
812
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
813 def accept(self):
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
814 """
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
815 Public slot to hide the dialog and set the result code to Accepted.
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
816 """
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
817 self.cw.shutdown()
2791
a9577f248f04 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2771
diff changeset
818 super(QRegularExpressionWizardDialog, self).accept()
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
819
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
820 def reject(self):
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
821 """
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
822 Public slot to hide the dialog and set the result code to Rejected.
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
823 """
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
824 self.cw.shutdown()
2791
a9577f248f04 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2771
diff changeset
825 super(QRegularExpressionWizardDialog, self).reject()
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 class QRegularExpressionWizardWindow(E5MainWindow):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830 Main window class for the standalone dialog.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 def __init__(self, parent=None):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
833 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
834 Constructor
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
836 @param parent reference to the parent widget (QWidget)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837 """
2791
a9577f248f04 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2771
diff changeset
838 super(QRegularExpressionWizardWindow, self).__init__(parent)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
839 self.cw = QRegularExpressionWizardWidget(self, fromEric=False)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 size = self.cw.size()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841 self.setCentralWidget(self.cw)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
842 self.resize(size)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
843 self.setWindowTitle(self.cw.windowTitle())
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844
2893
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
845 self.setStyle(
150de635fa29 Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
846 Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
847
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3213
diff changeset
848 self.cw.buttonBox.accepted.connect(self.close)
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3213
diff changeset
849 self.cw.buttonBox.rejected.connect(self.close)
2747
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
850
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
851 def closeEvent(self, evt):
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
852 """
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
853 Protected method handling the close event.
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
854
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
855 @param evt close event (QCloseEvent)
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
856 """
68b920f307ff Started to rework the QRegularExpression wizard because PyQt4 and PyQt5 cannot be mixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2743
diff changeset
857 self.cw.shutdown()
2791
a9577f248f04 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2771
diff changeset
858 super(QRegularExpressionWizardWindow, self).closeEvent(evt)

eric ide

mercurial