RefactoringRope/HistoryDialog.py

Wed, 21 Sep 2022 15:30:34 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 21 Sep 2022 15:30:34 +0200
branch
eric7
changeset 389
4f53795beff0
parent 374
958f34e97952
child 396
933b8fcd854f
permissions
-rw-r--r--

Reformatted source code with 'Black'.

4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
374
958f34e97952 Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
3 # Copyright (c) 2010 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the History dialog.
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
10 from PyQt6.QtCore import pyqtSlot, Qt, QItemSelectionModel
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
11 from PyQt6.QtGui import QBrush, QTextCursor
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
12 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QListWidgetItem, QAbstractButton
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
14 from EricWidgets.EricApplication import ericApp
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
15 from EricWidgets import EricMessageBox
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
203
c38750e1bafd Performed some code cleanup actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 189
diff changeset
17 from .Ui_HistoryDialog import Ui_HistoryDialog
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
19 import Globals
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 import Utilities
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
21 import Preferences
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
20
83b71483e198 Made the code PEP-8 compliant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
23
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
24 class HistoryDialog(QDialog, Ui_HistoryDialog):
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Class implementing the History dialog.
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
28
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
29 ChangeIDRole = Qt.ItemDataRole.UserRole
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
30
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
31 def __init__(self, refactoring, filename="", parent=None):
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 Constructor
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
34
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param refactoring reference to the main refactoring object
189
2711fdd91925 Renamed the 'Refactoring' module and class 'RefactoringServer'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 170
diff changeset
36 @type RefactoringServer
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
37 @param filename name of the file to show the history for
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
38 @type str
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
39 @param parent reference to the parent widget
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
40 @type QWidget
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
42 QDialog.__init__(self, parent)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
43 self.setupUi(self)
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
44 self.setWindowFlags(Qt.WindowType.Window)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
45
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
46 if Globals.isWindowsPlatform():
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
47 self.previewEdit.setFontFamily("Lucida Console")
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
48 else:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
49 self.previewEdit.setFontFamily("Monospace")
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
50
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
51 self.formats = {}
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
52 self.formats[" "] = self.previewEdit.currentCharFormat()
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
53
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
54 charFormat = self.previewEdit.currentCharFormat()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
55 charFormat.setBackground(QBrush(Preferences.getDiffColour("AddedColor")))
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
56 self.formats["+"] = charFormat
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
57
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
58 charFormat = self.previewEdit.currentCharFormat()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
59 charFormat.setBackground(QBrush(Preferences.getDiffColour("RemovedColor")))
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
60 self.formats["-"] = charFormat
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
61
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
62 charFormat = self.previewEdit.currentCharFormat()
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
63 charFormat.setBackground(QBrush(Preferences.getDiffColour("ReplacedColor")))
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
64 self.formats["@"] = charFormat
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
65
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
66 charFormat = self.previewEdit.currentCharFormat()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
67 charFormat.setBackground(QBrush(Preferences.getDiffColour("ContextColor")))
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
68 self.formats["?"] = charFormat
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
69
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
70 charFormat = self.previewEdit.currentCharFormat()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
71 charFormat.setBackground(QBrush(Preferences.getDiffColour("HeaderColor")))
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
72 self.formats["="] = charFormat
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
73
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.__refactoring = refactoring
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
75 self.__filename = filename
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
76
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
77 if not filename:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
78 self.header.setText(self.tr("<b>Project History</b>"))
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
79 else:
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
80 self.header.setText(self.tr("<b>File History: {0}</b>").format(filename))
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
81
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
82 self.__undoButton = self.buttonBox.addButton(
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
83 self.tr("&Undo"), QDialogButtonBox.ButtonRole.ActionRole
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
84 )
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
85 self.__redoButton = self.buttonBox.addButton(
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
86 self.tr("&Redo"), QDialogButtonBox.ButtonRole.ActionRole
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
87 )
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
88 self.__refreshButton = self.buttonBox.addButton(
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
89 self.tr("Re&fresh"), QDialogButtonBox.ButtonRole.ActionRole
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
90 )
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
91 self.__clearButton = self.buttonBox.addButton(
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
92 self.tr("&Clear History"), QDialogButtonBox.ButtonRole.ActionRole
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
93 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
94
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 # populate the list
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
96 self.__refreshHistories()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
97
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
98 def __appendText(self, txt, charFormat):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
99 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
100 Private method to append text to the end of the preview pane.
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
101
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
102 @param txt text to insert
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
103 @type str
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
104 @param charFormat text format to be used
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
105 @type QTextCharFormat
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
106 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
107 tc = self.previewEdit.textCursor()
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
108 tc.movePosition(QTextCursor.MoveOperation.End)
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
109 self.previewEdit.setTextCursor(tc)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
110 self.previewEdit.setCurrentCharFormat(charFormat)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
111 self.previewEdit.insertPlainText(txt)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
112
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
113 @pyqtSlot(QAbstractButton)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
114 def on_buttonBox_clicked(self, button):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
115 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
116 Private slot handling the selection of a dialog button.
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
117
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
118 @param button reference to the button clicked
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
119 @type QAbstractButton
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 """
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
121 if button == QDialogButtonBox.StandardButton.Close:
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
122 self.close()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
123 elif button == self.__undoButton:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
124 self.__undoChanges()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
125 elif button == self.__redoButton:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
126 self.__redoChanges()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
127 elif button == self.__refreshButton:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
128 self.__refreshHistories()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
129 elif button == self.__clearButton:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
130 self.__clearHistory()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
131
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
132 def __currentItemChanged(self, current):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
133 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
134 Private method to request change data of an item.
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
135
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
136 @param current reference to the item to get change data for
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
137 @type QListWidgetItem
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 if current is None:
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 return
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
141
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 self.previewEdit.clear()
151
5260100b6700 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 147
diff changeset
143 changeId = current.data(HistoryDialog.ChangeIDRole)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
144 self.__refactoring.sendJson(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
145 "History",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
146 {
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
147 "Subcommand": "GetChange",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
148 "Id": changeId,
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
149 },
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
150 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
151
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
152 @pyqtSlot(QListWidgetItem, QListWidgetItem)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
153 def on_redoChangesList_currentItemChanged(self, current, previous):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
154 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
155 Private slot handling a change of the current redo change.
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
156
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
157 @param current reference to the new current redo item
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
158 @type QListWidgetItem
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
159 @param previous reference to the previous current redo item
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
160 @type QListWidgetItem
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
161 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
162 self.__redoButton.setEnabled(current is not None)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
163 self.__currentItemChanged(current)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
164
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
165 @pyqtSlot(QListWidgetItem)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
166 def on_redoChangesList_itemClicked(self, item):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
167 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
168 Private slot handling a click on a redo entry.
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
169
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
170 @param item reference to the clicked item
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
171 @type QListWidgetItem
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 """
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
173 self.__currentItemChanged(item)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
174
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
175 @pyqtSlot(QListWidgetItem, QListWidgetItem)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
176 def on_undoChangesList_currentItemChanged(self, current, previous):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
177 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
178 Private slot handling a change of the current undo change.
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
179
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
180 @param current reference to the new current undo item
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
181 @type QListWidgetItem
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
182 @param previous reference to the previous current undo item
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
183 @type QListWidgetItem
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 """
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
185 self.__undoButton.setEnabled(current is not None)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
186 self.__currentItemChanged(current)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
187
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
188 @pyqtSlot(QListWidgetItem)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
189 def on_undoChangesList_itemClicked(self, item):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
190 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
191 Private slot handling a click on an undo entry.
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
192
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
193 @param item reference to the clicked item
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
194 @type QListWidgetItem
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
195 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
196 self.__currentItemChanged(item)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
197
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
198 def __undoChanges(self):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
199 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
200 Private method to undo the selected set of changes.
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
201 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
202 currentUndoItem = self.undoChangesList.currentItem()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
203 change = currentUndoItem.text()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
204 changeId = currentUndoItem.data(HistoryDialog.ChangeIDRole)
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
205 res = EricMessageBox.yesNo(
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
206 None,
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
207 self.tr("Undo Refactorings"),
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
208 self.tr(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
209 """Shall all refactorings up to <b>{0}</b>""" """ be undone?"""
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
210 ).format(Utilities.html_encode(change)),
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
211 )
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
212 if res:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
213 if not self.__refactoring.confirmAllBuffersSaved():
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
214 return
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
215
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
216 self.__refactoring.sendJson(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
217 "History",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
218 {
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
219 "Subcommand": "Undo",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
220 "Id": changeId,
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
221 },
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
222 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
223
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
224 def __redoChanges(self):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
225 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
226 Private method to redo the selected set of changes.
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
227 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
228 currentRedoItem = self.redoChangesList.currentItem()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
229 change = currentRedoItem.text()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
230 changeId = currentRedoItem.data(HistoryDialog.ChangeIDRole)
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
231 res = EricMessageBox.yesNo(
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
232 None,
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
233 self.tr("Redo Refactorings"),
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
234 self.tr(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
235 """Shall all refactorings up to <b>{0}</b>""" """ be redone?"""
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
236 ).format(Utilities.html_encode(change)),
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
237 )
48
de33dc93a3ac Changed usage of QMessageBox and QFileDialog to the eric5 equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 46
diff changeset
238 if res:
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 if not self.__refactoring.confirmAllBuffersSaved():
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 return
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
241
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
242 self.__refactoring.sendJson(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
243 "History",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
244 {
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
245 "Subcommand": "Redo",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
246 "Id": changeId,
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
247 },
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
248 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
249
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
250 def __refreshHistories(self):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
251 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
252 Private method to refresh the undo and redo history lists.
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
253 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
254 self.__undoButton.setEnabled(False)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
255 self.__redoButton.setEnabled(False)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
256 self.__refreshButton.setEnabled(False)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
257 self.__clearButton.setEnabled(False)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
258
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
259 self.undoChangesList.clear()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
260 self.redoChangesList.clear()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
261 self.previewEdit.clear()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
262
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
263 self.__refactoring.sendJson(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
264 "History", {"Subcommand": "Get", "Filename": self.__filename}
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
265 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
266
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
267 def __clearHistory(self):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
268 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
269 Private method to clear the refactoring history.
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
270 """
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
271 res = EricMessageBox.yesNo(
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
272 None,
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
273 self.tr("Clear History"),
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
274 self.tr("Do you really want to clear the refactoring history?"),
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
275 )
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
276 if res:
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
277 self.sendJson(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
278 "History",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
279 {
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
280 "Subcommand": "Clear",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
281 },
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
282 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
283
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
284 self.historyCleared()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
285
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
286 def historyCleared(self):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
287 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
288 Public method to indicate, that the refactoring history was cleared
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
289 through the menu.
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
290 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
291 self.__refreshHistories()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
292
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
293 def processHistoryCommand(self, data):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
294 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
295 Public method to process the data sent by the refactoring client.
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
296
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
297 @param data dictionary containing the history data
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
298 @type dict
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
299 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
300 subcommand = data["Subcommand"]
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
301 if subcommand == "Histories":
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
302 for change, changeId in data["Undo"]:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
303 itm = QListWidgetItem(change, self.undoChangesList)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
304 itm.setData(HistoryDialog.ChangeIDRole, changeId)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
305 for change, changeId in data["Redo"]:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
306 itm = QListWidgetItem(change, self.redoChangesList)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
307 itm.setData(HistoryDialog.ChangeIDRole, changeId)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
308 if self.undoChangesList.count() > 0:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
309 self.undoChangesList.setCurrentItem(
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
310 self.undoChangesList.item(0),
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
311 QItemSelectionModel.SelectionFlag.Select,
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
312 )
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
313 elif self.redoChangesList.count() > 0:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
314 self.redoChangesList.setCurrentItem(
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
315 self.redoChangesList.item(0),
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
316 QItemSelectionModel.SelectionFlag.Select,
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
317 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
318
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
319 self.__refreshButton.setEnabled(True)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
320 if self.undoChangesList.count() > 0 or self.redoChangesList.count() > 0:
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
321 self.__clearButton.setEnabled(True)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
322
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
323 elif subcommand == "ChangeDescription":
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
324 for line in data["Description"].splitlines(True):
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
325 try:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
326 charFormat = self.formats[line[0]]
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
327 except (IndexError, KeyError):
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
328 charFormat = self.formats[" "]
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
329 self.__appendText(line, charFormat)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
330
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
331 elif subcommand in ["Undo", "Redo"]:
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
332 self.__refactoring.refreshEditors(data["ChangedFiles"])
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
333 p = ericApp().getObject("Project")
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 if p.isDirty():
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 p.saveProject()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
336
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
337 self.raise_()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
338 self.__refreshHistories()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
339
170
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
340 def closeEvent(self, evt):
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
341 """
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
342 Protected method handling close events.
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
343
170
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
344 @param evt reference to the close event object
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
345 @type QCloseEvent
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
346 """
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
347 self.__refactoring.sendJson(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
348 "History",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
349 {
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
350 "Subcommand": "ClearChanges",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
351 },
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
352 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
353
170
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
354 evt.accept()

eric ide

mercurial