18 |
18 |
19 class EditBreakpointDialog(QDialog, Ui_EditBreakpointDialog): |
19 class EditBreakpointDialog(QDialog, Ui_EditBreakpointDialog): |
20 """ |
20 """ |
21 Class implementing a dialog to edit breakpoint properties. |
21 Class implementing a dialog to edit breakpoint properties. |
22 """ |
22 """ |
23 def __init__(self, breakPointId, properties, condHistory, parent=None, |
23 |
24 name=None, modal=False, addMode=False, filenameHistory=None): |
24 def __init__( |
|
25 self, |
|
26 breakPointId, |
|
27 properties, |
|
28 condHistory, |
|
29 parent=None, |
|
30 name=None, |
|
31 modal=False, |
|
32 addMode=False, |
|
33 filenameHistory=None, |
|
34 ): |
25 """ |
35 """ |
26 Constructor |
36 Constructor |
27 |
37 |
28 @param breakPointId id of the breakpoint (tuple) |
38 @param breakPointId id of the breakpoint (tuple) |
29 (filename, linenumber) |
39 (filename, linenumber) |
30 @param properties properties for the breakpoint (tuple) |
40 @param properties properties for the breakpoint (tuple) |
31 (condition, temporary flag, enabled flag, ignore count) |
41 (condition, temporary flag, enabled flag, ignore count) |
32 @param condHistory the list of conditionals history (list of strings) |
42 @param condHistory the list of conditionals history (list of strings) |
40 super().__init__(parent) |
50 super().__init__(parent) |
41 self.setupUi(self) |
51 self.setupUi(self) |
42 if name: |
52 if name: |
43 self.setObjectName(name) |
53 self.setObjectName(name) |
44 self.setModal(modal) |
54 self.setModal(modal) |
45 |
55 |
46 self.filenamePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
56 self.filenamePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
47 self.filenamePicker.setSizeAdjustPolicy( |
57 self.filenamePicker.setSizeAdjustPolicy( |
48 QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon) |
58 QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon |
49 |
59 ) |
50 self.okButton = self.buttonBox.button( |
60 |
51 QDialogButtonBox.StandardButton.Ok) |
61 self.okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok) |
52 |
62 |
53 fn, lineno = breakPointId |
63 fn, lineno = breakPointId |
54 |
64 |
55 if not addMode: |
65 if not addMode: |
56 cond, temp, enabled, count = properties |
66 cond, temp, enabled, count = properties |
57 |
67 |
58 # set the filename |
68 # set the filename |
59 if fn is not None: |
69 if fn is not None: |
60 self.filenamePicker.setEditText(fn) |
70 self.filenamePicker.setEditText(fn) |
61 |
71 |
62 # set the line number |
72 # set the line number |
63 self.linenoSpinBox.setValue(lineno) |
73 self.linenoSpinBox.setValue(lineno) |
64 |
74 |
65 # set the condition |
75 # set the condition |
66 if cond is None: |
76 if cond is None: |
67 cond = '' |
77 cond = "" |
68 try: |
78 try: |
69 curr = condHistory.index(cond) |
79 curr = condHistory.index(cond) |
70 except ValueError: |
80 except ValueError: |
71 condHistory.insert(0, cond) |
81 condHistory.insert(0, cond) |
72 curr = 0 |
82 curr = 0 |
73 self.conditionCombo.addItems(condHistory) |
83 self.conditionCombo.addItems(condHistory) |
74 self.conditionCombo.setCurrentIndex(curr) |
84 self.conditionCombo.setCurrentIndex(curr) |
75 |
85 |
76 # set the ignore count |
86 # set the ignore count |
77 self.ignoreSpinBox.setValue(count) |
87 self.ignoreSpinBox.setValue(count) |
78 |
88 |
79 # set the checkboxes |
89 # set the checkboxes |
80 self.temporaryCheckBox.setChecked(temp) |
90 self.temporaryCheckBox.setChecked(temp) |
81 self.enabledCheckBox.setChecked(enabled) |
91 self.enabledCheckBox.setChecked(enabled) |
82 |
92 |
83 self.filenamePicker.setEnabled(False) |
93 self.filenamePicker.setEnabled(False) |
84 self.linenoSpinBox.setEnabled(False) |
94 self.linenoSpinBox.setEnabled(False) |
85 self.conditionCombo.setFocus() |
95 self.conditionCombo.setFocus() |
86 else: |
96 else: |
87 self.setWindowTitle(self.tr("Add Breakpoint")) |
97 self.setWindowTitle(self.tr("Add Breakpoint")) |
93 except ValueError: |
103 except ValueError: |
94 filenameHistory.insert(0, fn) |
104 filenameHistory.insert(0, fn) |
95 curr = 0 |
105 curr = 0 |
96 self.filenamePicker.addItems(filenameHistory) |
106 self.filenamePicker.addItems(filenameHistory) |
97 self.filenamePicker.setCurrentIndex(curr) |
107 self.filenamePicker.setCurrentIndex(curr) |
98 |
108 |
99 # set the condition |
109 # set the condition |
100 cond = '' |
110 cond = "" |
101 try: |
111 try: |
102 curr = condHistory.index(cond) |
112 curr = condHistory.index(cond) |
103 except ValueError: |
113 except ValueError: |
104 condHistory.insert(0, cond) |
114 condHistory.insert(0, cond) |
105 curr = 0 |
115 curr = 0 |
106 self.conditionCombo.addItems(condHistory) |
116 self.conditionCombo.addItems(condHistory) |
107 self.conditionCombo.setCurrentIndex(curr) |
117 self.conditionCombo.setCurrentIndex(curr) |
108 |
118 |
109 if not fn: |
119 if not fn: |
110 self.okButton.setEnabled(False) |
120 self.okButton.setEnabled(False) |
111 |
121 |
112 msh = self.minimumSizeHint() |
122 msh = self.minimumSizeHint() |
113 self.resize(max(self.width(), msh.width()), msh.height()) |
123 self.resize(max(self.width(), msh.width()), msh.height()) |
114 |
124 |
115 def on_filenamePicker_editTextChanged(self, fn): |
125 def on_filenamePicker_editTextChanged(self, fn): |
116 """ |
126 """ |
117 Private slot to handle the change of the filename. |
127 Private slot to handle the change of the filename. |
118 |
128 |
119 @param fn text of the filename edit (string) |
129 @param fn text of the filename edit (string) |
120 """ |
130 """ |
121 if not fn: |
131 if not fn: |
122 self.okButton.setEnabled(False) |
132 self.okButton.setEnabled(False) |
123 else: |
133 else: |
124 self.okButton.setEnabled(True) |
134 self.okButton.setEnabled(True) |
125 |
135 |
126 def getData(self): |
136 def getData(self): |
127 """ |
137 """ |
128 Public method to retrieve the entered data. |
138 Public method to retrieve the entered data. |
129 |
139 |
130 @return a tuple containing the breakpoints new properties |
140 @return a tuple containing the breakpoints new properties |
131 (condition, temporary flag, enabled flag, ignore count) |
141 (condition, temporary flag, enabled flag, ignore count) |
132 """ |
142 """ |
133 return (self.conditionCombo.currentText(), |
143 return ( |
134 self.temporaryCheckBox.isChecked(), |
144 self.conditionCombo.currentText(), |
135 self.enabledCheckBox.isChecked(), self.ignoreSpinBox.value()) |
145 self.temporaryCheckBox.isChecked(), |
136 |
146 self.enabledCheckBox.isChecked(), |
|
147 self.ignoreSpinBox.value(), |
|
148 ) |
|
149 |
137 def getAddData(self): |
150 def getAddData(self): |
138 """ |
151 """ |
139 Public method to retrieve the entered data for an add. |
152 Public method to retrieve the entered data for an add. |
140 |
153 |
141 @return a tuple containing the new breakpoints properties |
154 @return a tuple containing the new breakpoints properties |
142 (filename, lineno, condition, temporary flag, enabled flag, |
155 (filename, lineno, condition, temporary flag, enabled flag, |
143 ignore count) |
156 ignore count) |
144 """ |
157 """ |
145 fn = self.filenamePicker.currentText() |
158 fn = self.filenamePicker.currentText() |
146 fn = os.path.expanduser(os.path.expandvars(fn)) if fn else None |
159 fn = os.path.expanduser(os.path.expandvars(fn)) if fn else None |
147 |
160 |
148 return (fn, self.linenoSpinBox.value(), |
161 return ( |
149 self.conditionCombo.currentText(), |
162 fn, |
150 self.temporaryCheckBox.isChecked(), |
163 self.linenoSpinBox.value(), |
151 self.enabledCheckBox.isChecked(), |
164 self.conditionCombo.currentText(), |
152 self.ignoreSpinBox.value()) |
165 self.temporaryCheckBox.isChecked(), |
|
166 self.enabledCheckBox.isChecked(), |
|
167 self.ignoreSpinBox.value(), |
|
168 ) |