Debugger/StartHistoryEditDialog.py

Sat, 06 May 2017 13:43:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 06 May 2017 13:43:21 +0200
branch
maintenance
changeset 5730
6422afc7adc4
parent 5389
9b1c800daff3
child 6048
82ad8ec9548c
permissions
-rw-r--r--

Merged with default branch in order to prepare the 17.05 release.

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
5389
9b1c800daff3 Updated copyright for 2017.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5372
diff changeset
3 # Copyright (c) 2016 - 2017 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 __future__ import unicode_literals
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
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 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
13 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
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 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
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 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
18
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 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
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 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
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 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
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 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
27
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 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
29 @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
30 @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
31 @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
32 """
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 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
34 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
35
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 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
37 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
38 itm = self.historyList.item(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
39 flags = itm.flags() | Qt.ItemIsEditable
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 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
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 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
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 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
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 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
47 """
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 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
49 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
50 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
51 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
52
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 @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
54 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
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 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
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 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
59
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 @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
61 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
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 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
64 """
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 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
66 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
67 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
68 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
69 self.tr("Enter the new 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 QLineEdit.Normal,
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.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
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)
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
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 """
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 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
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"),
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 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
84 """ 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
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
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
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 """
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 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
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"),
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.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
100 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
101 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
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 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
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 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
106
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 @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
108 @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
109 """
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 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
111 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
112 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
113 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
114
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
115 return history

eric ide

mercurial