eric6/Debugger/StartHistoryEditDialog.py

Tue, 02 Mar 2021 17:17:09 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 02 Mar 2021 17:17:09 +0100
changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
permissions
-rw-r--r--

Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.

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
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2016 - 2021 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
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
10 from PyQt5.QtCore import pyqtSlot, Qt
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
11 from PyQt5.QtWidgets import QDialog, QInputDialog, QLineEdit
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
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
13 from E5Gui import E5MessageBox
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 """
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
22 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
23 """
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 Constructor
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
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
26 @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
27 @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
28 @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
29 @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
30 """
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 super(StartHistoryEditDialog, self).__init__(parent)
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
32 self.setupUi(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
33
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
34 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
35 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
36 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
37 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
38 itm.setFlags(flags)
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
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
40 self.__updateEditButtons()
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
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
42 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
43 """
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 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
45 """
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 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
47 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
48 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
49 self.deleteAllButton.setEnabled(self.historyList.count() > 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
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
51 @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
52 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
53 """
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 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
55 """
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 self.__updateEditButtons()
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
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
58 @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
59 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
60 """
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 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
62 """
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 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
64 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
65 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
66 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
67 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
68 QLineEdit.EchoMode.Normal,
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
69 itm.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
70 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
71 itm.setText(historyText)
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
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 @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
74 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
75 """
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 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
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 yes = E5MessageBox.yesNo(
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 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
80 self.tr("Delete 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
81 self.tr("""Do you really want to delete the selected"""
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 """ 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
83 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
84 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
85 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
86 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
87 del 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
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 @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
90 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
91 """
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 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
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 yes = E5MessageBox.yesNo(
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 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
96 self.tr("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
97 self.tr("""Do you really want to delete the shown 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
98 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
99 self.historyList.clear()
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
100
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 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
102 """
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
103 Public method to get the new 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
104
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 @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
106 @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
107 """
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 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
109 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
110 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
111 history.append(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
112
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 return history

eric ide

mercurial