RefactoringRope/HistoryDialog.py

Sun, 17 Sep 2017 17:03:16 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 17 Sep 2017 17:03:16 +0200
branch
server_client_variant
changeset 168
53d76b4fc1ac
parent 151
5260100b6700
child 170
05ef7c12a6d4
permissions
-rw-r--r--

Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.

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
147
3f8a995f6e49 Updated copyright for 2017.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 144
diff changeset
3 # Copyright (c) 2010 - 2017 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
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
14 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, 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
15 QAbstractButton
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 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
18 from E5Gui import E5MessageBox
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
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
20 from Ui_HistoryDialog import Ui_HistoryDialog
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
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
22 import Globals
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 import Utilities
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 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 ChangeIDRole = Qt.UserRole
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
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
37 @type Refactoring
53d76b4fc1ac 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)
53d76b4fc1ac 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.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
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()
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
54 charFormat = self.previewEdit.currentCharFormat()
53d76b4fc1ac 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.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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65 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
66 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
67 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
68 self.formats['='] = charFormat
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 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
71 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
72
53d76b4fc1ac 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 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
74 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
75 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
76 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
77 filename))
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
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
79 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
80 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
81 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
82 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
83 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
84 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
85 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
86 self.tr("&Clear History"), QDialogButtonBox.ActionRole)
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 # 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
89 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
90
53d76b4fc1ac 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 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
92 """
53d76b4fc1ac 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 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
94
53d76b4fc1ac 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 @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
96 @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
97 @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
98 @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
99 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
100 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
101 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
102 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
103 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
104 self.previewEdit.insertPlainText(txt)
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
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
106 @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
107 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
108 """
53d76b4fc1ac 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 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
110
53d76b4fc1ac 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 @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
112 @type QAbstractButton
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 """
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
114 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
115 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
116 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
117 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
118 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
119 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
120 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
121 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
122 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
123 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
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
125 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
126 """
53d76b4fc1ac 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 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
128
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
129 @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
130 @type QListWidgetItem
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 """
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 if current is None:
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 return
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.previewEdit.clear()
151
5260100b6700 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 147
diff changeset
136 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
137 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
138 "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
139 "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
140 })
53d76b4fc1ac 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 @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
143 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
144 """
53d76b4fc1ac 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 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
146
53d76b4fc1ac 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 @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
148 @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
149 @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
150 @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
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 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
153 self.__currentItemChanged(current)
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
155 @pyqtSlot(QListWidgetItem)
53d76b4fc1ac 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 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
157 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
158 Private slot handling a 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
159
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
160 @param 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
161 @type QListWidgetItem
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 """
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
163 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
164
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
165 @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
166 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
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 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
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 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
171 @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
172 @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
173 @type QListWidgetItem
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 """
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
175 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
176 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
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 @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
179 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
180 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
181 Private slot handling a click on an undo entry.
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
183 @param 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
184 @type QListWidgetItem
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
185 """
53d76b4fc1ac 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(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
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 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
189 """
53d76b4fc1ac 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 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
191 """
53d76b4fc1ac 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 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
193 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
194 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
195 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
196 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
197 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
198 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
199 """ 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
200 .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
201 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
202 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
203 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
204
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
205 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
206 "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
207 "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
208 })
53d76b4fc1ac 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 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
211 """
53d76b4fc1ac 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 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
213 """
53d76b4fc1ac 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 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
215 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
216 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
217 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
218 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
219 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
220 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
221 """ 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
222 .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
223 if res:
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 if not self.__refactoring.confirmAllBuffersSaved():
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 return
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226
168
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
227 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
228 "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
229 "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
230 })
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
231
53d76b4fc1ac 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 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
233 """
53d76b4fc1ac 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 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
235 """
53d76b4fc1ac 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 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
237 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
238 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
239 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
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 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
242 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
243 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
244
53d76b4fc1ac 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 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
246 "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
247 "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
248 })
53d76b4fc1ac 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 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
251 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
252 Private method to 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
253 """
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
254 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
255 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
256 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
257 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
258 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
259 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
260 "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
261 })
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262
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
263 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
264
53d76b4fc1ac 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 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
266 """
53d76b4fc1ac 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 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
268 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
269 """
53d76b4fc1ac 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 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
271
53d76b4fc1ac Implemented the distributed History dialog and moved the Undo/Redo functions to this dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
272 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
273 """
53d76b4fc1ac 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 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
275
53d76b4fc1ac 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 @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
277 @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
278 """
53d76b4fc1ac 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 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
280 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
281 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
282 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
283 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
284 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
285 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
286 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
287 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
288 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
289 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
290 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
291 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
292 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
293 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
294 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
295
53d76b4fc1ac 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 self.__refreshButton.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
297 if self.undoChangesList.count() > 0 or \
53d76b4fc1ac 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.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
299 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
300
53d76b4fc1ac 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 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
302 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
303 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
304 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
305 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
306 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
307 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
308
53d76b4fc1ac 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 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
310 self.__refactoring.refreshEditors(data["ChangedFiles"])
4
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 p = e5App().getObject("Project")
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 if p.isDirty():
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 p.saveProject()
2e2463ef1aae Added the undo/redo functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314
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
315 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
316 self.__refreshHistories()

eric ide

mercurial