|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2003 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to edit watch expression properties. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import * |
|
11 from PyQt4.QtGui import * |
|
12 |
|
13 from Ui_EditWatchpointDialog import Ui_EditWatchpointDialog |
|
14 |
|
15 |
|
16 class EditWatchpointDialog(QDialog, Ui_EditWatchpointDialog): |
|
17 """ |
|
18 Class implementing a dialog to edit watch expression properties. |
|
19 """ |
|
20 def __init__(self, properties, parent = None, name = None, modal = False): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param properties properties for the watch expression (tuple) |
|
25 (expression, temporary flag, enabled flag, ignore count, 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 QDialog.__init__(self,parent) |
|
31 self.setupUi(self) |
|
32 if name: |
|
33 self.setObjectName(name) |
|
34 self.setModal(modal) |
|
35 |
|
36 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
|
37 |
|
38 # connect our widgets |
|
39 self.connect(self.conditionEdit, SIGNAL("textChanged(const QString &)"), |
|
40 self.__textChanged) |
|
41 self.connect(self.specialEdit, SIGNAL("textChanged(const QString &)"), |
|
42 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 def __textChanged(self, txt): |
|
71 """ |
|
72 Private slot to handle the text changed signal of the condition line edit. |
|
73 |
|
74 @param txt text of the line edit (string) |
|
75 """ |
|
76 if self.conditionButton.isChecked(): |
|
77 self.buttonBox.button(QDialogButtonBox.Ok)\ |
|
78 .setEnabled(self.conditionEdit.text() != "") |
|
79 elif self.specialButton.isChecked(): |
|
80 self.buttonBox.button(QDialogButtonBox.Ok)\ |
|
81 .setEnabled(self.specialEdit.text() != "") |
|
82 else: |
|
83 # should not happen |
|
84 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
|
85 |
|
86 |
|
87 def getData(self): |
|
88 """ |
|
89 Public method to retrieve the entered data. |
|
90 |
|
91 @return a tuple containing the watch expressions new properties |
|
92 (expression, temporary flag, enabled flag, ignore count, special condition) |
|
93 """ |
|
94 if self.conditionButton.isChecked(): |
|
95 return (self.conditionEdit.text(), |
|
96 self.temporaryCheckBox.isChecked(), |
|
97 self.enabledCheckBox.isChecked(), |
|
98 self.ignoreSpinBox.value(), |
|
99 "") |
|
100 elif self.specialButton.isChecked(): |
|
101 return (self.specialEdit.text(), |
|
102 self.temporaryCheckBox.isChecked(), |
|
103 self.enabledCheckBox.isChecked(), |
|
104 self.ignoreSpinBox.value(), |
|
105 self.specialCombo.currentText()) |
|
106 else: |
|
107 # should not happen |
|
108 return ("", False, False, 0, "") |