Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardDialog.py

Thu, 04 Oct 2012 19:28:49 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 04 Oct 2012 19:28:49 +0200
changeset 2101
5bac7dee9e1a
parent 1818
a5e4cb4bed43
child 2104
671c38b34bef
permissions
-rw-r--r--

Introduced the E5MainWindow class allowing to set a style for all the main windows.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
1509
c0b5e693b0eb Updated copyright for 2012.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
3 # Copyright (c) 2004 - 2012 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the QRegExp wizard dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
12 from PyQt4.QtCore import QFileInfo, QRegExp, Qt, pyqtSlot, qVersion
1112
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
13 from PyQt4.QtGui import QWidget, QDialog, QApplication, QClipboard, QTextCursor, \
2101
5bac7dee9e1a Introduced the E5MainWindow class allowing to set a style for all the main windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1818
diff changeset
14 QDialogButtonBox, QVBoxLayout, QTableWidgetItem
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
16 from E5Gui import E5MessageBox, E5FileDialog
2101
5bac7dee9e1a Introduced the E5MainWindow class allowing to set a style for all the main windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1818
diff changeset
17 from E5Gui.E5MainWindow import E5MainWindow
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 465
diff changeset
18
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
19 from .Ui_QRegExpWizardDialog import Ui_QRegExpWizardWidget
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
21 from .QRegExpWizardRepeatDialog import QRegExpWizardRepeatDialog
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
22 from .QRegExpWizardCharactersDialog import QRegExpWizardCharactersDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 import Utilities
2101
5bac7dee9e1a Introduced the E5MainWindow class allowing to set a style for all the main windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1818
diff changeset
27 import Preferences
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
29
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
30 class QRegExpWizardWidget(QWidget, Ui_QRegExpWizardWidget):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Class implementing the QRegExp wizard dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
34 def __init__(self, parent=None, fromEric=True):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @param parent parent widget (QWidget)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
39 @param fromEric flag indicating a call from within eric5
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
41 super().__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 # initialize icons of the tool buttons
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
45 # regexp tool buttons
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.charButton.setIcon(UI.PixmapCache.getIcon("characters.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.anycharButton.setIcon(UI.PixmapCache.getIcon("anychar.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.repeatButton.setIcon(UI.PixmapCache.getIcon("repeat.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.nonGroupButton.setIcon(UI.PixmapCache.getIcon("nongroup.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.groupButton.setIcon(UI.PixmapCache.getIcon("group.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.altnButton.setIcon(UI.PixmapCache.getIcon("altn.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.beglineButton.setIcon(UI.PixmapCache.getIcon("begline.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.endlineButton.setIcon(UI.PixmapCache.getIcon("endline.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.wordboundButton.setIcon(UI.PixmapCache.getIcon("wordboundary.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.nonwordboundButton.setIcon(UI.PixmapCache.getIcon("nonwordboundary.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.poslookaheadButton.setIcon(UI.PixmapCache.getIcon("poslookahead.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.neglookaheadButton.setIcon(UI.PixmapCache.getIcon("neglookahead.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.undoButton.setIcon(UI.PixmapCache.getIcon("editUndo.png"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.redoButton.setIcon(UI.PixmapCache.getIcon("editRedo.png"))
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
60 # wildcard tool buttons
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
61 self.wildcardCharButton.setIcon(UI.PixmapCache.getIcon("characters.png"))
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
62 self.wildcardAnycharButton.setIcon(UI.PixmapCache.getIcon("anychar.png"))
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
63 self.wildcardRepeatButton.setIcon(UI.PixmapCache.getIcon("repeat.png"))
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
64 # W3C tool buttons
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
65 self.w3cCharButton.setIcon(UI.PixmapCache.getIcon("characters.png"))
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
66 self.w3cAnycharButton.setIcon(UI.PixmapCache.getIcon("anychar.png"))
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
67 self.w3cRepeatButton.setIcon(UI.PixmapCache.getIcon("repeat.png"))
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
68 self.w3cGroupButton.setIcon(UI.PixmapCache.getIcon("group.png"))
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
69 self.w3cAltnButton.setIcon(UI.PixmapCache.getIcon("altn.png"))
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
70
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
71 # initialize the syntax pattern combo
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
72 self.syntaxCombo.addItem("RegExp", QRegExp.RegExp)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
73 self.syntaxCombo.addItem("RegExp2", QRegExp.RegExp2)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
74 self.syntaxCombo.addItem("Wildcard", QRegExp.Wildcard)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
75 self.syntaxCombo.addItem("Unix Wildcard", QRegExp.WildcardUnix)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
76 self.syntaxCombo.addItem("Fixed String", QRegExp.FixedString)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
77 self.syntaxCombo.addItem("W3C XML Schema 1.1", QRegExp.W3CXmlSchema11)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
78 if qVersion() >= "5.0.0":
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
79 self.syntaxCombo.setCurrentIndex(1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.saveButton = \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.buttonBox.addButton(self.trUtf8("Save"), QDialogButtonBox.ActionRole)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.saveButton.setToolTip(self.trUtf8("Save the regular expression to a file"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.loadButton = \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.buttonBox.addButton(self.trUtf8("Load"), QDialogButtonBox.ActionRole)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.loadButton.setToolTip(self.trUtf8("Load a regular expression from a file"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.validateButton = \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.buttonBox.addButton(self.trUtf8("Validate"), QDialogButtonBox.ActionRole)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.validateButton.setToolTip(self.trUtf8("Validate the regular expression"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.executeButton = \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.buttonBox.addButton(self.trUtf8("Execute"), QDialogButtonBox.ActionRole)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.executeButton.setToolTip(self.trUtf8("Execute the regular expression"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.nextButton = \
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
94 self.buttonBox.addButton(self.trUtf8("Next match"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 QDialogButtonBox.ActionRole)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
96 self.nextButton.setToolTip(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.trUtf8("Show the next match of the regular expression"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.nextButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 if fromEric:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.buttonBox.button(QDialogButtonBox.Close).hide()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.copyButton = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 self.copyButton = \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 self.buttonBox.addButton(self.trUtf8("Copy"), QDialogButtonBox.ActionRole)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
106 self.copyButton.setToolTip(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.trUtf8("Copy the regular expression to the clipboard"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.buttonBox.button(QDialogButtonBox.Ok).hide()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.buttonBox.button(QDialogButtonBox.Cancel).hide()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.variableLabel.hide()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.variableLineEdit.hide()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.variableLine.hide()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.regexpLineEdit.setFocus()
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
114
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
115 @pyqtSlot(int)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
116 def on_syntaxCombo_currentIndexChanged(self, index):
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
117 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
118 Private slot handling the selection of a pattern syntax.
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
119
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
120 @param index index of the selected entry (integer)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
121 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
122 syntax = self.syntaxCombo.itemData(index)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
123 self.regexpButtonsFrame.setVisible(syntax in [
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
124 QRegExp.RegExp, QRegExp.RegExp2])
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
125 self.regexpButtonsFrame.setEnabled(syntax in [
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
126 QRegExp.RegExp, QRegExp.RegExp2])
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
127 self.wildcardButtonsFrame.setVisible(syntax in [
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
128 QRegExp.Wildcard, QRegExp.WildcardUnix])
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
129 self.wildcardButtonsFrame.setEnabled(syntax in [
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
130 QRegExp.Wildcard, QRegExp.WildcardUnix])
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
131 self.w3cButtonsFrame.setVisible(syntax in [QRegExp.W3CXmlSchema11])
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
132 self.w3cButtonsFrame.setEnabled(syntax in [QRegExp.W3CXmlSchema11])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 def __insertString(self, s, steps=0):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 Private method to insert a string into line edit and move cursor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @param s string to be inserted into the regexp line edit
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 @param steps number of characters to move the cursor (integer).
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 Negative steps moves cursor back, positives forward.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 self.regexpLineEdit.insert(s)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 self.regexpLineEdit.cursorForward(False, steps)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 def on_anycharButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 Private slot to handle the any character toolbutton.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 self.__insertString(".")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 def on_nonGroupButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 Private slot to handle the non group toolbutton.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 self.__insertString("(?:)", -1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 def on_groupButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 Private slot to handle the group toolbutton.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 self.__insertString("()", -1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 def on_altnButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 Private slot to handle the alternatives toolbutton.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 self.__insertString("(|)", -2)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 def on_beglineButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 Private slot to handle the begin line toolbutton.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 self.__insertString("^")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 def on_endlineButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 Private slot to handle the end line toolbutton.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.__insertString("$")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 def on_wordboundButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 Private slot to handle the word boundary toolbutton.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 self.__insertString("\\b")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 def on_nonwordboundButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 Private slot to handle the non word boundary toolbutton.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 self.__insertString("\\B")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 def on_poslookaheadButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 Private slot to handle the positive lookahead toolbutton.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 self.__insertString("(?=)", -1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 def on_neglookaheadButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 Private slot to handle the negative lookahead toolbutton.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 self.__insertString("(?!)", -1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 def on_repeatButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 Private slot to handle the repeat toolbutton.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 dlg = QRegExpWizardRepeatDialog(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 if dlg.exec_() == QDialog.Accepted:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 self.__insertString(dlg.getRepeat())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 def on_charButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 Private slot to handle the characters toolbutton.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 """
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
230 dlg = QRegExpWizardCharactersDialog(
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
231 mode=QRegExpWizardCharactersDialog.RegExpMode, parent=self)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
232 if dlg.exec_() == QDialog.Accepted:
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
233 self.__insertString(dlg.getCharacters())
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
234
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
235 @pyqtSlot()
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
236 def on_wildcardCharButton_clicked(self):
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
237 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
238 Private slot to handle the wildcard characters toolbutton.
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
239 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
240 dlg = QRegExpWizardCharactersDialog(
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
241 mode=QRegExpWizardCharactersDialog.WildcardMode, parent=self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 if dlg.exec_() == QDialog.Accepted:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 self.__insertString(dlg.getCharacters())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
245 @pyqtSlot()
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
246 def on_wildcardAnycharButton_clicked(self):
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
247 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
248 Private slot to handle the wildcard any character toolbutton.
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
249 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
250 self.__insertString("?")
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
251
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
252 @pyqtSlot()
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
253 def on_wildcardRepeatButton_clicked(self):
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
254 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
255 Private slot to handle the wildcard multiple characters toolbutton.
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
256 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
257 self.__insertString("*")
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
258
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
259 @pyqtSlot()
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
260 def on_w3cCharButton_clicked(self):
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
261 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
262 Private slot to handle the wildcard characters toolbutton.
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
263 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
264 dlg = QRegExpWizardCharactersDialog(
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
265 mode=QRegExpWizardCharactersDialog.W3CMode, parent=self)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
266 if dlg.exec_() == QDialog.Accepted:
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
267 self.__insertString(dlg.getCharacters())
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
268
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
269 @pyqtSlot()
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
270 def on_w3cAnycharButton_clicked(self):
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
271 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
272 Private slot to handle the W3C any character toolbutton.
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
273 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
274 self.__insertString(".")
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
275
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
276 @pyqtSlot()
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
277 def on_w3cRepeatButton_clicked(self):
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
278 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
279 Private slot to handle the W3C repeat toolbutton.
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
280 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
281 dlg = QRegExpWizardRepeatDialog(self)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
282 if dlg.exec_() == QDialog.Accepted:
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
283 self.__insertString(dlg.getRepeat())
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
284
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
285 @pyqtSlot()
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
286 def on_w3cGroupButton_clicked(self):
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
287 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
288 Private slot to handle the W3C group toolbutton.
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
289 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
290 self.__insertString("()", -1)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
291
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
292 @pyqtSlot()
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
293 def on_w3cAltnButton_clicked(self):
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
294 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
295 Private slot to handle the alternatives toolbutton.
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
296 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
297 self.__insertString("(|)", -2)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
298
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 Private slot called by a button of the button box clicked.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 @param button button that was clicked (QAbstractButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 if button == self.validateButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 self.on_validateButton_clicked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 elif button == self.executeButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 self.on_executeButton_clicked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 elif button == self.saveButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 self.on_saveButton_clicked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 elif button == self.loadButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 self.on_loadButton_clicked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 elif button == self.nextButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 self.on_nextButton_clicked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 elif self.copyButton and button == self.copyButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 self.on_copyButton_clicked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 def on_saveButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 Private slot to save the regexp to a file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 """
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
323 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 self,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 self.trUtf8("Save regular expression"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 "",
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 self.trUtf8("RegExp Files (*.rx);;All Files (*)"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 None,
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
329 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 if fname:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 ext = QFileInfo(fname).suffix()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 if not ext:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 ex = selectedFilter.split("(*")[1].split(")")[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 if ex:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 fname += ex
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 if QFileInfo(fname).exists():
546
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
337 res = E5MessageBox.yesNo(self,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 self.trUtf8("Save regular expression"),
546
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
339 self.trUtf8("<p>The file <b>{0}</b> already exists."
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
340 " Overwrite it?</p>").format(fname),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
341 icon=E5MessageBox.Warning)
546
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
342 if not res:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
345 syntax = self.syntaxCombo.itemData(self.syntaxCombo.currentIndex())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 try:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
347 f = open(Utilities.toNativeSeparators(fname), "w", encoding="utf-8")
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
348 f.write("syntax={0}\n".format(syntax))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 f.write(self.regexpLineEdit.text())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 f.close()
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
351 except IOError as err:
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 465
diff changeset
352 E5MessageBox.information(self,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 self.trUtf8("Save regular expression"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 self.trUtf8("""<p>The regular expression could not be saved.</p>"""
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
355 """<p>Reason: {0}</p>""").format(str(err)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 def on_loadButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 Private slot to load a regexp from a file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 """
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
362 fname = E5FileDialog.getOpenFileName(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 self,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 self.trUtf8("Load regular expression"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 "",
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
366 self.trUtf8("RegExp Files (*.rx);;All Files (*)"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 if fname:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 try:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
369 f = open(Utilities.toNativeSeparators(fname), "r", encoding="utf-8")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 regexp = f.read()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 f.close()
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
372 if regexp.startswith("syntax="):
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
373 lines = regexp.splitlines()
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
374 syntax = int(lines[0].replace("syntax=", ""))
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
375 index = self.syntaxCombo.findData(syntax)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
376 self.syntaxCombo.setCurrentIndex(index)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
377 regexp = lines[1]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 self.regexpLineEdit.setText(regexp)
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
379 except IOError as err:
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 465
diff changeset
380 E5MessageBox.information(self,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 self.trUtf8("Save regular expression"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 self.trUtf8("""<p>The regular expression could not be saved.</p>"""
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
383 """<p>Reason: {0}</p>""").format(str(err)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 def on_copyButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 Private slot to copy the regexp string into the clipboard.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
390 This slot is only available, if not called from within eric5.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 escaped = self.regexpLineEdit.text()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 if escaped:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 escaped = escaped.replace("\\", "\\\\")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 cb = QApplication.clipboard()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 cb.setText(escaped, QClipboard.Clipboard)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 if cb.supportsSelection():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 cb.setText(escaped, QClipboard.Selection)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 def on_validateButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 Private slot to validate the entered regexp.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 regex = self.regexpLineEdit.text()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 if regex:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 re = QRegExp(regex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 if self.caseSensitiveCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 re.setCaseSensitivity(Qt.CaseSensitive)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 re.setCaseSensitivity(Qt.CaseInsensitive)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 re.setMinimal(self.minimalCheckBox.isChecked())
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
413 re.setPatternSyntax(self.syntaxCombo.itemData(self.syntaxCombo.currentIndex()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 if re.isValid():
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 465
diff changeset
415 E5MessageBox.information(self,
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
416 self.trUtf8("Validation"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 self.trUtf8("""The regular expression is valid."""))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 else:
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
419 E5MessageBox.critical(self,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 self.trUtf8("Error"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 self.trUtf8("""Invalid regular expression: {0}""")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 .format(re.errorString()))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 else:
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
425 E5MessageBox.critical(self,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 self.trUtf8("Error"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 self.trUtf8("""A regular expression must be given."""))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 @pyqtSlot()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
430 def on_executeButton_clicked(self, startpos=0):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 Private slot to execute the entered regexp on the test text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 This slot will execute the entered regexp on the entered test
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 data and will display the result in the table part of the dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 @param startpos starting position for the regexp matching
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 regex = self.regexpLineEdit.text()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 text = self.textTextEdit.toPlainText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 if regex and text:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 re = QRegExp(regex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 if self.caseSensitiveCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 re.setCaseSensitivity(Qt.CaseSensitive)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 re.setCaseSensitivity(Qt.CaseInsensitive)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 re.setMinimal(self.minimalCheckBox.isChecked())
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
448 syntax = self.syntaxCombo.itemData(self.syntaxCombo.currentIndex())
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
449 wildcard = syntax in [QRegExp.Wildcard, QRegExp.WildcardUnix]
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
450 re.setPatternSyntax(syntax)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 if not re.isValid():
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
452 E5MessageBox.critical(self,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 self.trUtf8("Error"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 self.trUtf8("""Invalid regular expression: {0}""")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 .format(re.errorString()))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 offset = re.indexIn(text, startpos)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 captures = re.numCaptures()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 row = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 OFFSET = 5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 self.resultTable.setColumnCount(0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 self.resultTable.setColumnCount(3)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 self.resultTable.setRowCount(0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 self.resultTable.setRowCount(OFFSET)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 self.resultTable.setItem(row, 0, QTableWidgetItem(self.trUtf8("Regexp")))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 self.resultTable.setItem(row, 1, QTableWidgetItem(regex))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 if offset != -1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 self.lastMatchEnd = offset + re.matchedLength()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 self.nextButton.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 row += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 self.resultTable.setItem(row, 0, QTableWidgetItem(self.trUtf8("Offset")))
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
474 self.resultTable.setItem(row, 1, QTableWidgetItem("{0:d}".format(offset)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 if not wildcard:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 row += 1
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
478 self.resultTable.setItem(row, 0,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 QTableWidgetItem(self.trUtf8("Captures")))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
480 self.resultTable.setItem(row, 1,
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
481 QTableWidgetItem("{0:d}".format(captures)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 row += 1
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
483 self.resultTable.setItem(row, 1,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 QTableWidgetItem(self.trUtf8("Text")))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
485 self.resultTable.setItem(row, 2,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 QTableWidgetItem(self.trUtf8("Characters")))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 row += 1
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
489 self.resultTable.setItem(row, 0,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 QTableWidgetItem(self.trUtf8("Match")))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
491 self.resultTable.setItem(row, 1,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 QTableWidgetItem(re.cap(0)))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
493 self.resultTable.setItem(row, 2,
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
494 QTableWidgetItem("{0:d}".format(re.matchedLength())))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 if not wildcard:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 for i in range(1, captures + 1):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 if len(re.cap(i)) > 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 row += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 self.resultTable.insertRow(row)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
501 self.resultTable.setItem(row, 0,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 QTableWidgetItem(self.trUtf8("Capture #{0}").format(i)))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
503 self.resultTable.setItem(row, 1,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 QTableWidgetItem(re.cap(i)))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
505 self.resultTable.setItem(row, 2,
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
506 QTableWidgetItem("{0:d}".format(len(re.cap(i)))))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 self.resultTable.setRowCount(3)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 # highlight the matched text
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 tc = self.textTextEdit.textCursor()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 tc.setPosition(offset)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 tc.setPosition(self.lastMatchEnd, QTextCursor.KeepAnchor)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 self.textTextEdit.setTextCursor(tc)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 self.nextButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 self.resultTable.setRowCount(2)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518 row += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 if startpos > 0:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
520 self.resultTable.setItem(row, 0,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 QTableWidgetItem(self.trUtf8("No more matches")))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 else:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
523 self.resultTable.setItem(row, 0,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 QTableWidgetItem(self.trUtf8("No matches")))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 # remove the highlight
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 tc = self.textTextEdit.textCursor()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 tc.setPosition(0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 self.textTextEdit.setTextCursor(tc)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 self.resultTable.resizeColumnsToContents()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 self.resultTable.resizeRowsToContents()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 self.resultTable.verticalHeader().hide()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 self.resultTable.horizontalHeader().hide()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 else:
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
536 E5MessageBox.critical(self,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 self.trUtf8("Error"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 self.trUtf8("""A regular expression and a text must be given."""))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 def on_nextButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 Private slot to find the next match.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 self.on_executeButton_clicked(self.lastMatchEnd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 def on_regexpLineEdit_textChanged(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 Private slot called when the regexp changes.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 @param txt the new text of the line edit (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 self.nextButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
555 def __getPatternSyntaxCode(self, syntaxValue):
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
556 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
557 Private method to convert a pattern syntax value into a pattern syntax string.
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
558
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
559 @param syntaxValue pattern syntax value (integer)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
560 @return pattern syntax string (string)
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
561 """
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
562 syntax = "QRegExp."
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
563 if syntaxValue == QRegExp.RegExp:
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
564 syntax += "RegExp"
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
565 elif syntaxValue == QRegExp.RegExp2:
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
566 syntax += "RegExp2"
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
567 elif syntaxValue == QRegExp.Wildcard:
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
568 syntax += "Wildcard"
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
569 elif syntaxValue == QRegExp.WildcardUnix:
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
570 syntax += "WildcardUnix"
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
571 elif syntaxValue == QRegExp.FixedString:
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
572 syntax += "FixedString"
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
573 elif syntaxValue == QRegExp.W3CXmlSchema11:
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
574 syntax += "W3CXmlSchema11"
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
575 return syntax
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
576
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 def getCode(self, indLevel, indString):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 Public method to get the source code.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
581 @param indLevel indentation level (int)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
582 @param indString string used for indentation (space or tab) (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
583 @return generated code (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 # calculate the indentation string
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 istring = indLevel * indString
446
69aac6eeba9b Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
587 estring = os.linesep + indLevel * indString
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
588
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589 # now generate the code
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590 reVar = self.variableLineEdit.text()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 if not reVar:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 reVar = "regexp"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 regexp = self.regexpLineEdit.text()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
596 code = '{0} = QRegExp(r"""{1}"""){2}'.format(
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
597 reVar, regexp.replace('"', '\\"'), os.linesep)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598 if not self.caseSensitiveCheckBox.isChecked():
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
599 code += '{0}{1}.setCaseSensitivity(Qt.CaseInsensitive){2}'.format(
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
600 istring, reVar, os.linesep)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601 if self.minimalCheckBox.isChecked():
446
69aac6eeba9b Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
602 code += '{0}{1}.setMinimal(True){2}'.format(istring, reVar, os.linesep)
1818
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
603 syntax = self.syntaxCombo.itemData(self.syntaxCombo.currentIndex())
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
604 needPatternSyntax = True
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
605 if qVersion() < "5.0.0" and syntax == QRegExp.RegExp or \
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
606 qVersion() >= "5.0.0" and syntax == QRegExp.RegExp2:
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
607 # default value selected
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
608 needPatternSyntax = False
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
609 if needPatternSyntax:
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
610 code += '{0}{1}.setPatternSyntax({2}){3}'.format(
a5e4cb4bed43 Added support for the various pattern syntaxes to the QRegExp wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
611 istring, reVar, self.__getPatternSyntaxCode(syntax), estring)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 return code
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
614
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 class QRegExpWizardDialog(QDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
616 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
617 Class for the dialog variant.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
619 def __init__(self, parent=None, fromEric=True):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 @param parent parent widget (QWidget)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
624 @param fromEric flag indicating a call from within eric5
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
626 super().__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 self.setModal(fromEric)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 self.setSizeGripEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 self.__layout = QVBoxLayout(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 self.__layout.setMargin(0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 self.setLayout(self.__layout)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 self.cw = QRegExpWizardWidget(self, fromEric)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 size = self.cw.size()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 self.__layout.addWidget(self.cw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 self.resize(size)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638
465
c20e25deb33a Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 446
diff changeset
639 self.cw.buttonBox.accepted[()].connect(self.accept)
c20e25deb33a Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 446
diff changeset
640 self.cw.buttonBox.rejected[()].connect(self.reject)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
641
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642 def getCode(self, indLevel, indString):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 Public method to get the source code.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646 @param indLevel indentation level (int)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
647 @param indString string used for indentation (space or tab) (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
648 @return generated code (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
649 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650 return self.cw.getCode(indLevel, indString)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
652
2101
5bac7dee9e1a Introduced the E5MainWindow class allowing to set a style for all the main windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1818
diff changeset
653 class QRegExpWizardWindow(E5MainWindow):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655 Main window class for the standalone dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
657 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 @param parent reference to the parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
663 super().__init__(parent)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
664 self.cw = QRegExpWizardWidget(self, fromEric=False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 size = self.cw.size()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666 self.setCentralWidget(self.cw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667 self.resize(size)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668
2101
5bac7dee9e1a Introduced the E5MainWindow class allowing to set a style for all the main windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1818
diff changeset
669 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
5bac7dee9e1a Introduced the E5MainWindow class allowing to set a style for all the main windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1818
diff changeset
670
465
c20e25deb33a Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 446
diff changeset
671 self.cw.buttonBox.accepted[()].connect(self.close)
880
52ed20236a1c Added the option to not use the native file dialog to prevent crashes on Linux.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
672 self.cw.buttonBox.rejected[()].connect(self.close)

eric ide

mercurial