9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 import os |
12 import os |
13 |
13 |
14 from PyQt4.QtCore import pyqtSignal, QFileInfo, QDateTime, QDate, QTime, \ |
14 from PyQt4.QtCore import pyqtSignal, pyqtSlot, QFileInfo, QDateTime, QDate, \ |
15 QUrl, QTimer, QFile, QIODevice, QByteArray, QDataStream, QTemporaryFile |
15 QTime, QUrl, QTimer, QFile, QIODevice, QByteArray, QDataStream, \ |
|
16 QTemporaryFile |
16 from PyQt4.QtWebKit import QWebHistoryInterface, QWebSettings |
17 from PyQt4.QtWebKit import QWebHistoryInterface, QWebSettings |
17 |
18 |
18 from E5Gui import E5MessageBox |
19 from E5Gui import E5MessageBox |
19 |
20 |
20 from Utilities.AutoSaver import AutoSaver |
21 from Utilities.AutoSaver import AutoSaver |
339 """ |
340 """ |
340 Public method to indicate a change of preferences. |
341 Public method to indicate a change of preferences. |
341 """ |
342 """ |
342 self.setDaysToExpire(Preferences.getHelp("HistoryLimit")) |
343 self.setDaysToExpire(Preferences.getHelp("HistoryLimit")) |
343 |
344 |
|
345 @pyqtSlot() |
344 def clear(self, period=0): |
346 def clear(self, period=0): |
345 """ |
347 """ |
346 Public slot to clear the complete history. |
348 Public slot to clear the complete history. |
347 |
349 |
348 @param period history period in milliseconds to be cleared (integer) |
350 @param period history period in milliseconds to be cleared (integer) |
384 if not historyFile.exists(): |
386 if not historyFile.exists(): |
385 return |
387 return |
386 if not historyFile.open(QIODevice.ReadOnly): |
388 if not historyFile.open(QIODevice.ReadOnly): |
387 E5MessageBox.warning( |
389 E5MessageBox.warning( |
388 None, |
390 None, |
389 self.trUtf8("Loading History"), |
391 self.tr("Loading History"), |
390 self.trUtf8( |
392 self.tr( |
391 """<p>Unable to open history file <b>{0}</b>.<br/>""" |
393 """<p>Unable to open history file <b>{0}</b>.<br/>""" |
392 """Reason: {1}</p>""") |
394 """Reason: {1}</p>""") |
393 .format(historyFile.fileName, historyFile.errorString())) |
395 .format(historyFile.fileName, historyFile.errorString())) |
394 return |
396 return |
395 |
397 |
464 opened = f.open(QIODevice.Append) |
466 opened = f.open(QIODevice.Append) |
465 |
467 |
466 if not opened: |
468 if not opened: |
467 E5MessageBox.warning( |
469 E5MessageBox.warning( |
468 None, |
470 None, |
469 self.trUtf8("Saving History"), |
471 self.tr("Saving History"), |
470 self.trUtf8( |
472 self.tr( |
471 """<p>Unable to open history file <b>{0}</b>.<br/>""" |
473 """<p>Unable to open history file <b>{0}</b>.<br/>""" |
472 """Reason: {1}</p>""") |
474 """Reason: {1}</p>""") |
473 .format(f.fileName(), f.errorString())) |
475 .format(f.fileName(), f.errorString())) |
474 return |
476 return |
475 |
477 |
487 f.close() |
489 f.close() |
488 if saveAll: |
490 if saveAll: |
489 if historyFile.exists() and not historyFile.remove(): |
491 if historyFile.exists() and not historyFile.remove(): |
490 E5MessageBox.warning( |
492 E5MessageBox.warning( |
491 None, |
493 None, |
492 self.trUtf8("Saving History"), |
494 self.tr("Saving History"), |
493 self.trUtf8( |
495 self.tr( |
494 """<p>Error removing old history file <b>{0}</b>.""" |
496 """<p>Error removing old history file <b>{0}</b>.""" |
495 """<br/>Reason: {1}</p>""") |
497 """<br/>Reason: {1}</p>""") |
496 .format(historyFile.fileName(), |
498 .format(historyFile.fileName(), |
497 historyFile.errorString())) |
499 historyFile.errorString())) |
498 if not f.copy(historyFile.fileName()): |
500 if not f.copy(historyFile.fileName()): |
499 E5MessageBox.warning( |
501 E5MessageBox.warning( |
500 None, |
502 None, |
501 self.trUtf8("Saving History"), |
503 self.tr("Saving History"), |
502 self.trUtf8( |
504 self.tr( |
503 """<p>Error moving new history file over old one """ |
505 """<p>Error moving new history file over old one """ |
504 """(<b>{0}</b>).<br/>Reason: {1}</p>""") |
506 """(<b>{0}</b>).<br/>Reason: {1}</p>""") |
505 .format(historyFile.fileName(), f.errorString())) |
507 .format(historyFile.fileName(), f.errorString())) |
506 self.historySaved.emit() |
508 self.historySaved.emit() |
507 try: |
509 try: |