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