src/eric7/WebBrowser/Sync/SyncManager.py

branch
eric7
changeset 10436
f6881d10e995
parent 9653
e67609152c5e
child 10439
21c28b0f9e41
equal deleted inserted replaced
10435:c712d09cc839 10436:f6881d10e995
19 19
20 class SyncManager(QObject): 20 class SyncManager(QObject):
21 """ 21 """
22 Class implementing the synchronization manager. 22 Class implementing the synchronization manager.
23 23
24 @signal syncError(message) emitted for a general error with the error 24 @signal syncError(message) emitted for a general error with the error message
25 message (string) 25 @signal syncMessage(message) emitted to give status info about the sync process
26 @signal syncMessage(message) emitted to give status info about the sync 26 @signal syncStatus(type_, message) emitted to indicate the synchronization status
27 process (string) 27 @signal syncFinished(type_, done, download) emitted after a synchronization
28 @signal syncStatus(type_, message) emitted to indicate the synchronization 28 has finished
29 status (string one of "bookmarks", "history", "passwords",
30 "useragents" or "speeddial", string)
31 @signal syncFinished(type_, done, download) emitted after a
32 synchronization has finished (string one of "bookmarks", "history",
33 "passwords", "useragents" or "speeddial", boolean, boolean)
34 """ 29 """
35 30
36 syncError = pyqtSignal(str) 31 syncError = pyqtSignal(str)
37 syncMessage = pyqtSignal(str) 32 syncMessage = pyqtSignal(str)
38 syncStatus = pyqtSignal(str, str) 33 syncStatus = pyqtSignal(str, str)
40 35
41 def __init__(self, parent=None): 36 def __init__(self, parent=None):
42 """ 37 """
43 Constructor 38 Constructor
44 39
45 @param parent reference to the parent object (QObject) 40 @param parent reference to the parent object
41 @type QObject
46 """ 42 """
47 super().__init__(parent) 43 super().__init__(parent)
48 44
49 self.__handler = None 45 self.__handler = None
50 46
51 def handler(self): 47 def handler(self):
52 """ 48 """
53 Public method to get a reference to the sync handler object. 49 Public method to get a reference to the sync handler object.
54 50
55 @return reference to the sync handler object (SyncHandler) 51 @return reference to the sync handler object
52 @rtype SyncHandler
56 """ 53 """
57 return self.__handler 54 return self.__handler
58 55
59 def showSyncDialog(self): 56 def showSyncDialog(self):
60 """ 57 """
68 def loadSettings(self, forceUpload=False): 65 def loadSettings(self, forceUpload=False):
69 """ 66 """
70 Public method to load the settings. 67 Public method to load the settings.
71 68
72 @param forceUpload flag indicating a forced upload of the files 69 @param forceUpload flag indicating a forced upload of the files
73 (boolean) 70
71 @type bool
74 """ 72 """
75 if self.__handler is not None: 73 if self.__handler is not None:
76 self.__handler.syncError.disconnect(self.__syncError) 74 self.__handler.syncError.disconnect(self.__syncError)
77 self.__handler.syncFinished.disconnect(self.__syncFinished) 75 self.__handler.syncFinished.disconnect(self.__syncFinished)
78 self.__handler.syncStatus.disconnect(self.__syncStatus) 76 self.__handler.syncStatus.disconnect(self.__syncStatus)
200 def syncEnabled(self): 198 def syncEnabled(self):
201 """ 199 """
202 Public method to check, if synchronization is enabled. 200 Public method to check, if synchronization is enabled.
203 201
204 @return flag indicating enabled synchronization 202 @return flag indicating enabled synchronization
203 @rtype bool
205 """ 204 """
206 from . import SyncGlobals 205 from . import SyncGlobals
207 206
208 return ( 207 return (
209 Preferences.getWebBrowser("SyncEnabled") 208 Preferences.getWebBrowser("SyncEnabled")
247 246
248 def __syncError(self, message): 247 def __syncError(self, message):
249 """ 248 """
250 Private slot to handle general synchronization issues. 249 Private slot to handle general synchronization issues.
251 250
252 @param message error message (string) 251 @param message error message
252 @type str
253 """ 253 """
254 self.syncError.emit(message) 254 self.syncError.emit(message)
255 255
256 def __syncFinished(self, type_, status, download): 256 def __syncFinished(self, type_, status, download):
257 """ 257 """
258 Private slot to handle a finished synchronization event. 258 Private slot to handle a finished synchronization event.
259 259
260 @param type_ type of the synchronization event (string one 260 @param type_ type of the synchronization event (one of "bookmarks",
261 of "bookmarks", "history", "passwords", "useragents" or 261 "history", "passwords", "useragents" or "speeddial")
262 "speeddial") 262 @type str
263 @param status flag indicating success (boolean) 263 @param status flag indicating success
264 @param download flag indicating a download of a file (boolean) 264 @type bool
265 @param download flag indicating a download of a file
266 @type bool
265 """ 267 """
266 if status and download: 268 if status and download:
267 if type_ == "bookmarks": 269 if type_ == "bookmarks":
268 WebBrowserWindow.bookmarksManager().reload() 270 WebBrowserWindow.bookmarksManager().reload()
269 elif type_ == "history": 271 elif type_ == "history":
278 280
279 def __syncStatus(self, type_, message): 281 def __syncStatus(self, type_, message):
280 """ 282 """
281 Private slot to handle a status update of a synchronization event. 283 Private slot to handle a status update of a synchronization event.
282 284
283 @param type_ type of the synchronization event (string one 285 @param type_ type of the synchronization event (one of "bookmarks",
284 of "bookmarks", "history", "passwords", "useragents" or 286 "history", "passwords", "useragents" or "speeddial")
285 "speeddial") 287 @type str
286 @param message status message for the event (string) 288 @param message status message for the event
289 @type str
287 """ 290 """
288 self.syncMessage.emit(message) 291 self.syncMessage.emit(message)
289 self.syncStatus.emit(type_, message) 292 self.syncStatus.emit(type_, message)
290 293
291 def close(self): 294 def close(self):

eric ide

mercurial