Helpviewer/History/HistoryManager.py

changeset 3035
36e9f388958b
parent 3034
7ce719013078
child 3060
5883ce99ee12
child 3160
209a07d7e401
equal deleted inserted replaced
3034:7ce719013078 3035:36e9f388958b
349 self.__history = [] 349 self.__history = []
350 self.historyReset.emit() 350 self.historyReset.emit()
351 else: 351 else:
352 breakMS = QDateTime.currentMSecsSinceEpoch() - period 352 breakMS = QDateTime.currentMSecsSinceEpoch() - period
353 while self.__history and \ 353 while self.__history and \
354 (QDateTime(self.__history[0].dateTime).toMSecsSinceEpoch() > 354 (QDateTime(self.__history[0].dateTime).toMSecsSinceEpoch() >
355 breakMS): 355 breakMS):
356 itm = self.__history.pop(0) 356 itm = self.__history.pop(0)
357 self.entryRemoved.emit(itm) 357 self.entryRemoved.emit(itm)
358 self.__lastSavedUrl = "" 358 self.__lastSavedUrl = ""
359 self.__saveTimer.changeOccurred() 359 self.__saveTimer.changeOccurred()
360 self.__saveTimer.saveIfNeccessary() 360 self.__saveTimer.saveIfNeccessary()
386 None, 386 None,
387 self.trUtf8("Loading History"), 387 self.trUtf8("Loading History"),
388 self.trUtf8( 388 self.trUtf8(
389 """<p>Unable to open history file <b>{0}</b>.<br/>""" 389 """<p>Unable to open history file <b>{0}</b>.<br/>"""
390 """Reason: {1}</p>""") 390 """Reason: {1}</p>""")
391 .format(historyFile.fileName, historyFile.errorString())) 391 .format(historyFile.fileName, historyFile.errorString()))
392 return 392 return
393 393
394 history = [] 394 history = []
395 395
396 # double check, that the history file is sorted as it is read 396 # double check, that the history file is sorted as it is read
466 None, 466 None,
467 self.trUtf8("Saving History"), 467 self.trUtf8("Saving History"),
468 self.trUtf8( 468 self.trUtf8(
469 """<p>Unable to open history file <b>{0}</b>.<br/>""" 469 """<p>Unable to open history file <b>{0}</b>.<br/>"""
470 """Reason: {1}</p>""") 470 """Reason: {1}</p>""")
471 .format(f.fileName(), f.errorString())) 471 .format(f.fileName(), f.errorString()))
472 return 472 return
473 473
474 for index in range(first, -1, -1): 474 for index in range(first, -1, -1):
475 data = QByteArray() 475 data = QByteArray()
476 stream = QDataStream(data, QIODevice.WriteOnly) 476 stream = QDataStream(data, QIODevice.WriteOnly)
489 None, 489 None,
490 self.trUtf8("Saving History"), 490 self.trUtf8("Saving History"),
491 self.trUtf8( 491 self.trUtf8(
492 """<p>Error removing old history file <b>{0}</b>.""" 492 """<p>Error removing old history file <b>{0}</b>."""
493 """<br/>Reason: {1}</p>""") 493 """<br/>Reason: {1}</p>""")
494 .format(historyFile.fileName(), 494 .format(historyFile.fileName(),
495 historyFile.errorString())) 495 historyFile.errorString()))
496 if not f.copy(historyFile.fileName()): 496 if not f.copy(historyFile.fileName()):
497 E5MessageBox.warning( 497 E5MessageBox.warning(
498 None, 498 None,
499 self.trUtf8("Saving History"), 499 self.trUtf8("Saving History"),
500 self.trUtf8( 500 self.trUtf8(
501 """<p>Error moving new history file over old one """ 501 """<p>Error moving new history file over old one """
502 """(<b>{0}</b>).<br/>Reason: {1}</p>""") 502 """(<b>{0}</b>).<br/>Reason: {1}</p>""")
503 .format(historyFile.fileName(), f.errorString())) 503 .format(historyFile.fileName(), f.errorString()))
504 self.historySaved.emit() 504 self.historySaved.emit()
505 try: 505 try:
506 self.__lastSavedUrl = self.__history[0].url 506 self.__lastSavedUrl = self.__history[0].url
507 except IndexError: 507 except IndexError:
508 self.__lastSavedUrl = "" 508 self.__lastSavedUrl = ""

eric ide

mercurial