Tue, 06 May 2025 11:09:21 +0200
Removed a forgotten TODO marker.
11260
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2025 Detlev Offenbach <detlev@die-offenbachs.de> |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a controller for shared editing. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | import difflib |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | from PyQt6.QtCore import QCryptographicHash, QObject |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | from eric7 import Utilities |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | from eric7.EricWidgets.EricApplication import ericApp |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | from .SharedEditStatus import SharedEditStatus |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | class SharedEditorController(QObject): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | Class implementing a controller for shared editing. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | Separator = "@@@" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | StartEditToken = "START_EDIT" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | EndEditToken = "END_EDIT" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | CancelEditToken = "CANCEL_EDIT" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | RequestSyncToken = "REQUEST_SYNC" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | SyncToken = "SYNC" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | def __init__(self, cooperationClient, chatWidget): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | Constructor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | @param cooperationClient reference to the cooperation client object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | @type CooperationClient |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | @param chatWidget reference to the main cooperation widget |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | @type ChatWidget |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | super().__init__(chatWidget) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | self.__cooperationWidget = chatWidget |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | self.__cooperationClient = cooperationClient |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | def __send(self, editor, editToken, args=None): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | Private method to send an editor command to remote editors. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | @param editor reference to the editor object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | @param editToken edit command token |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | @type str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | @param args arguments for the command |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | @type str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | if self.__cooperationClient.hasConnections(): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | project = ericApp().getObject("Project") |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | fileName = editor.getFileName() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | if fileName and project.isProjectFile(fileName): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | msg = "" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | if editToken in ( |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | SharedEditorController.StartEditToken, |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | SharedEditorController.EndEditToken, |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | SharedEditorController.RequestSyncToken, |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | SharedEditorController.SyncToken, |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | ): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | msg = f"{editToken}{SharedEditorController.Separator}{args}" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | elif editToken == SharedEditorController.CancelEditToken: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | msg = f"{editToken}{SharedEditorController.Separator}c" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | self.__cooperationClient.sendEditorCommand( |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | project.getHash(), project.getRelativeUniversalPath(fileName), msg |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | ) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | def receiveEditorCommand(self, projectHash, fileName, command): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | Public method to handle received editor commands. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | @param projectHash hash of the project |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | @type str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | @param fileName project relative file name of the editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | @type str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | @param command command string |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | @type str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | project = ericApp().getObject("Project") |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | if projectHash == project.getHash(): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | fn = project.getAbsoluteUniversalPath(fileName) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | editor = ericApp().getObject("ViewManager").getOpenEditor(fn) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | if editor: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | status = self.__getSharedEditStatus(editor) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | if status.isShared: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | if status.isSyncing and not command.startswith( |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | SharedEditorController.SyncToken |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | + SharedEditorController.Separator |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | ): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | status.receivedWhileSyncing.append(command) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | else: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | self.__dispatchCommand(editor, command) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | def shareConnected(self, connected): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | Public slot to handle a change of the connected state. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | @param connected flag indicating the connected state |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | @type bool |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | for editor in ericApp().getObject("ViewManager").getOpenEditors(): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | self.__shareConnected(editor, connected) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | def shareEditor(self, share): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | Public slot to set the shared status of the current editor. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | @param share flag indicating the share status |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | @type bool |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | aw = ericApp().getObject("ViewManager").activeWindow() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | if aw is not None: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | fn = aw.getFileName() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | if fn and ericApp().getObject("Project").isProjectFile(fn): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | self.__shareEditor(aw, share) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | def startSharedEdit(self): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | Public slot to start a shared edit session for the current editor. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | aw = ericApp().getObject("ViewManager").activeWindow() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | if aw is not None: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | fn = aw.getFileName() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | if fn and ericApp().getObject("Project").isProjectFile(fn): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | self.__startSharedEdit(aw) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | def sendSharedEdit(self): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | Public slot to end a shared edit session for the current editor and |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | send the changes. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | aw = ericApp().getObject("ViewManager").activeWindow() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | if aw is not None: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | fn = aw.getFileName() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | if fn and ericApp().getObject("Project").isProjectFile(fn): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | self.__sendSharedEdit(aw) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | def cancelSharedEdit(self): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | Public slot to cancel a shared edit session for the current editor. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | aw = ericApp().getObject("ViewManager").activeWindow() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | if aw is not None: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | fn = aw.getFileName() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | if fn and ericApp().getObject("Project").isProjectFile(fn): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | self.__cancelSharedEdit(aw) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | ############################################################################ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | ## Shared editor related methods |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | ############################################################################ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | def __getSharedEditStatus(self, editor): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | Private method to get the shared edit status object of a given editor. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | If the editor does not have such an object, a default one is created and |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | set for the editor. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | @param editor reference to the editor object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | @return reference to the shared edit status |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | @rtype SharedEditStatus |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | status = editor.getSharedEditStatus() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | if status is None: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | status = SharedEditStatus() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | editor.setSharedEditStatus(status) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | return status |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | def getSharingStatus(self, editor): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | Public method to get some share status info. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | @param editor reference to the editor object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | @return tuple indicating, if the editor is sharable, the sharing |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | status, if it is inside a locally initiated shared edit session |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | and if it is inside a remotely initiated shared edit session |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | @rtype tuple of (bool, bool, bool, bool) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | project = ericApp().getObject("Project") |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | fn = editor.getFileName() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | status = self.__getSharedEditStatus(editor) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | return ( |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | bool(fn) and project.isOpen() and project.isProjectFile(fn), |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | False if status is None else status.isShared, |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | False if status is None else status.inSharedEdit, |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | False if status is None else status.inRemoteSharedEdit, |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | ) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | def __shareConnected(self, editor, connected): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | Private method to handle a change of the connected state. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | @param editor reference to the editor object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | @param connected flag indicating the connected state |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | @type bool |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | if not connected: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | status = self.__getSharedEditStatus(editor) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | status.inRemoteSharedEdit = False |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | status.isSyncing = False |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | status.receivedWhileSyncing = [] |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | editor.setReadOnly(False) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | editor.updateReadOnly() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | self.__cancelSharedEdit(editor, send=False) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | def __shareEditor(self, editor, share): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | Private method to set the shared status of the editor. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | @param editor reference to the editor object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | @param share flag indicating the share status |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | @type bool |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | status = self.__getSharedEditStatus(editor) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | status.isShared = share |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | if not share: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | self.__shareConnected(editor, False) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | def __startSharedEdit(self, editor): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | Private method to start a shared edit session for the editor. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | @param editor reference to the editor object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | status = self.__getSharedEditStatus(editor) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | status.inSharedEdit = True |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | status.savedText = editor.text() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | hashStr = str( |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | QCryptographicHash.hash( |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | Utilities.encode(status.savedText, editor.getEncoding())[0], |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | QCryptographicHash.Algorithm.Sha1, |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | ).toHex(), |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | encoding="utf-8", |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
250 | ) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | self.__send(editor, SharedEditorController.StartEditToken, hashStr) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | def __sendSharedEdit(self, editor): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
254 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
255 | Private method to end a shared edit session for the editor and |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
256 | send the changes. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
257 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | @param editor reference to the editor object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
261 | status = self.__getSharedEditStatus(editor) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | commands = self.__calculateChanges(status.savedText, editor.text()) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
263 | self.__send(editor, SharedEditorController.EndEditToken, commands) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | status.inSharedEdit = False |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | status.savedText = "" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
266 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
267 | def __cancelSharedEdit(self, editor, send=True): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
269 | Private method to cancel a shared edit session for the editor. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | @param editor reference to the editor object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
272 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
273 | @param send flag indicating to send the CancelEdit command |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | @type bool |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
275 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
276 | status = self.__getSharedEditStatus(editor) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
277 | status.inSharedEdit = False |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
278 | status.savedText = "" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
279 | if send: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
280 | self.__send(editor, SharedEditorController.CancelEditToken) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
281 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
282 | def __dispatchCommand(self, editor, command): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
283 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
284 | Private method to dispatch received commands. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
285 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
286 | @param editor reference to the edior object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | @param command command to be processed |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | @type str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
290 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
291 | editToken, argsString = command.split(SharedEditorController.Separator, 1) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | if editToken == SharedEditorController.StartEditToken: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
293 | self.__processStartEditCommand(editor, argsString) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
294 | elif editToken == SharedEditorController.CancelEditToken: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
295 | self.__shareConnected(editor, False) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
296 | elif editToken == SharedEditorController.EndEditToken: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
297 | self.__processEndEditCommand(editor, argsString) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
298 | elif editToken == SharedEditorController.RequestSyncToken: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
299 | self.__processRequestSyncCommand(editor, argsString) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
300 | elif editToken == SharedEditorController.SyncToken: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
301 | self.__processSyncCommand(editor, argsString) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
302 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
303 | def __processStartEditCommand(self, editor, argsString): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
304 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
305 | Private method to process a remote StartEdit command. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
306 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
307 | @param editor reference to the editor object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
308 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
309 | @param argsString string containing the command parameters |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
310 | @type str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
311 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
312 | status = self.__getSharedEditStatus(editor) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
313 | if not status.inSharedEdit and not status.inRemoteSharedEdit: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
314 | status.inRemoteSharedEdit = True |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
315 | editor.setReadOnly(True) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
316 | editor.updateReadOnly() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
317 | hashStr = str( |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
318 | QCryptographicHash.hash( |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
319 | Utilities.encode(editor.text(), editor.getEncoding())[0], |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
320 | QCryptographicHash.Algorithm.Sha1, |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
321 | ).toHex(), |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
322 | encoding="utf-8", |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
323 | ) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | if hashStr != argsString: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
325 | # text is different to the remote site, request to sync it |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
326 | status.isSyncing = True |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
327 | self.__send(editor, SharedEditorController.RequestSyncToken, argsString) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
328 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
329 | def __calculateChanges(self, old, new): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
330 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
331 | Private method to determine change commands to convert old text into |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
332 | new text. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
333 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
334 | @param old old text |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
335 | @type str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
336 | @param new new text |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
337 | @type str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
338 | @return commands to change old into new |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
339 | @rtype str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
340 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
341 | oldL = old.splitlines() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
342 | newL = new.splitlines() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
343 | matcher = difflib.SequenceMatcher(None, oldL, newL) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
344 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
345 | formatStr = "@@{0} {1} {2} {3}" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
346 | commands = [] |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
347 | for diffToken, i1, i2, j1, j2 in matcher.get_opcodes(): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
348 | if diffToken == "insert": |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
349 | commands.append(formatStr.format("i", j1, j2 - j1, -1)) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
350 | commands.extend(newL[j1:j2]) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
351 | elif diffToken == "delete": |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
352 | commands.append(formatStr.format("d", j1, i2 - i1, -1)) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
353 | elif diffToken == "replace": |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
354 | commands.append(formatStr.format("r", j1, i2 - i1, j2 - j1)) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
355 | commands.extend(newL[j1:j2]) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
356 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
357 | return "\n".join(commands) + "\n" |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
358 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
359 | def __processEndEditCommand(self, editor, argsString): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
360 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
361 | Private method to process a remote EndEdit command. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
362 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
363 | @param editor reference to the editor object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
364 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
365 | @param argsString string containing the command parameters |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
366 | @type str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
367 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
368 | status = self.__getSharedEditStatus(editor) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
369 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
370 | commands = argsString.splitlines() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
371 | sep = editor.getLineSeparator() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
372 | cur = editor.getCursorPosition() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
373 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
374 | editor.setReadOnly(False) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
375 | editor.beginUndoAction() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
376 | while commands: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
377 | commandLine = commands.pop(0) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
378 | if not commandLine.startswith("@@"): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
379 | continue |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
381 | args = commandLine.split() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
382 | command = args.pop(0) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
383 | pos, l1, l2 = [int(arg) for arg in args] |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
384 | if command == "@@i": |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
385 | txt = sep.join(commands[0:l1]) + sep |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
386 | editor.insertAt(txt, pos, 0) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
387 | del commands[0:l1] |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
388 | elif command == "@@d": |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
389 | editor.setSelection(pos, 0, pos + l1, 0) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
390 | editor.removeSelectedText() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
391 | elif command == "@@r": |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
392 | editor.setSelection(pos, 0, pos + l1, 0) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
393 | editor.removeSelectedText() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
394 | txt = sep.join(commands[0:l2]) + sep |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
395 | editor.insertAt(txt, pos, 0) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
396 | del commands[0:l2] |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
397 | editor.endUndoAction() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
398 | editor.updateReadOnly() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
399 | status.inRemoteSharedEdit = False |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
400 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
401 | editor.setCursorPosition(*cur) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
402 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
403 | def __processRequestSyncCommand(self, editor, argsString): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
404 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
405 | Private method to process a remote RequestSync command. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
406 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
407 | @param editor reference to the editor object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
408 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
409 | @param argsString string containing the command parameters |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
410 | @type str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
411 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
412 | status = self.__getSharedEditStatus(editor) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
413 | if status.inSharedEdit: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
414 | hashStr = str( |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
415 | QCryptographicHash.hash( |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
416 | Utilities.encode(status.savedText, editor.getEncoding())[0], |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
417 | QCryptographicHash.Algorithm.Sha1, |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
418 | ).toHex(), |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
419 | encoding="utf-8", |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
420 | ) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
421 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
422 | if hashStr == argsString: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
423 | self.__send(editor, SharedEditorController.SyncToken, status.savedText) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
424 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
425 | def __processSyncCommand(self, editor, argsString): |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
426 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
427 | Private method to process a remote Sync command. |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
428 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
429 | @param editor reference to the editor object |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
430 | @type Editor |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
431 | @param argsString string containing the command parameters |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
432 | @type str |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
433 | """ |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
434 | status = self.__getSharedEditStatus(editor) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
435 | if status.isSyncing: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
436 | cur = editor.getCursorPosition() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
437 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
438 | editor.setReadOnly(False) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
439 | editor.beginUndoAction() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
440 | editor.selectAll() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
441 | editor.removeSelectedText() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
442 | editor.insertAt(argsString, 0, 0) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
443 | editor.endUndoAction() |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
444 | editor.setReadOnly(True) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
445 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
446 | editor.setCursorPosition(*cur) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
447 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
448 | while status.receivedWhileSyncing: |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
449 | command = status.receivedWhileSyncing.pop(0) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
450 | self.__dispatchCommand(editor, command) |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
451 | |
67773a953b64
Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
452 | status.isSyncing = False |