14 |
14 |
15 class EditWatchpointDialog(QDialog, Ui_EditWatchpointDialog): |
15 class EditWatchpointDialog(QDialog, Ui_EditWatchpointDialog): |
16 """ |
16 """ |
17 Class implementing a dialog to edit watch expression properties. |
17 Class implementing a dialog to edit watch expression properties. |
18 """ |
18 """ |
|
19 |
19 def __init__(self, properties, parent=None, name=None, modal=False): |
20 def __init__(self, properties, parent=None, name=None, modal=False): |
20 """ |
21 """ |
21 Constructor |
22 Constructor |
22 |
23 |
23 @param properties properties for the watch expression (tuple) |
24 @param properties properties for the watch expression (tuple) |
24 (expression, temporary flag, enabled flag, ignore count, |
25 (expression, temporary flag, enabled flag, ignore count, |
25 special condition) |
26 special condition) |
26 @param parent the parent of this dialog |
27 @param parent the parent of this dialog |
27 @param name the widget name of this dialog |
28 @param name the widget name of this dialog |
30 super().__init__(parent) |
31 super().__init__(parent) |
31 self.setupUi(self) |
32 self.setupUi(self) |
32 if name: |
33 if name: |
33 self.setObjectName(name) |
34 self.setObjectName(name) |
34 self.setModal(modal) |
35 self.setModal(modal) |
35 |
36 |
36 self.buttonBox.button( |
37 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
37 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
38 |
38 |
|
39 # connect our widgets |
39 # connect our widgets |
40 self.conditionEdit.textChanged.connect(self.__textChanged) |
40 self.conditionEdit.textChanged.connect(self.__textChanged) |
41 self.specialEdit.textChanged.connect(self.__textChanged) |
41 self.specialEdit.textChanged.connect(self.__textChanged) |
42 |
42 |
43 cond, temp, enabled, count, special = properties |
43 cond, temp, enabled, count, special = properties |
44 |
44 |
45 # set the condition |
45 # set the condition |
46 if not special: |
46 if not special: |
47 self.conditionButton.setChecked(True) |
47 self.conditionButton.setChecked(True) |
48 self.conditionEdit.setText(cond) |
48 self.conditionEdit.setText(cond) |
49 else: |
49 else: |
51 self.specialEdit.setText(cond) |
51 self.specialEdit.setText(cond) |
52 ind = self.specialCombo.findText(special) |
52 ind = self.specialCombo.findText(special) |
53 if ind == -1: |
53 if ind == -1: |
54 ind = 0 |
54 ind = 0 |
55 self.specialCombo.setCurrentIndex(ind) |
55 self.specialCombo.setCurrentIndex(ind) |
56 |
56 |
57 # set the ignore count |
57 # set the ignore count |
58 self.ignoreSpinBox.setValue(count) |
58 self.ignoreSpinBox.setValue(count) |
59 |
59 |
60 # set the checkboxes |
60 # set the checkboxes |
61 self.temporaryCheckBox.setChecked(temp) |
61 self.temporaryCheckBox.setChecked(temp) |
62 self.enabledCheckBox.setChecked(enabled) |
62 self.enabledCheckBox.setChecked(enabled) |
63 |
63 |
64 if not special: |
64 if not special: |
65 self.conditionEdit.setFocus() |
65 self.conditionEdit.setFocus() |
66 else: |
66 else: |
67 self.specialEdit.setFocus() |
67 self.specialEdit.setFocus() |
68 |
68 |
69 msh = self.minimumSizeHint() |
69 msh = self.minimumSizeHint() |
70 self.resize(max(self.width(), msh.width()), msh.height()) |
70 self.resize(max(self.width(), msh.width()), msh.height()) |
71 |
71 |
72 def __textChanged(self, txt): |
72 def __textChanged(self, txt): |
73 """ |
73 """ |
74 Private slot to handle the text changed signal of the condition line |
74 Private slot to handle the text changed signal of the condition line |
75 edit. |
75 edit. |
76 |
76 |
77 @param txt text of the line edit (string) |
77 @param txt text of the line edit (string) |
78 """ |
78 """ |
79 if self.conditionButton.isChecked(): |
79 if self.conditionButton.isChecked(): |
80 self.buttonBox.button( |
80 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
81 QDialogButtonBox.StandardButton.Ok |
81 self.conditionEdit.text() != "" |
82 ).setEnabled(self.conditionEdit.text() != "") |
82 ) |
83 elif self.specialButton.isChecked(): |
83 elif self.specialButton.isChecked(): |
84 self.buttonBox.button( |
84 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
85 QDialogButtonBox.StandardButton.Ok |
85 self.specialEdit.text() != "" |
86 ).setEnabled(self.specialEdit.text() != "") |
86 ) |
87 else: |
87 else: |
88 # should not happen |
88 # should not happen |
89 self.buttonBox.button( |
89 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
90 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
90 |
91 |
|
92 def getData(self): |
91 def getData(self): |
93 """ |
92 """ |
94 Public method to retrieve the entered data. |
93 Public method to retrieve the entered data. |
95 |
94 |
96 @return a tuple containing the watch expressions new properties |
95 @return a tuple containing the watch expressions new properties |
97 (expression, temporary flag, enabled flag, ignore count, |
96 (expression, temporary flag, enabled flag, ignore count, |
98 special condition) |
97 special condition) |
99 """ |
98 """ |
100 if self.conditionButton.isChecked(): |
99 if self.conditionButton.isChecked(): |
101 return (self.conditionEdit.text(), |
100 return ( |
102 self.temporaryCheckBox.isChecked(), |
101 self.conditionEdit.text(), |
103 self.enabledCheckBox.isChecked(), |
102 self.temporaryCheckBox.isChecked(), |
104 self.ignoreSpinBox.value(), |
103 self.enabledCheckBox.isChecked(), |
105 "") |
104 self.ignoreSpinBox.value(), |
|
105 "", |
|
106 ) |
106 elif self.specialButton.isChecked(): |
107 elif self.specialButton.isChecked(): |
107 return (self.specialEdit.text(), |
108 return ( |
108 self.temporaryCheckBox.isChecked(), |
109 self.specialEdit.text(), |
109 self.enabledCheckBox.isChecked(), |
110 self.temporaryCheckBox.isChecked(), |
110 self.ignoreSpinBox.value(), |
111 self.enabledCheckBox.isChecked(), |
111 self.specialCombo.currentText()) |
112 self.ignoreSpinBox.value(), |
|
113 self.specialCombo.currentText(), |
|
114 ) |
112 else: |
115 else: |
113 # should not happen |
116 # should not happen |
114 return ("", False, False, 0, "") |
117 return ("", False, False, 0, "") |