Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardRepeatDialog.py

changeset 0
de9c2efb9d02
child 12
1d8dd9706f46
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2004 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog for entering repeat counts.
8 """
9
10 from PyQt4.QtCore import *
11 from PyQt4.QtGui import *
12
13 from Ui_QRegExpWizardRepeatDialog import Ui_QRegExpWizardRepeatDialog
14
15
16 class QRegExpWizardRepeatDialog(QDialog, Ui_QRegExpWizardRepeatDialog):
17 """
18 Class implementing a dialog for entering repeat counts.
19 """
20 def __init__(self,parent = None):
21 """
22 Constructor
23
24 @param parent parent widget (QWidget)
25 """
26 QDialog.__init__(self,parent)
27 self.setupUi(self)
28
29 self.unlimitedButton.setChecked(True)
30
31 @pyqtSlot(int)
32 def on_lowerSpin_valueChanged(self, value):
33 """
34 Private slot to handle the lowerSpin valueChanged signal.
35
36 @param value value of the spinbox (integer)
37 """
38 if self.upperSpin.value() < value:
39 self.upperSpin.setValue(value)
40
41 @pyqtSlot(int)
42 def on_upperSpin_valueChanged(self, value):
43 """
44 Private slot to handle the upperSpin valueChanged signal.
45
46 @param value value of the spinbox (integer)
47 """
48 if self.lowerSpin.value() > value:
49 self.lowerSpin.setValue(value)
50
51 def getRepeat(self):
52 """
53 Public method to retrieve the dialog's result.
54
55 @return ready formatted repeat string (string)
56 """
57 if self.unlimitedButton.isChecked():
58 return "*"
59 elif self.minButton.isChecked():
60 reps = self.minSpin.value()
61 if reps == 1:
62 return "+"
63 else:
64 return "{%d,}" % reps
65 elif self.maxButton.isChecked():
66 reps = self.maxSpin.value()
67 if reps == 1:
68 return "?"
69 else:
70 return "{,%d}" % reps
71 elif self.exactButton.isChecked():
72 reps = self.exactSpin.value()
73 return "{%d}" % reps
74 elif self.betweenButton.isChecked():
75 repsMin = self.lowerSpin.value()
76 repsMax = self.upperSpin.value()
77 return "{%d,%d}" % (repsMin, repsMax)

eric ide

mercurial