RefactoringRope/HistoryDialog.py

Wed, 26 May 2021 19:07:42 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 26 May 2021 19:07:42 +0200
branch
eric7
changeset 365
f740b50380df
parent 347
b5048b5ff454
child 374
958f34e97952
permissions
-rw-r--r--

Ported the plug-in to PyQt6 for eric7.

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
346
877cac2e8d94 Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 326
diff changeset
3 # Copyright (c) 2010 - 2021 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
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
12 from PyQt6.QtWidgets import (
320
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
13 QDialog, QDialogButtonBox, QListWidgetItem, QAbstractButton
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
14 )
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
16 from EricWidgets.EricApplication import ericApp
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
17 from EricWidgets import EricMessageBox
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
203
c38750e1bafd Performed some code cleanup actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 189
diff changeset
19 from .Ui_HistoryDialog import Ui_HistoryDialog
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
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
21 import Globals
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Utilities
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
23 import Preferences
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
20
83b71483e198 Made the code PEP-8 compliant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
25
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
26 class HistoryDialog(QDialog, Ui_HistoryDialog):
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Class implementing the History dialog.
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
30 ChangeIDRole = Qt.ItemDataRole.UserRole
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
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
32 def __init__(self, refactoring, filename="", parent=None):
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 Constructor
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 @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
37 @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
38 @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
39 @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
40 @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
41 @type QWidget
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
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
43 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
44 self.setupUi(self)
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
45 self.setWindowFlags(Qt.WindowType.Window)
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
53d76b4fc1ac 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 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
48 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
49 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
50 self.previewEdit.setFontFamily("Monospace")
53d76b4fc1ac 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
53d76b4fc1ac 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.formats = {}
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
53 self.formats[' '] = self.previewEdit.currentCharFormat()
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
54
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
55 charFormat = self.previewEdit.currentCharFormat()
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
56 charFormat.setBackground(
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
57 QBrush(Preferences.getDiffColour("AddedColor")))
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 self.formats['+'] = charFormat
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
59
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
60 charFormat = self.previewEdit.currentCharFormat()
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
61 charFormat.setBackground(
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
62 QBrush(Preferences.getDiffColour("RemovedColor")))
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
63 self.formats['-'] = charFormat
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
64
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
65 charFormat = self.previewEdit.currentCharFormat()
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
66 charFormat.setBackground(
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
67 QBrush(Preferences.getDiffColour("ReplacedColor")))
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
68 self.formats['@'] = charFormat
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
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()
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
71 charFormat.setBackground(
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
72 QBrush(Preferences.getDiffColour("ContextColor")))
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 self.formats['?'] = charFormat
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
74
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 charFormat = self.previewEdit.currentCharFormat()
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
76 charFormat.setBackground(
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
77 QBrush(Preferences.getDiffColour("HeaderColor")))
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.formats['='] = charFormat
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 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
81 self.__filename = 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
82
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
83 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
84 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
85 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
86 self.header.setText(self.tr("<b>File History: {0}</b>").format(
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
87 filename))
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
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
89 self.__undoButton = self.buttonBox.addButton(
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
90 self.tr("&Undo"), QDialogButtonBox.ButtonRole.ActionRole)
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.__redoButton = self.buttonBox.addButton(
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
92 self.tr("&Redo"), QDialogButtonBox.ButtonRole.ActionRole)
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
93 self.__refreshButton = self.buttonBox.addButton(
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
94 self.tr("Re&fresh"), QDialogButtonBox.ButtonRole.ActionRole)
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
95 self.__clearButton = self.buttonBox.addButton(
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
96 self.tr("&Clear History"), QDialogButtonBox.ButtonRole.ActionRole)
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
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()
53d76b4fc1ac 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
53d76b4fc1ac 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.
53d76b4fc1ac 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
53d76b4fc1ac 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)
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
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.
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
120
53d76b4fc1ac 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()
53d76b4fc1ac 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
53d76b4fc1ac 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.
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
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
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
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)
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
147 self.__refactoring.sendJson("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
148 "Subcommand": "GetChange",
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
149 "Id": 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
150 })
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
151
53d76b4fc1ac 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.
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
156
53d76b4fc1ac 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)
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
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.
53d76b4fc1ac 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
53d76b4fc1ac 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)
53d76b4fc1ac 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
53d76b4fc1ac 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.
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
179
53d76b4fc1ac 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)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
187
53d76b4fc1ac 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.
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
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)
53d76b4fc1ac 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
53d76b4fc1ac 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"),
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
208 self.tr("""Shall all refactorings up to <b>{0}</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
209 """ be undone?""")
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
210 .format(Utilities.html_encode(change)))
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
211 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
212 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
213 return
53d76b4fc1ac 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
53d76b4fc1ac 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 self.__refactoring.sendJson("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
216 "Subcommand": "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
217 "Id": 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
218 })
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
219
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
220 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
221 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
222 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
223 """
53d76b4fc1ac 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 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
225 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
226 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
227 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
228 None,
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
229 self.tr("Redo Refactorings"),
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
230 self.tr("""Shall all refactorings up to <b>{0}</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
231 """ be redone?""")
53d76b4fc1ac 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 .format(Utilities.html_encode(change)))
48
de33dc93a3ac Changed usage of QMessageBox and QFileDialog to the eric5 equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 46
diff changeset
233 if res:
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 if not self.__refactoring.confirmAllBuffersSaved():
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 return
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236
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
237 self.__refactoring.sendJson("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
238 "Subcommand": "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
239 "Id": 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
240 })
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
241
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
242 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
243 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
244 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
245 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
246 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
247 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
248 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
249 self.__clearButton.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
250
53d76b4fc1ac 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 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
252 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
253 self.previewEdit.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
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 self.__refactoring.sendJson("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
256 "Subcommand": "Get",
53d76b4fc1ac 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 "Filename": self.__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
258 })
53d76b4fc1ac 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
53d76b4fc1ac 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 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
261 """
53d76b4fc1ac 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 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
263 """
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
264 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
265 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
266 self.tr("Clear 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
267 self.tr("Do you really want 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
268 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
269 self.sendJson("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 "Subcommand": "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
271 })
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272
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
273 self.historyCleared()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
274
53d76b4fc1ac 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 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
276 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
277 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
278 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
279 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
280 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
281
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
282 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
283 """
53d76b4fc1ac 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 Public method to process the data sent by the refactoring client.
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
285
53d76b4fc1ac 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 @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
287 @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
288 """
53d76b4fc1ac 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 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
290 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
291 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
292 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
293 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
294 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
295 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
296 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
297 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
298 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
299 self.undoChangesList.item(0),
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
300 QItemSelectionModel.SelectionFlag.Select)
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
301 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
302 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
303 self.redoChangesList.item(0),
365
f740b50380df Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 347
diff changeset
304 QItemSelectionModel.SelectionFlag.Select)
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
305
53d76b4fc1ac 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 self.__refreshButton.setEnabled(True)
320
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
307 if (
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
308 self.undoChangesList.count() > 0 or
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
309 self.redoChangesList.count() > 0
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
310 ):
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
311 self.__clearButton.setEnabled(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
312
53d76b4fc1ac 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 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
314 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
315 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
316 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
317 except (IndexError, KeyError):
53d76b4fc1ac 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 charFormat = self.formats[' ']
53d76b4fc1ac 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.__appendText(line, 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
320
53d76b4fc1ac 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 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
322 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
323 p = ericApp().getObject("Project")
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 if p.isDirty():
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 p.saveProject()
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326
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
327 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
328 self.__refreshHistories()
170
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
329
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
330 def closeEvent(self, evt):
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
331 """
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
332 Protected method handling close events.
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
333
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
334 @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
335 @type QCloseEvent
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
336 """
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
337 self.__refactoring.sendJson("History", {
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
338 "Subcommand": "ClearChanges",
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
339 })
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
340
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
341 evt.accept()

eric ide

mercurial