eric6/Debugger/EditWatchpointDialog.py

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

eric ide

mercurial