src/eric7/Debugger/StartHistoryEditDialog.py

Sat, 31 Dec 2022 16:23:21 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 31 Dec 2022 16:23:21 +0100
branch
eric7
changeset 9653
e67609152c5e
parent 9576
be9f8e7e42e0
child 10439
21c28b0f9e41
permissions
-rw-r--r--

Updated copyright for 2023.

5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
9653
e67609152c5e Updated copyright for 2023.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9576
diff changeset
3 # Copyright (c) 2016 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to edit a list of history entries.
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
10 from PyQt6.QtCore import Qt, pyqtSlot
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
11 from PyQt6.QtWidgets import QDialog, QInputDialog, QLineEdit
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
13 from eric7.EricWidgets import EricMessageBox
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from .Ui_StartHistoryEditDialog import Ui_StartHistoryEditDialog
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class StartHistoryEditDialog(QDialog, Ui_StartHistoryEditDialog):
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing a dialog to edit a list of history entries.
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
22
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 def __init__(self, history, parent=None):
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
26
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @param history list of history entries to be edited
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @type list of str
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param parent reference to the parent widget
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @type QWidget
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
32 super().__init__(parent)
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.setupUi(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
34
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.historyList.addItems(history)
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 for row in range(self.historyList.count()):
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 itm = self.historyList.item(row)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
38 flags = itm.flags() | Qt.ItemFlag.ItemIsEditable
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 itm.setFlags(flags)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
40
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__updateEditButtons()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
42
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 def __updateEditButtons(self):
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 Private method to set the state of the edit buttons.
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 selectedCount = len(self.historyList.selectedItems())
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.editButton.setEnabled(selectedCount == 1)
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.deleteButton.setEnabled(selectedCount > 0)
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.deleteAllButton.setEnabled(self.historyList.count() > 0)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
51
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 @pyqtSlot()
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 def on_historyList_itemSelectionChanged(self):
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 Private slot to handle the selection of entries.
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.__updateEditButtons()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
58
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 @pyqtSlot()
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 def on_editButton_clicked(self):
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 Private slot to edit the selected entry.
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 itm = self.historyList.selectedItems()[0]
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 historyText, ok = QInputDialog.getText(
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self,
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.tr("Edit History Entry"),
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.tr("Enter the new text:"),
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
69 QLineEdit.EchoMode.Normal,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
70 itm.text(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
71 )
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 if ok:
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 itm.setText(historyText)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
74
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 @pyqtSlot()
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 def on_deleteButton_clicked(self):
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 Private slot to delete the selected entries.
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
80 yes = EricMessageBox.yesNo(
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self,
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.tr("Delete Selected Entries"),
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9573
diff changeset
83 self.tr("""Do you really want to delete the selected history entries?"""),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
84 )
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 if yes:
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 for itm in self.historyList.selectedItems():
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 row = self.historyList.row(itm)
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.historyList.takeItem(row)
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 del itm
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
90
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 @pyqtSlot()
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 def on_deleteAllButton_clicked(self):
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 Private slot to delete all entries.
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
96 yes = EricMessageBox.yesNo(
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self,
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.tr("Delete All Entries"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
99 self.tr("""Do you really want to delete the shown history?"""),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
100 )
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 if yes:
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.historyList.clear()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
103
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 def getHistory(self):
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 Public method to get the new list of history entries.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
107
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 @return list of history entries
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 @rtype list of str
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 history = []
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 for row in range(self.historyList.count()):
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 entry = self.historyList.item(row).text()
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 history.append(entry)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
115
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 return history

eric ide

mercurial