Helpviewer/History/HistoryCompleter.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2525
8b507a9a2d40
parent 3002
6ffc581f00f1
child 3145
a9de05d4a22f
diff -r 9986ec0e559a -r 10516539f238 Helpviewer/History/HistoryCompleter.py
--- a/Helpviewer/History/HistoryCompleter.py	Tue Oct 15 22:03:54 2013 +0200
+++ b/Helpviewer/History/HistoryCompleter.py	Fri Oct 18 23:00:41 2013 +0200
@@ -57,6 +57,7 @@
         Public method to give a size hint for rows.
         
         @param row row number (integer)
+        @return desired row height (integer)
         """
         metrics = self.fontMetrics()
         return metrics.height()
@@ -77,7 +78,8 @@
         super(HistoryCompletionModel, self).__init__(parent)
         
         self.__searchString = ""
-        self.__searchMatcher = QRegExp("", Qt.CaseInsensitive, QRegExp.FixedString)
+        self.__searchMatcher = QRegExp(
+            "", Qt.CaseInsensitive, QRegExp.FixedString)
         self.__wordMatcher = QRegExp("", Qt.CaseInsensitive)
         self.__isValid = False
         
@@ -91,8 +93,8 @@
         @param role data role (integer)
         @return history entry data
         """
-        # If the model is valid, tell QCompleter that everything we have filtered
-        # matches what the user typed; if not, nothing matches
+        # If the model is valid, tell QCompleter that everything we have
+        # filtered matches what the user typed; if not, nothing matches
         if role == self.HistoryCompletionRole and index.isValid():
             if self.isValid():
                 return "t"
@@ -126,14 +128,15 @@
         
         self.__searchString = string
         self.__searchMatcher.setPattern(self.__searchString)
-        self.__wordMatcher.setPattern("\\b" + QRegExp.escape(self.__searchString))
+        self.__wordMatcher.setPattern(
+            "\\b" + QRegExp.escape(self.__searchString))
         self.invalidateFilter()
     
     def isValid(self):
         """
         Public method to check the model for validity.
         
-        @param flag indicating a valid status (boolean)
+        @return flag indicating a valid status (boolean)
         """
         return self.__isValid
     
@@ -149,7 +152,8 @@
         self.__isValid = valid
         
         # tell the history completer that the model has changed
-        self.dataChanged.emit(self.index(0, 0), self.index(0, self.rowCount() - 1))
+        self.dataChanged.emit(self.index(0, 0), self.index(0,
+                              self.rowCount() - 1))
     
     def filterAcceptsRow(self, sourceRow, sourceParent):
         """
@@ -213,6 +217,9 @@
 
 
 class HistoryCompleter(QCompleter):
+    """
+    Class implementing a completer for the browser history.
+    """
     def __init__(self, model, parent=None):
         """
         Constructor
@@ -248,8 +255,8 @@
     
     def splitPath(self, path):
         """
-        Public method to split the given path into strings, that are used to match
-        at each level in the model.
+        Public method to split the given path into strings, that are used to
+        match at each level in the model.
         
         @param path path to be split (string)
         @return list of path elements (list of strings)
@@ -258,7 +265,8 @@
             return ["t"]
         
         # Queue an update to the search string. Wait a bit, so that if the user
-        # is quickly typing, the completer doesn't try to complete until they pause.
+        # is quickly typing, the completer doesn't try to complete until they
+        # pause.
         if self.__filterTimer.isActive():
             self.__filterTimer.stop()
         self.__filterTimer.start(150)
@@ -271,7 +279,8 @@
         self.__searchString = path
         
         # The actual filtering is done by the HistoryCompletionModel. Just
-        # return a short dummy here so that QCompleter thinks everything matched.
+        # return a short dummy here so that QCompleter thinks everything
+        # matched.
         return ["t"]
     
     def __updateFilter(self):
@@ -289,6 +298,7 @@
         # Mark it valid.
         completionModel.setValid(True)
         
-        # Now update the QCompleter widget, but only if the user is still typing a URL.
+        # Now update the QCompleter widget, but only if the user is still
+        # typing a URL.
         if self.widget() is not None and self.widget().hasFocus():
             self.complete()

eric ide

mercurial