Helpviewer/History/HistoryManager.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2599
2373006616da
parent 3002
6ffc581f00f1
child 3058
0a02c433f52d
diff -r 9986ec0e559a -r 10516539f238 Helpviewer/History/HistoryManager.py
--- a/Helpviewer/History/HistoryManager.py	Tue Oct 15 22:03:54 2013 +0200
+++ b/Helpviewer/History/HistoryManager.py	Fri Oct 18 23:00:41 2013 +0200
@@ -11,8 +11,8 @@
 
 import os
 
-from PyQt4.QtCore import pyqtSignal, QFileInfo, QDateTime, QDate, QTime, QUrl, QTimer, \
-    QFile, QIODevice, QByteArray, QDataStream, QTemporaryFile
+from PyQt4.QtCore import pyqtSignal, QFileInfo, QDateTime, QDate, QTime, \
+    QUrl, QTimer, QFile, QIODevice, QByteArray, QDataStream, QTemporaryFile
 from PyQt4.QtWebKit import QWebHistoryInterface, QWebSettings
 
 from E5Gui import E5MessageBox
@@ -44,7 +44,8 @@
         """
         Special method determining equality.
         
-        @param other reference to the history entry to compare against (HistoryEntry)
+        @param other reference to the history entry to compare against
+            (HistoryEntry)
         @return flag indicating equality (boolean)
         """
         return other.title == self.title and \
@@ -57,7 +58,8 @@
         
         Note: History is sorted in reverse order by date and time
         
-        @param other reference to the history entry to compare against (HistoryEntry)
+        @param other reference to the history entry to compare against
+            (HistoryEntry)
         @return flag indicating less (boolean)
         """
         return self.dateTime > other.dateTime
@@ -82,8 +84,10 @@
     
     @signal historyCleared() emitted after the history has been cleared
     @signal historyReset() emitted after the history has been reset
-    @signal entryAdded(HistoryEntry) emitted after a history entry has been added
-    @signal entryRemoved(HistoryEntry) emitted after a history entry has been removed
+    @signal entryAdded(HistoryEntry) emitted after a history entry has been
+        added
+    @signal entryRemoved(HistoryEntry) emitted after a history entry has been
+        removed
     @signal entryUpdated(int) emitted after a history entry has been updated
     @signal historySaved() emitted after the history was saved
     """
@@ -125,8 +129,10 @@
         from .HistoryTreeModel import HistoryTreeModel
         
         self.__historyModel = HistoryModel(self, self)
-        self.__historyFilterModel = HistoryFilterModel(self.__historyModel, self)
-        self.__historyTreeModel = HistoryTreeModel(self.__historyFilterModel, self)
+        self.__historyFilterModel = \
+            HistoryFilterModel(self.__historyModel, self)
+        self.__historyTreeModel = \
+            HistoryTreeModel(self.__historyFilterModel, self)
         
         super(HistoryManager, self).setDefaultInterface(self)
         self.__startFrequencyTimer()
@@ -154,7 +160,8 @@
         
         @param history reference to the list of history entries to be set
             (list of HistoryEntry)
-        @param loadedAndSorted flag indicating that the list is sorted (boolean)
+        @param loadedAndSorted flag indicating that the list is sorted
+            (boolean)
         """
         self.__history = history[:]
         if not loadedAndSorted:
@@ -219,7 +226,8 @@
                 cleanurl.setPassword("")
             if cleanurl.host():
                 cleanurl.setHost(cleanurl.host().lower())
-            itm = HistoryEntry(cleanurl.toString(), QDateTime.currentDateTime())
+            itm = HistoryEntry(cleanurl.toString(),
+                               QDateTime.currentDateTime())
             self._addHistoryEntry(itm)
     
     def updateHistoryEntry(self, url, title):
@@ -289,7 +297,8 @@
         
         while self.__history:
             checkForExpired = QDateTime(self.__history[-1].dateTime)
-            checkForExpired.setDate(checkForExpired.date().addDays(self.__daysToExpire))
+            checkForExpired.setDate(
+                checkForExpired.date().addDays(self.__daysToExpire))
             if now.daysTo(checkForExpired) > 7:
                 nextTimeout = 7 * 86400
             else:
@@ -344,7 +353,8 @@
         else:
             breakMS = QDateTime.currentMSecsSinceEpoch() - period
             while self.__history and \
-                  QDateTime(self.__history[0].dateTime).toMSecsSinceEpoch() > breakMS:
+                  (QDateTime(self.__history[0].dateTime).toMSecsSinceEpoch() >
+                   breakMS):
                 itm = self.__history.pop(0)
                 self.entryRemoved.emit(itm)
         self.__lastSavedUrl = ""
@@ -376,8 +386,9 @@
         if not historyFile.open(QIODevice.ReadOnly):
             E5MessageBox.warning(None,
                 self.trUtf8("Loading History"),
-                self.trUtf8("""<p>Unable to open history file <b>{0}</b>.<br/>"""
-                            """Reason: {1}</p>""")\
+                self.trUtf8(
+                    """<p>Unable to open history file <b>{0}</b>.<br/>"""
+                    """Reason: {1}</p>""")\
                     .format(historyFile.fileName, historyFile.errorString()))
             return
         
@@ -454,8 +465,9 @@
         if not opened:
             E5MessageBox.warning(None,
                 self.trUtf8("Saving History"),
-                self.trUtf8("""<p>Unable to open history file <b>{0}</b>.<br/>"""
-                            """Reason: {1}</p>""")\
+                self.trUtf8(
+                    """<p>Unable to open history file <b>{0}</b>.<br/>"""
+                    """Reason: {1}</p>""")\
                     .format(f.fileName(), f.errorString()))
             return
         
@@ -475,14 +487,17 @@
             if historyFile.exists() and not historyFile.remove():
                 E5MessageBox.warning(None,
                     self.trUtf8("Saving History"),
-                    self.trUtf8("""<p>Error removing old history file <b>{0}</b>."""
-                                """<br/>Reason: {1}</p>""")\
-                        .format(historyFile.fileName(), historyFile.errorString()))
+                    self.trUtf8(
+                        """<p>Error removing old history file <b>{0}</b>."""
+                        """<br/>Reason: {1}</p>""")\
+                        .format(historyFile.fileName(),
+                                historyFile.errorString()))
             if not f.copy(historyFile.fileName()):
                 E5MessageBox.warning(None,
                     self.trUtf8("Saving History"),
-                    self.trUtf8("""<p>Error moving new history file over old one """
-                                """(<b>{0}</b>).<br/>Reason: {1}</p>""")\
+                    self.trUtf8(
+                        """<p>Error moving new history file over old one """
+                        """(<b>{0}</b>).<br/>Reason: {1}</p>""")\
                         .format(historyFile.fileName(), f.errorString()))
         self.historySaved.emit()
         try:
@@ -502,4 +517,5 @@
         Private method to start the timer to recalculate the frequencies.
         """
         tomorrow = QDateTime(QDate.currentDate().addDays(1), QTime(3, 0))
-        self.__frequencyTimer.start(QDateTime.currentDateTime().secsTo(tomorrow) * 1000)
+        self.__frequencyTimer.start(
+            QDateTime.currentDateTime().secsTo(tomorrow) * 1000)

eric ide

mercurial