RefactoringRope/HistoryDialog.py

Fri, 11 Oct 2019 19:05:23 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 11 Oct 2019 19:05:23 +0200
changeset 320
91b171fdd85f
parent 302
2e853e2f2430
child 326
67bcde9c65b9
permissions
-rw-r--r--

Fixed some code style issues.

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
302
2e853e2f2430 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
3 # Copyright (c) 2010 - 2019 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
76
936b2a98fe4e Merge with Py2 comp.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 62 63
diff changeset
10 from __future__ import unicode_literals
50
a29c3d2e6dc0 rope for Python2 projects enabled, if running on Python2
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
11
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
12 from PyQt5.QtCore import pyqtSlot, Qt, QItemSelectionModel
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
13 from PyQt5.QtGui import QBrush, QColor, QTextCursor
320
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
14 from PyQt5.QtWidgets import (
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
15 QDialog, QDialogButtonBox, QListWidgetItem, QAbstractButton
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
16 )
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from E5Gui.E5Application import e5App
48
de33dc93a3ac Changed usage of QMessageBox and QFileDialog to the eric5 equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 46
diff changeset
19 from E5Gui import E5MessageBox
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
203
c38750e1bafd Performed some code cleanup actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 189
diff changeset
21 from .Ui_HistoryDialog import Ui_HistoryDialog
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
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
23 import Globals
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 import Utilities
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 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 ChangeIDRole = Qt.UserRole
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
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
33 def __init__(self, refactoring, filename="", parent=None):
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 Constructor
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 @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
38 @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
39 @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
40 @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
41 @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
42 @type QWidget
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
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
44 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
45 self.setupUi(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
46 self.setWindowFlags(Qt.Window)
53d76b4fc1ac 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
53d76b4fc1ac 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 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
49 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
50 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
51 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
52
53d76b4fc1ac 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 = {}
53d76b4fc1ac 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[' '] = self.previewEdit.currentCharFormat()
53d76b4fc1ac 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()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
56 charFormat.setBackground(QBrush(QColor(190, 237, 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
57 self.formats['+'] = 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
58 charFormat = self.previewEdit.currentCharFormat()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
59 charFormat.setBackground(QBrush(QColor(237, 190, 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
60 self.formats['-'] = 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
61 charFormat = self.previewEdit.currentCharFormat()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
62 charFormat.setBackground(QBrush(QColor(190, 190, 237)))
53d76b4fc1ac 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
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
64 charFormat = self.previewEdit.currentCharFormat()
53d76b4fc1ac 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.setBackground(QBrush(QColor(124, 124, 124)))
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
66 self.formats['?'] = 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
67 charFormat = self.previewEdit.currentCharFormat()
53d76b4fc1ac 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 charFormat.setBackground(QBrush(QColor(190, 190, 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
69 self.formats['='] = charFormat
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 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
72 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
73
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
74 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
75 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
76 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
77 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
78 filename))
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
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 self.__undoButton = self.buttonBox.addButton(
53d76b4fc1ac 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.tr("&Undo"), QDialogButtonBox.ActionRole)
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
82 self.__redoButton = self.buttonBox.addButton(
53d76b4fc1ac 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 self.tr("&Redo"), QDialogButtonBox.ActionRole)
53d76b4fc1ac 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.__refreshButton = self.buttonBox.addButton(
53d76b4fc1ac 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.tr("Re&fresh"), QDialogButtonBox.ActionRole)
53d76b4fc1ac 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.__clearButton = self.buttonBox.addButton(
53d76b4fc1ac 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 self.tr("&Clear History"), QDialogButtonBox.ActionRole)
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 # 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
90 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
91
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
92 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
93 """
53d76b4fc1ac 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 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
95
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
96 @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
97 @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
98 @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
99 @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
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 tc = self.previewEdit.textCursor()
53d76b4fc1ac 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 tc.movePosition(QTextCursor.End)
53d76b4fc1ac 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 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
104 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
105 self.previewEdit.insertPlainText(txt)
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106
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
107 @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
108 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
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 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
111
53d76b4fc1ac 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 @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
113 @type QAbstractButton
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 """
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
115 if button == QDialogButtonBox.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
116 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
117 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
118 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
119 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
120 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
121 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
122 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
123 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
124 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
125
53d76b4fc1ac 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 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
127 """
53d76b4fc1ac 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 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
129
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
130 @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
131 @type QListWidgetItem
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 if current is None:
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 return
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 self.previewEdit.clear()
151
5260100b6700 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 147
diff changeset
137 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
138 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
139 "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
140 "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
141 })
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
142
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
143 @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
144 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
145 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
146 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
147
53d76b4fc1ac 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 @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
149 @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
150 @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
151 @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
152 """
53d76b4fc1ac 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 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
154 self.__currentItemChanged(current)
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155
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
156 @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
157 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
158 """
53d76b4fc1ac 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 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
160
53d76b4fc1ac 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 @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
162 @type QListWidgetItem
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 """
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
164 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
165
53d76b4fc1ac 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 @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
167 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
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
169 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
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 @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
172 @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
173 @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
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.__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
177 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
178
53d76b4fc1ac 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 @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
180 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
181 """
53d76b4fc1ac 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 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
183
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
184 @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
185 @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
186 """
53d76b4fc1ac 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 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
188
53d76b4fc1ac 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 __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
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 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
192 """
53d76b4fc1ac 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 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
194 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
195 changeId = currentUndoItem.data(HistoryDialog.ChangeIDRole)
53d76b4fc1ac 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 res = E5MessageBox.yesNo(
53d76b4fc1ac 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 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
198 self.tr("Undo refactorings"),
53d76b4fc1ac 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.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
200 """ 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
201 .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
202 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
203 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
204 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
205
53d76b4fc1ac 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 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
207 "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
208 "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
209 })
53d76b4fc1ac 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
53d76b4fc1ac 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 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
212 """
53d76b4fc1ac 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 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
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 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
216 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
217 changeId = currentRedoItem.data(HistoryDialog.ChangeIDRole)
53d76b4fc1ac 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 res = E5MessageBox.yesNo(
53d76b4fc1ac 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 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
220 self.tr("Redo refactorings"),
53d76b4fc1ac 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 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
222 """ 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
223 .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
224 if res:
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 if not self.__refactoring.confirmAllBuffersSaved():
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 return
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227
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 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
229 "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
230 "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
231 })
53d76b4fc1ac 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
53d76b4fc1ac 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 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
234 """
53d76b4fc1ac 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 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
236 """
53d76b4fc1ac 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.__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
238 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
239 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
240 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
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 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
243 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
244 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
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.__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
247 "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
248 "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
249 })
53d76b4fc1ac 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 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
252 """
53d76b4fc1ac 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 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
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 res = E5MessageBox.yesNo(
53d76b4fc1ac 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 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
257 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
258 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
259 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
260 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
261 "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
262 })
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263
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
264 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
265
53d76b4fc1ac 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 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
267 """
53d76b4fc1ac 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 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
269 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
270 """
53d76b4fc1ac 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 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
272
53d76b4fc1ac 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 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
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 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
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 @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
278 @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
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 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
281 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
282 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
283 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
284 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
285 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
286 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
287 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
288 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
289 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
290 self.undoChangesList.item(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
291 QItemSelectionModel.Select)
53d76b4fc1ac 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 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
293 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
294 self.redoChangesList.item(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
295 QItemSelectionModel.Select)
53d76b4fc1ac 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
53d76b4fc1ac 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 self.__refreshButton.setEnabled(True)
320
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
298 if (
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
299 self.undoChangesList.count() > 0 or
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
300 self.redoChangesList.count() > 0
91b171fdd85f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 302
diff changeset
301 ):
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
302 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
303
53d76b4fc1ac 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 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
305 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
306 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
307 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
308 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
309 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
310 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
311
53d76b4fc1ac 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 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
313 self.__refactoring.refreshEditors(data["ChangedFiles"])
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 p = e5App().getObject("Project")
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 if p.isDirty():
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 p.saveProject()
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317
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
318 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
319 self.__refreshHistories()
170
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
320
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
321 def closeEvent(self, evt):
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
322 """
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
323 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
324
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
325 @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
326 @type QCloseEvent
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
327 """
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
328 self.__refactoring.sendJson("History", {
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
329 "Subcommand": "ClearChanges",
05ef7c12a6d4 Modified the client side to keep multiple change caches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
330 })
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 evt.accept()

eric ide

mercurial