445 Private method to load the saved history entries from disk. |
445 Private method to load the saved history entries from disk. |
446 """ |
446 """ |
447 historyFile = QFile(self.getFileName()) |
447 historyFile = QFile(self.getFileName()) |
448 if not historyFile.exists(): |
448 if not historyFile.exists(): |
449 return |
449 return |
450 if not historyFile.open(QIODevice.ReadOnly): |
450 if not historyFile.open(QIODevice.OpenModeFlag.ReadOnly): |
451 E5MessageBox.warning( |
451 E5MessageBox.warning( |
452 None, |
452 None, |
453 self.tr("Loading History"), |
453 self.tr("Loading History"), |
454 self.tr( |
454 self.tr( |
455 """<p>Unable to open history file <b>{0}</b>.<br/>""" |
455 """<p>Unable to open history file <b>{0}</b>.<br/>""" |
461 |
461 |
462 # double check, that the history file is sorted as it is read |
462 # double check, that the history file is sorted as it is read |
463 needToSort = False |
463 needToSort = False |
464 lastInsertedItem = HistoryEntry() |
464 lastInsertedItem = HistoryEntry() |
465 data = QByteArray(historyFile.readAll()) |
465 data = QByteArray(historyFile.readAll()) |
466 stream = QDataStream(data, QIODevice.ReadOnly) |
466 stream = QDataStream(data, QIODevice.OpenModeFlag.ReadOnly) |
467 stream.setVersion(QDataStream.Qt_4_6) |
467 stream.setVersion(QDataStream.Version.Qt_4_6) |
468 while not stream.atEnd(): |
468 while not stream.atEnd(): |
469 ver = stream.readUInt32() |
469 ver = stream.readUInt32() |
470 if ver not in HISTORY_VERSIONS: |
470 if ver not in HISTORY_VERSIONS: |
471 continue |
471 continue |
472 itm = HistoryEntry() |
472 itm = HistoryEntry() |
548 .format(f.fileName(), f.errorString())) |
548 .format(f.fileName(), f.errorString())) |
549 return |
549 return |
550 |
550 |
551 for index in range(first, -1, -1): |
551 for index in range(first, -1, -1): |
552 data = QByteArray() |
552 data = QByteArray() |
553 stream = QDataStream(data, QIODevice.WriteOnly) |
553 stream = QDataStream(data, QIODevice.OpenModeFlag.WriteOnly) |
554 stream.setVersion(QDataStream.Qt_4_6) |
554 stream.setVersion(QDataStream.Version.Qt_4_6) |
555 itm = self.__history[index] |
555 itm = self.__history[index] |
556 stream.writeUInt32(HISTORY_VERSION_60) |
556 stream.writeUInt32(HISTORY_VERSION_60) |
557 stream.writeString(itm.url.encode("utf-8")) |
557 stream.writeString(itm.url.encode("utf-8")) |
558 stream << itm.dateTime |
558 stream << itm.dateTime |
559 stream.writeString(itm.title.encode('utf-8')) |
559 stream.writeString(itm.title.encode('utf-8')) |