9 |
9 |
10 from PyQt6.QtCore import pyqtSlot |
10 from PyQt6.QtCore import pyqtSlot |
11 from PyQt6.QtWidgets import QDialog |
11 from PyQt6.QtWidgets import QDialog |
12 |
12 |
13 from .Ui_QRegularExpressionWizardRepeatDialog import ( |
13 from .Ui_QRegularExpressionWizardRepeatDialog import ( |
14 Ui_QRegularExpressionWizardRepeatDialog |
14 Ui_QRegularExpressionWizardRepeatDialog, |
15 ) |
15 ) |
16 |
16 |
17 |
17 |
18 class QRegularExpressionWizardRepeatDialog( |
18 class QRegularExpressionWizardRepeatDialog( |
19 QDialog, Ui_QRegularExpressionWizardRepeatDialog): |
19 QDialog, Ui_QRegularExpressionWizardRepeatDialog |
|
20 ): |
20 """ |
21 """ |
21 Class implementing a dialog for entering repeat counts. |
22 Class implementing a dialog for entering repeat counts. |
22 """ |
23 """ |
|
24 |
23 def __init__(self, parent=None): |
25 def __init__(self, parent=None): |
24 """ |
26 """ |
25 Constructor |
27 Constructor |
26 |
28 |
27 @param parent reference to the parent widget (QWidget) |
29 @param parent reference to the parent widget (QWidget) |
28 """ |
30 """ |
29 super().__init__(parent) |
31 super().__init__(parent) |
30 self.setupUi(self) |
32 self.setupUi(self) |
31 |
33 |
32 self.unlimitedButton.setChecked(True) |
34 self.unlimitedButton.setChecked(True) |
33 self.greedyButton.setChecked(True) |
35 self.greedyButton.setChecked(True) |
34 |
36 |
35 msh = self.minimumSizeHint() |
37 msh = self.minimumSizeHint() |
36 self.resize(max(self.width(), msh.width()), msh.height()) |
38 self.resize(max(self.width(), msh.width()), msh.height()) |
37 |
39 |
38 @pyqtSlot(int) |
40 @pyqtSlot(int) |
39 def on_lowerSpin_valueChanged(self, value): |
41 def on_lowerSpin_valueChanged(self, value): |
40 """ |
42 """ |
41 Private slot to handle the lowerSpin valueChanged signal. |
43 Private slot to handle the lowerSpin valueChanged signal. |
42 |
44 |
43 @param value value of the spinbox (integer) |
45 @param value value of the spinbox (integer) |
44 """ |
46 """ |
45 if self.upperSpin.value() < value: |
47 if self.upperSpin.value() < value: |
46 self.upperSpin.setValue(value) |
48 self.upperSpin.setValue(value) |
47 |
49 |
48 @pyqtSlot(int) |
50 @pyqtSlot(int) |
49 def on_upperSpin_valueChanged(self, value): |
51 def on_upperSpin_valueChanged(self, value): |
50 """ |
52 """ |
51 Private slot to handle the upperSpin valueChanged signal. |
53 Private slot to handle the upperSpin valueChanged signal. |
52 |
54 |
53 @param value value of the spinbox (integer) |
55 @param value value of the spinbox (integer) |
54 """ |
56 """ |
55 if self.lowerSpin.value() > value: |
57 if self.lowerSpin.value() > value: |
56 self.lowerSpin.setValue(value) |
58 self.lowerSpin.setValue(value) |
57 |
59 |
58 def getRepeat(self): |
60 def getRepeat(self): |
59 """ |
61 """ |
60 Public method to retrieve the dialog's result. |
62 Public method to retrieve the dialog's result. |
61 |
63 |
62 @return ready formatted repeat string (string) |
64 @return ready formatted repeat string (string) |
63 """ |
65 """ |
64 if self.possessiveButton.isChecked(): |
66 if self.possessiveButton.isChecked(): |
65 greedy = "+" |
67 greedy = "+" |
66 elif self.lazyButton.isChecked(): |
68 elif self.lazyButton.isChecked(): |
67 greedy = "?" |
69 greedy = "?" |
68 else: |
70 else: |
69 greedy = "" |
71 greedy = "" |
70 |
72 |
71 if self.unlimitedButton.isChecked(): |
73 if self.unlimitedButton.isChecked(): |
72 return "*" + greedy |
74 return "*" + greedy |
73 elif self.minButton.isChecked(): |
75 elif self.minButton.isChecked(): |
74 reps = self.minSpin.value() |
76 reps = self.minSpin.value() |
75 if reps == 1: |
77 if reps == 1: |