src/eric7/Debugger/EditBreakpointDialog.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2003 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to edit breakpoint properties.
8 """
9
10 import os.path
11
12 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QComboBox
13
14 from EricWidgets.EricPathPicker import EricPathPickerModes
15
16 from .Ui_EditBreakpointDialog import Ui_EditBreakpointDialog
17
18
19 class EditBreakpointDialog(QDialog, Ui_EditBreakpointDialog):
20 """
21 Class implementing a dialog to edit breakpoint properties.
22 """
23 def __init__(self, breakPointId, properties, condHistory, parent=None,
24 name=None, modal=False, addMode=False, filenameHistory=None):
25 """
26 Constructor
27
28 @param breakPointId id of the breakpoint (tuple)
29 (filename, linenumber)
30 @param properties properties for the breakpoint (tuple)
31 (condition, temporary flag, enabled flag, ignore count)
32 @param condHistory the list of conditionals history (list of strings)
33 @param parent the parent of this dialog (QWidget)
34 @param name the widget name of this dialog (string)
35 @param modal flag indicating a modal dialog (boolean)
36 @param addMode flag indicating the add mode (boolean)
37 @param filenameHistory list of recently used file names
38 (list of strings)
39 """
40 super().__init__(parent)
41 self.setupUi(self)
42 if name:
43 self.setObjectName(name)
44 self.setModal(modal)
45
46 self.filenamePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
47 self.filenamePicker.setSizeAdjustPolicy(
48 QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
49
50 self.okButton = self.buttonBox.button(
51 QDialogButtonBox.StandardButton.Ok)
52
53 fn, lineno = breakPointId
54
55 if not addMode:
56 cond, temp, enabled, count = properties
57
58 # set the filename
59 if fn is not None:
60 self.filenamePicker.setEditText(fn)
61
62 # set the line number
63 self.linenoSpinBox.setValue(lineno)
64
65 # set the condition
66 if cond is None:
67 cond = ''
68 try:
69 curr = condHistory.index(cond)
70 except ValueError:
71 condHistory.insert(0, cond)
72 curr = 0
73 self.conditionCombo.addItems(condHistory)
74 self.conditionCombo.setCurrentIndex(curr)
75
76 # set the ignore count
77 self.ignoreSpinBox.setValue(count)
78
79 # set the checkboxes
80 self.temporaryCheckBox.setChecked(temp)
81 self.enabledCheckBox.setChecked(enabled)
82
83 self.filenamePicker.setEnabled(False)
84 self.linenoSpinBox.setEnabled(False)
85 self.conditionCombo.setFocus()
86 else:
87 self.setWindowTitle(self.tr("Add Breakpoint"))
88 # set the filename
89 if fn is None:
90 fn = ""
91 try:
92 curr = filenameHistory.index(fn)
93 except ValueError:
94 filenameHistory.insert(0, fn)
95 curr = 0
96 self.filenamePicker.addItems(filenameHistory)
97 self.filenamePicker.setCurrentIndex(curr)
98
99 # set the condition
100 cond = ''
101 try:
102 curr = condHistory.index(cond)
103 except ValueError:
104 condHistory.insert(0, cond)
105 curr = 0
106 self.conditionCombo.addItems(condHistory)
107 self.conditionCombo.setCurrentIndex(curr)
108
109 if not fn:
110 self.okButton.setEnabled(False)
111
112 msh = self.minimumSizeHint()
113 self.resize(max(self.width(), msh.width()), msh.height())
114
115 def on_filenamePicker_editTextChanged(self, fn):
116 """
117 Private slot to handle the change of the filename.
118
119 @param fn text of the filename edit (string)
120 """
121 if not fn:
122 self.okButton.setEnabled(False)
123 else:
124 self.okButton.setEnabled(True)
125
126 def getData(self):
127 """
128 Public method to retrieve the entered data.
129
130 @return a tuple containing the breakpoints new properties
131 (condition, temporary flag, enabled flag, ignore count)
132 """
133 return (self.conditionCombo.currentText(),
134 self.temporaryCheckBox.isChecked(),
135 self.enabledCheckBox.isChecked(), self.ignoreSpinBox.value())
136
137 def getAddData(self):
138 """
139 Public method to retrieve the entered data for an add.
140
141 @return a tuple containing the new breakpoints properties
142 (filename, lineno, condition, temporary flag, enabled flag,
143 ignore count)
144 """
145 fn = self.filenamePicker.currentText()
146 fn = os.path.expanduser(os.path.expandvars(fn)) if fn else None
147
148 return (fn, self.linenoSpinBox.value(),
149 self.conditionCombo.currentText(),
150 self.temporaryCheckBox.isChecked(),
151 self.enabledCheckBox.isChecked(),
152 self.ignoreSpinBox.value())

eric ide

mercurial