403 stream = QDataStream(historyArray, QIODevice.WriteOnly) |
403 stream = QDataStream(historyArray, QIODevice.WriteOnly) |
404 stream << self.history() |
404 stream << self.history() |
405 sessionData["History"] = str( |
405 sessionData["History"] = str( |
406 historyArray.toBase64(QByteArray.Base64UrlEncoding), |
406 historyArray.toBase64(QByteArray.Base64UrlEncoding), |
407 encoding="ascii") |
407 encoding="ascii") |
|
408 sessionData["HistoryIndex"] = self.history().currentItemIndex() |
408 |
409 |
409 return sessionData |
410 return sessionData |
|
411 |
|
412 def loadFromSessionData(self, sessionData): |
|
413 """ |
|
414 Public method to load the session data. |
|
415 |
|
416 @param sessionData dictionary containing the session data as |
|
417 generated by getSessionData() |
|
418 @type dict |
|
419 """ |
|
420 # 1. page history |
|
421 if "History" in sessionData: |
|
422 historyArray = QByteArray.fromBase64( |
|
423 sessionData["History"].encode("ascii"), |
|
424 QByteArray.Base64UrlEncoding) |
|
425 stream = QDataStream(historyArray, QIODevice.ReadOnly) |
|
426 stream >> self.history() |
|
427 |
|
428 if "HistoryIndex" in sessionData: |
|
429 item = self.history().itemAt(sessionData["HistoryIndex"]) |
|
430 if item is not None: |
|
431 self.history().goToItem(item) |
|
432 |
|
433 # 2. zoom factor |
|
434 if "ZoomFactor" in sessionData: |
|
435 self.setZoomFactor(sessionData["ZoomFactor"]) |
|
436 |
|
437 # 3. scroll position |
|
438 if "ScrollPosition" in sessionData: |
|
439 scrollPos = sessionData["ScrollPosition"] |
|
440 self.scrollTo(QPointF(scrollPos["x"], scrollPos["y"])) |
410 |
441 |
411 ################################################## |
442 ################################################## |
412 ## Methods below implement compatibility functions |
443 ## Methods below implement compatibility functions |
413 ################################################## |
444 ################################################## |
414 |
445 |