8 """ |
8 """ |
9 |
9 |
10 |
10 |
11 from PyQt5.QtCore import QRegExp |
11 from PyQt5.QtCore import QRegExp |
12 from PyQt5.QtGui import QRegExpValidator |
12 from PyQt5.QtGui import QRegExpValidator |
13 from PyQt5.QtWidgets import QWidget, QDialog, QVBoxLayout, QHBoxLayout, \ |
13 from PyQt5.QtWidgets import ( |
14 QScrollArea, QPushButton, QSpacerItem, QSizePolicy, QComboBox, QLineEdit, \ |
14 QWidget, QDialog, QVBoxLayout, QHBoxLayout, QScrollArea, QPushButton, |
15 QLabel |
15 QSpacerItem, QSizePolicy, QComboBox, QLineEdit, QLabel |
16 |
16 ) |
17 from .Ui_QRegularExpressionWizardCharactersDialog import \ |
17 |
|
18 from .Ui_QRegularExpressionWizardCharactersDialog import ( |
18 Ui_QRegularExpressionWizardCharactersDialog |
19 Ui_QRegularExpressionWizardCharactersDialog |
|
20 ) |
19 |
21 |
20 |
22 |
21 class QRegularExpressionWizardCharactersDialog( |
23 class QRegularExpressionWizardCharactersDialog( |
22 QDialog, Ui_QRegularExpressionWizardCharactersDialog): |
24 QDialog, Ui_QRegularExpressionWizardCharactersDialog): |
23 """ |
25 """ |
590 char = entrieslist[1].text() |
592 char = entrieslist[1].text() |
591 regexp += self.__formatCharacter(char, formatIdentifier) |
593 regexp += self.__formatCharacter(char, formatIdentifier) |
592 |
594 |
593 # character ranges |
595 # character ranges |
594 for entrieslist in self.rangesEntries: |
596 for entrieslist in self.rangesEntries: |
595 if not entrieslist[1].text() or \ |
597 if ( |
596 not entrieslist[2].text(): |
598 not entrieslist[1].text() or |
|
599 not entrieslist[2].text() |
|
600 ): |
597 continue |
601 continue |
598 formatIdentifier = entrieslist[0].itemData( |
602 formatIdentifier = entrieslist[0].itemData( |
599 entrieslist[0].currentIndex()) |
603 entrieslist[0].currentIndex()) |
600 char1 = entrieslist[1].text() |
604 char1 = entrieslist[1].text() |
601 char2 = entrieslist[2].text() |
605 char2 = entrieslist[2].text() |
602 regexp += "{0}-{1}".format( |
606 regexp += "{0}-{1}".format( |
603 self.__formatCharacter(char1, formatIdentifier), |
607 self.__formatCharacter(char1, formatIdentifier), |
604 self.__formatCharacter(char2, formatIdentifier)) |
608 self.__formatCharacter(char2, formatIdentifier)) |
605 |
609 |
606 if regexp: |
610 if regexp: |
607 if (regexp.startswith("\\") and |
611 if ( |
608 regexp.count("\\") == 1 and |
612 (regexp.startswith("\\") and |
609 "-" not in regexp) or \ |
613 regexp.count("\\") == 1 and |
610 len(regexp) == 1: |
614 "-" not in regexp) or |
|
615 len(regexp) == 1 |
|
616 ): |
611 return regexp |
617 return regexp |
612 else: |
618 else: |
613 return "[{0}]".format(regexp) |
619 return "[{0}]".format(regexp) |
614 else: |
620 else: |
615 return "" |
621 return "" |