Helpviewer/History/HistoryManager.py

changeset 539
87f9bce38a44
parent 501
5c615a85241a
child 644
7c1c3abedf1c
equal deleted inserted replaced
538:7f1a56e80124 539:87f9bce38a44
8 """ 8 """
9 9
10 from PyQt4.QtCore import * 10 from PyQt4.QtCore import *
11 from PyQt4.QtGui import * 11 from PyQt4.QtGui import *
12 from PyQt4.QtWebKit import QWebHistoryInterface, QWebSettings 12 from PyQt4.QtWebKit import QWebHistoryInterface, QWebSettings
13
14 from E5Gui import E5MessageBox
13 15
14 from .HistoryModel import HistoryModel 16 from .HistoryModel import HistoryModel
15 from .HistoryFilterModel import HistoryFilterModel 17 from .HistoryFilterModel import HistoryFilterModel
16 from .HistoryTreeModel import HistoryTreeModel 18 from .HistoryTreeModel import HistoryTreeModel
17 19
334 """ 336 """
335 historyFile = QFile(Utilities.getConfigDir() + "/browser/history") 337 historyFile = QFile(Utilities.getConfigDir() + "/browser/history")
336 if not historyFile.exists(): 338 if not historyFile.exists():
337 return 339 return
338 if not historyFile.open(QIODevice.ReadOnly): 340 if not historyFile.open(QIODevice.ReadOnly):
339 QMessageBox.warning(None, 341 E5MessageBox.warning(None,
340 self.trUtf8("Loading History"), 342 self.trUtf8("Loading History"),
341 self.trUtf8("""<p>Unable to open history file <b>{0}</b>.<br/>""" 343 self.trUtf8("""<p>Unable to open history file <b>{0}</b>.<br/>"""
342 """Reason: {1}</p>""")\ 344 """Reason: {1}</p>""")\
343 .format(historyFile.fileName, historyFile.errorString())) 345 .format(historyFile.fileName, historyFile.errorString()))
344 return 346 return
410 else: 412 else:
411 f = historyFile 413 f = historyFile
412 opened = f.open(QIODevice.Append) 414 opened = f.open(QIODevice.Append)
413 415
414 if not opened: 416 if not opened:
415 QMessageBox.warning(None, 417 E5MessageBox.warning(None,
416 self.trUtf8("Saving History"), 418 self.trUtf8("Saving History"),
417 self.trUtf8("""<p>Unable to open history file <b>{0}</b>.<br/>""" 419 self.trUtf8("""<p>Unable to open history file <b>{0}</b>.<br/>"""
418 """Reason: {1}</p>""")\ 420 """Reason: {1}</p>""")\
419 .format(f.fileName(), f.errorString())) 421 .format(f.fileName(), f.errorString()))
420 return 422 return
430 f.write(data) 432 f.write(data)
431 433
432 f.close() 434 f.close()
433 if saveAll: 435 if saveAll:
434 if historyFile.exists() and not historyFile.remove(): 436 if historyFile.exists() and not historyFile.remove():
435 QMessageBox.warning(None, 437 E5MessageBox.warning(None,
436 self.trUtf8("Saving History"), 438 self.trUtf8("Saving History"),
437 self.trUtf8("""<p>Error removing old history file <b>{0}</b>.""" 439 self.trUtf8("""<p>Error removing old history file <b>{0}</b>."""
438 """<br/>Reason: {1}</p>""")\ 440 """<br/>Reason: {1}</p>""")\
439 .format(historyFile.fileName(), historyFile.errorString())) 441 .format(historyFile.fileName(), historyFile.errorString()))
440 if not f.copy(historyFile.fileName()): 442 if not f.copy(historyFile.fileName()):
441 QMessageBox.warning(None, 443 E5MessageBox.warning(None,
442 self.trUtf8("Saving History"), 444 self.trUtf8("Saving History"),
443 self.trUtf8("""<p>Error moving new history file over old one """ 445 self.trUtf8("""<p>Error moving new history file over old one """
444 """(<b>{0}</b>).<br/>Reason: {1}</p>""")\ 446 """(<b>{0}</b>).<br/>Reason: {1}</p>""")\
445 .format(historyFile.fileName(), f.errorString())) 447 .format(historyFile.fileName(), f.errorString()))
446 448

eric ide

mercurial