src/eric7/Debugger/ExceptionsFilterDialog.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) 2002 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the exceptions filter dialog.
8 """
9
10 from PyQt6.QtCore import pyqtSlot
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
12
13 from .Ui_ExceptionsFilterDialog import Ui_ExceptionsFilterDialog
14
15
16 class ExceptionsFilterDialog(QDialog, Ui_ExceptionsFilterDialog):
17 """
18 Class implementing the exceptions filter dialog.
19 """
20 def __init__(self, excList, ignore, parent=None):
21 """
22 Constructor
23
24 @param excList list of exceptions to be edited (list of strings)
25 @param ignore flag indicating the ignore exceptions mode (boolean)
26 @param parent the parent widget (QWidget)
27 """
28 super().__init__(parent)
29 self.setupUi(self)
30 self.setModal(True)
31
32 self.exceptionList.addItems(excList)
33
34 if ignore:
35 self.setWindowTitle(self.tr("Ignored Exceptions"))
36 self.exceptionList.setToolTip(
37 self.tr("List of ignored exceptions"))
38
39 self.okButton = self.buttonBox.button(
40 QDialogButtonBox.StandardButton.Ok)
41
42 @pyqtSlot()
43 def on_exceptionList_itemSelectionChanged(self):
44 """
45 Private slot to handle the change of the selection.
46 """
47 self.deleteButton.setEnabled(
48 len(self.exceptionList.selectedItems()) > 0)
49
50 @pyqtSlot()
51 def on_deleteButton_clicked(self):
52 """
53 Private slot to delete the currently selected exception of the listbox.
54 """
55 itm = self.exceptionList.takeItem(self.exceptionList.currentRow())
56 del itm
57
58 @pyqtSlot()
59 def on_deleteAllButton_clicked(self):
60 """
61 Private slot to delete all exceptions of the listbox.
62 """
63 while self.exceptionList.count() > 0:
64 itm = self.exceptionList.takeItem(0) # __IGNORE_WARNING__
65 del itm
66
67 @pyqtSlot()
68 def on_addButton_clicked(self):
69 """
70 Private slot to handle the Add button press.
71 """
72 exception = self.exceptionEdit.text()
73 if exception:
74 self.exceptionList.addItem(exception)
75 self.exceptionEdit.clear()
76
77 def on_exceptionEdit_textChanged(self, txt):
78 """
79 Private slot to handle the textChanged signal of exceptionEdit.
80
81 This slot sets the enabled status of the add button and sets the forms
82 default button.
83
84 @param txt the text entered into exceptionEdit (string)
85 """
86 if not txt:
87 self.okButton.setDefault(True)
88 self.addButton.setDefault(False)
89 self.addButton.setEnabled(False)
90 else:
91 self.okButton.setDefault(False)
92 self.addButton.setDefault(True)
93 self.addButton.setEnabled(True)
94
95 def getExceptionsList(self):
96 """
97 Public method to retrieve the list of exception types.
98
99 @return list of exception types (list of strings)
100 """
101 excList = []
102 for row in range(0, self.exceptionList.count()):
103 itm = self.exceptionList.item(row)
104 excList.append(itm.text())
105 return excList

eric ide

mercurial