RefactoringRope/HistoryDialog.py

Tue, 10 Dec 2024 15:49:01 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 10 Dec 2024 15:49:01 +0100
branch
eric7
changeset 426
7592a1c052e8
parent 420
fa31c3a0df1d
permissions
-rw-r--r--

Updated copyright for 2025.

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
426
7592a1c052e8 Updated copyright for 2025.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 420
diff changeset
3 # Copyright (c) 2010 - 2025 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
409
65153bf17e8d Fixed a bug and resorted the imports with isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 406
diff changeset
10 from PyQt6.QtCore import QItemSelectionModel, Qt, pyqtSlot
365
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
409
65153bf17e8d Fixed a bug and resorted the imports with isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 406
diff changeset
12 from PyQt6.QtWidgets import QAbstractButton, QDialog, QDialogButtonBox, QListWidgetItem
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
406
923d7f711cae Adjusted code for eric7 23.1 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 396
diff changeset
14 from eric7 import Preferences, Utilities
409
65153bf17e8d Fixed a bug and resorted the imports with isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 406
diff changeset
15 from eric7.EricWidgets import EricMessageBox
396
933b8fcd854f Adapted the import statements to the new structure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 389
diff changeset
16 from eric7.EricWidgets.EricApplication import ericApp
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
406
923d7f711cae Adjusted code for eric7 23.1 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 396
diff changeset
18 try:
923d7f711cae Adjusted code for eric7 23.1 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 396
diff changeset
19 from eric7.SystemUtilities.OSUtilities import isWindowsPlatform
923d7f711cae Adjusted code for eric7 23.1 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 396
diff changeset
20 except ImportError:
420
fa31c3a0df1d Adjusted code for eric7 24.10 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 413
diff changeset
21 # backward compatibility for eric < 23.1
406
923d7f711cae Adjusted code for eric7 23.1 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 396
diff changeset
22 from eric7.Globals import isWindowsPlatform
923d7f711cae Adjusted code for eric7 23.1 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 396
diff changeset
23
203
c38750e1bafd Performed some code cleanup actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 189
diff changeset
24 from .Ui_HistoryDialog import Ui_HistoryDialog
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
20
83b71483e198 Made the code PEP-8 compliant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
26
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
27 class HistoryDialog(QDialog, Ui_HistoryDialog):
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Class implementing the History dialog.
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
31
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
32 ChangeIDRole = Qt.ItemDataRole.UserRole
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
33
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
34 def __init__(self, refactoring, filename="", parent=None):
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 Constructor
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
37
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @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
39 @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
40 @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
41 @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
42 @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
43 @type QWidget
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
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
45 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
46 self.setupUi(self)
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
47 self.setWindowFlags(Qt.WindowType.Window)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
48
406
923d7f711cae Adjusted code for eric7 23.1 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 396
diff changeset
49 if isWindowsPlatform():
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
50 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
51 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
52 self.previewEdit.setFontFamily("Monospace")
389
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 self.formats = {}
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
55 self.formats[" "] = self.previewEdit.currentCharFormat()
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
56
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
57 charFormat = self.previewEdit.currentCharFormat()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
58 charFormat.setBackground(QBrush(Preferences.getDiffColour("AddedColor")))
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
59 self.formats["+"] = charFormat
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
60
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
61 charFormat = self.previewEdit.currentCharFormat()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
62 charFormat.setBackground(QBrush(Preferences.getDiffColour("RemovedColor")))
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
63 self.formats["-"] = charFormat
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
64
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
65 charFormat = self.previewEdit.currentCharFormat()
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
66 charFormat.setBackground(QBrush(Preferences.getDiffColour("ReplacedColor")))
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
67 self.formats["@"] = charFormat
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
68
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
69 charFormat = self.previewEdit.currentCharFormat()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
70 charFormat.setBackground(QBrush(Preferences.getDiffColour("ContextColor")))
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
71 self.formats["?"] = charFormat
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
72
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
73 charFormat = self.previewEdit.currentCharFormat()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
74 charFormat.setBackground(QBrush(Preferences.getDiffColour("HeaderColor")))
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
75 self.formats["="] = charFormat
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
76
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 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
78 self.__filename = filename
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
79
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
80 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
81 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
82 else:
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
83 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
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.__undoButton = self.buttonBox.addButton(
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
86 self.tr("&Undo"), 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.__redoButton = self.buttonBox.addButton(
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
89 self.tr("&Redo"), 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.__refreshButton = self.buttonBox.addButton(
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
92 self.tr("Re&fresh"), QDialogButtonBox.ButtonRole.ActionRole
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
93 )
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
94 self.__clearButton = self.buttonBox.addButton(
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
95 self.tr("&Clear History"), QDialogButtonBox.ButtonRole.ActionRole
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
96 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
97
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 # 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
99 self.__refreshHistories()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
100
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
101 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
102 """
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 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
104
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
105 @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
106 @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
107 @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
108 @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
109 """
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 tc = self.previewEdit.textCursor()
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
111 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
112 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
113 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
114 self.previewEdit.insertPlainText(txt)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
115
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
116 @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
117 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
118 """
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 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
120
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
121 @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
122 @type QAbstractButton
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 """
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
124 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
125 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
126 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
127 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
128 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
129 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
130 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
131 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
132 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
133 self.__clearHistory()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
134
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
135 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
136 """
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 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
138
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
139 @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
140 @type QListWidgetItem
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 if current is None:
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 return
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
144
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 self.previewEdit.clear()
151
5260100b6700 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 147
diff changeset
146 changeId = current.data(HistoryDialog.ChangeIDRole)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
147 self.__refactoring.sendJson(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
148 "History",
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 "Subcommand": "GetChange",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
151 "Id": changeId,
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
152 },
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
153 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
154
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
155 @pyqtSlot(QListWidgetItem, QListWidgetItem)
413
a4cba20ad7ab Corrected some code style issues and converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 412
diff changeset
156 def on_redoChangesList_currentItemChanged(self, current, previous): # noqa: U100
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 """
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 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
159
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
160 @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
161 @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
162 @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
163 @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
164 """
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 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
166 self.__currentItemChanged(current)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
167
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
168 @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
169 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
170 """
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 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
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 @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
174 @type QListWidgetItem
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 """
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
176 self.__currentItemChanged(item)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
177
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
178 @pyqtSlot(QListWidgetItem, QListWidgetItem)
413
a4cba20ad7ab Corrected some code style issues and converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 412
diff changeset
179 def on_undoChangesList_currentItemChanged(self, current, previous): # noqa: U100
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 """
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 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
182
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
183 @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
184 @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
185 @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
186 @type QListWidgetItem
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
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 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
189 self.__currentItemChanged(current)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
190
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
191 @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
192 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
193 """
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 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
195
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
196 @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
197 @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
198 """
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 self.__currentItemChanged(item)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
200
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
201 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
202 """
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 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
204 """
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
205 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
206 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
207 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
208 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
209 None,
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
210 self.tr("Undo Refactorings"),
413
a4cba20ad7ab Corrected some code style issues and converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 412
diff changeset
211 self.tr("""Shall all refactorings up to <b>{0}</b> be undone?""").format(
a4cba20ad7ab Corrected some code style issues and converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 412
diff changeset
212 Utilities.html_encode(change)
a4cba20ad7ab Corrected some code style issues and converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 412
diff changeset
213 ),
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
214 )
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
215 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
216 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
217 return
389
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 self.__refactoring.sendJson(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
220 "History",
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 "Subcommand": "Undo",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
223 "Id": changeId,
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
224 },
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
225 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
226
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
227 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
228 """
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 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
230 """
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
231 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
232 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
233 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
234 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
235 None,
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
236 self.tr("Redo Refactorings"),
413
a4cba20ad7ab Corrected some code style issues and converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 412
diff changeset
237 self.tr("""Shall all refactorings up to <b>{0}</b> be redone?""").format(
a4cba20ad7ab Corrected some code style issues and converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 412
diff changeset
238 Utilities.html_encode(change)
a4cba20ad7ab Corrected some code style issues and converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 412
diff changeset
239 ),
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
240 )
48
de33dc93a3ac Changed usage of QMessageBox and QFileDialog to the eric5 equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 46
diff changeset
241 if res:
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 if not self.__refactoring.confirmAllBuffersSaved():
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 return
389
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 self.__refactoring.sendJson(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
246 "History",
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 "Subcommand": "Redo",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
249 "Id": changeId,
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
250 },
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
251 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
252
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
253 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
254 """
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 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
256 """
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.__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
258 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
259 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
260 self.__clearButton.setEnabled(False)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
261
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
262 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
263 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
264 self.previewEdit.clear()
389
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 self.__refactoring.sendJson(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
267 "History", {"Subcommand": "Get", "Filename": self.__filename}
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
268 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
269
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
270 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
271 """
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 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
273 """
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
274 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
275 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
276 self.tr("Clear History"),
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
277 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
278 )
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
279 if res:
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
280 self.sendJson(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
281 "History",
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 "Subcommand": "Clear",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
284 },
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
285 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
286
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
287 self.historyCleared()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
288
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
289 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
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 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
292 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
293 """
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 self.__refreshHistories()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
295
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
296 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
297 """
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 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
299
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
300 @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
301 @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
302 """
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 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
304 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
305 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
306 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
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 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
309 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
310 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
311 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
312 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
313 self.undoChangesList.item(0),
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
314 QItemSelectionModel.SelectionFlag.Select,
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
315 )
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
316 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
317 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
318 self.redoChangesList.item(0),
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
319 QItemSelectionModel.SelectionFlag.Select,
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
320 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
321
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
322 self.__refreshButton.setEnabled(True)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
323 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
324 self.__clearButton.setEnabled(True)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
325
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
326 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
327 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
328 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
329 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
330 except (IndexError, KeyError):
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
331 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
332 self.__appendText(line, charFormat)
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
333
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
334 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
335 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
336 p = ericApp().getObject("Project")
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 if p.isDirty():
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 p.saveProject()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
339
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
340 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
341 self.__refreshHistories()
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
342
170
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
343 def closeEvent(self, evt):
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
344 """
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
345 Protected method handling close events.
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
346
170
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
347 @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
348 @type QCloseEvent
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
349 """
389
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
350 self.__refactoring.sendJson(
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
351 "History",
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 "Subcommand": "ClearChanges",
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
354 },
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
355 )
4f53795beff0 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 374
diff changeset
356
170
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
357 evt.accept()

eric ide

mercurial