eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py

changeset 8143
2c730d5fd177
parent 7960
e8fc383322f7
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
71 self.redoButton.setIcon(UI.PixmapCache.getIcon("editRedo")) 71 self.redoButton.setIcon(UI.PixmapCache.getIcon("editRedo"))
72 72
73 self.namedGroups = re.compile(r"""\(?P<([^>]+)>""").findall 73 self.namedGroups = re.compile(r"""\(?P<([^>]+)>""").findall
74 74
75 self.saveButton = self.buttonBox.addButton( 75 self.saveButton = self.buttonBox.addButton(
76 self.tr("Save"), QDialogButtonBox.ActionRole) 76 self.tr("Save"), QDialogButtonBox.ButtonRole.ActionRole)
77 self.saveButton.setToolTip( 77 self.saveButton.setToolTip(
78 self.tr("Save the regular expression to a file")) 78 self.tr("Save the regular expression to a file"))
79 self.loadButton = self.buttonBox.addButton( 79 self.loadButton = self.buttonBox.addButton(
80 self.tr("Load"), QDialogButtonBox.ActionRole) 80 self.tr("Load"), QDialogButtonBox.ButtonRole.ActionRole)
81 self.loadButton.setToolTip( 81 self.loadButton.setToolTip(
82 self.tr("Load a regular expression from a file")) 82 self.tr("Load a regular expression from a file"))
83 self.validateButton = self.buttonBox.addButton( 83 self.validateButton = self.buttonBox.addButton(
84 self.tr("Validate"), QDialogButtonBox.ActionRole) 84 self.tr("Validate"), QDialogButtonBox.ButtonRole.ActionRole)
85 self.validateButton.setToolTip( 85 self.validateButton.setToolTip(
86 self.tr("Validate the regular expression")) 86 self.tr("Validate the regular expression"))
87 self.executeButton = self.buttonBox.addButton( 87 self.executeButton = self.buttonBox.addButton(
88 self.tr("Execute"), QDialogButtonBox.ActionRole) 88 self.tr("Execute"), QDialogButtonBox.ButtonRole.ActionRole)
89 self.executeButton.setToolTip( 89 self.executeButton.setToolTip(
90 self.tr("Execute the regular expression")) 90 self.tr("Execute the regular expression"))
91 self.nextButton = self.buttonBox.addButton( 91 self.nextButton = self.buttonBox.addButton(
92 self.tr("Next match"), QDialogButtonBox.ActionRole) 92 self.tr("Next match"), QDialogButtonBox.ButtonRole.ActionRole)
93 self.nextButton.setToolTip( 93 self.nextButton.setToolTip(
94 self.tr("Show the next match of the regular expression")) 94 self.tr("Show the next match of the regular expression"))
95 self.nextButton.setEnabled(False) 95 self.nextButton.setEnabled(False)
96 96
97 if fromEric: 97 if fromEric:
98 self.buttonBox.setStandardButtons( 98 self.buttonBox.setStandardButtons(
99 QDialogButtonBox.Cancel | QDialogButtonBox.Ok) 99 QDialogButtonBox.StandardButton.Cancel |
100 QDialogButtonBox.StandardButton.Ok)
100 self.copyButton = None 101 self.copyButton = None
101 else: 102 else:
102 self.copyButton = self.buttonBox.addButton( 103 self.copyButton = self.buttonBox.addButton(
103 self.tr("Copy"), QDialogButtonBox.ActionRole) 104 self.tr("Copy"), QDialogButtonBox.ButtonRole.ActionRole)
104 self.copyButton.setToolTip( 105 self.copyButton.setToolTip(
105 self.tr("Copy the regular expression to the clipboard")) 106 self.tr("Copy the regular expression to the clipboard"))
106 self.buttonBox.setStandardButtons(QDialogButtonBox.Close) 107 self.buttonBox.setStandardButtons(
108 QDialogButtonBox.StandardButton.Close)
107 self.variableLabel.hide() 109 self.variableLabel.hide()
108 self.variableLineEdit.hide() 110 self.variableLineEdit.hide()
109 self.variableLine.hide() 111 self.variableLine.hide()
110 self.importCheckBox.hide() 112 self.importCheckBox.hide()
111 self.regexpTextEdit.setFocus() 113 self.regexpTextEdit.setFocus()
121 """ 123 """
122 self.regexpTextEdit.insertPlainText(s) 124 self.regexpTextEdit.insertPlainText(s)
123 tc = self.regexpTextEdit.textCursor() 125 tc = self.regexpTextEdit.textCursor()
124 if steps != 0: 126 if steps != 0:
125 if steps < 0: 127 if steps < 0:
126 act = QTextCursor.Left 128 act = QTextCursor.MoveOperation.Left
127 steps = abs(steps) 129 steps = abs(steps)
128 else: 130 else:
129 act = QTextCursor.Right 131 act = QTextCursor.MoveOperation.Right
130 for _ in range(steps): 132 for _ in range(steps):
131 tc.movePosition(act) 133 tc.movePosition(act)
132 self.regexpTextEdit.setTextCursor(tc) 134 self.regexpTextEdit.setTextCursor(tc)
133 135
134 @pyqtSlot() 136 @pyqtSlot()
262 """ 264 """
263 Private slot to handle the repeat toolbutton. 265 Private slot to handle the repeat toolbutton.
264 """ 266 """
265 from .PyRegExpWizardRepeatDialog import PyRegExpWizardRepeatDialog 267 from .PyRegExpWizardRepeatDialog import PyRegExpWizardRepeatDialog
266 dlg = PyRegExpWizardRepeatDialog(self) 268 dlg = PyRegExpWizardRepeatDialog(self)
267 if dlg.exec() == QDialog.Accepted: 269 if dlg.exec() == QDialog.DialogCode.Accepted:
268 self.__insertString(dlg.getRepeat()) 270 self.__insertString(dlg.getRepeat())
269 271
270 @pyqtSlot() 272 @pyqtSlot()
271 def on_charButton_clicked(self): 273 def on_charButton_clicked(self):
272 """ 274 """
274 """ 276 """
275 from .PyRegExpWizardCharactersDialog import ( 277 from .PyRegExpWizardCharactersDialog import (
276 PyRegExpWizardCharactersDialog 278 PyRegExpWizardCharactersDialog
277 ) 279 )
278 dlg = PyRegExpWizardCharactersDialog(self) 280 dlg = PyRegExpWizardCharactersDialog(self)
279 if dlg.exec() == QDialog.Accepted: 281 if dlg.exec() == QDialog.DialogCode.Accepted:
280 self.__insertString(dlg.getCharacters()) 282 self.__insertString(dlg.getCharacters())
281 283
282 @pyqtSlot() 284 @pyqtSlot()
283 def on_undoButton_clicked(self): 285 def on_undoButton_clicked(self):
284 """ 286 """
385 """ 387 """
386 escaped = self.regexpTextEdit.toPlainText() 388 escaped = self.regexpTextEdit.toPlainText()
387 if escaped: 389 if escaped:
388 escaped = escaped.replace("\\", "\\\\") 390 escaped = escaped.replace("\\", "\\\\")
389 cb = QApplication.clipboard() 391 cb = QApplication.clipboard()
390 cb.setText(escaped, QClipboard.Clipboard) 392 cb.setText(escaped, QClipboard.Mode.Clipboard)
391 if cb.supportsSelection(): 393 if cb.supportsSelection():
392 cb.setText(escaped, QClipboard.Selection) 394 cb.setText(escaped, QClipboard.Mode.Selection)
393 395
394 @pyqtSlot() 396 @pyqtSlot()
395 def on_validateButton_clicked(self): 397 def on_validateButton_clicked(self):
396 """ 398 """
397 Private slot to validate the entered regexp. 399 Private slot to validate the entered regexp.
534 "{0:d}".format(len(matchobj.group(i))))) 536 "{0:d}".format(len(matchobj.group(i)))))
535 537
536 # highlight the matched text 538 # highlight the matched text
537 tc = self.textTextEdit.textCursor() 539 tc = self.textTextEdit.textCursor()
538 tc.setPosition(offset) 540 tc.setPosition(offset)
539 tc.setPosition(self.lastMatchEnd, QTextCursor.KeepAnchor) 541 tc.setPosition(self.lastMatchEnd,
542 QTextCursor.MoveMode.KeepAnchor)
540 self.textTextEdit.setTextCursor(tc) 543 self.textTextEdit.setTextCursor(tc)
541 else: 544 else:
542 self.nextButton.setEnabled(False) 545 self.nextButton.setEnabled(False)
543 self.resultTable.setRowCount(2) 546 self.resultTable.setRowCount(2)
544 row += 1 547 row += 1

eric ide

mercurial