summaryrefslogtreecommitdiff
path: root/qutebrowser/browser/history.py
diff options
context:
space:
mode:
Diffstat (limited to 'qutebrowser/browser/history.py')
-rw-r--r--qutebrowser/browser/history.py44
1 files changed, 21 insertions, 23 deletions
diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py
index 312edfc13..bf2277188 100644
--- a/qutebrowser/browser/history.py
+++ b/qutebrowser/browser/history.py
@@ -25,13 +25,11 @@ import contextlib
import pathlib
from typing import cast, Mapping, MutableSequence, Optional
-from qutebrowser.qt.core import pyqtSlot, QUrl, QObject, pyqtSignal
-from qutebrowser.qt.widgets import QProgressDialog, QApplication
-
from qutebrowser.config import config
from qutebrowser.api import cmdutils
from qutebrowser.utils import utils, log, usertypes, message, qtutils
from qutebrowser.misc import objects, sql
+from qutebrowser.qt import widgets, core
web_history = cast('WebHistory', None)
@@ -52,27 +50,27 @@ class HistoryProgress:
def start(self, text):
"""Start showing a progress dialog."""
- self._progress = QProgressDialog()
+ self._progress = widgets.QProgressDialog()
self._progress.setMaximum(0) # unknown
self._progress.setMinimumDuration(0)
self._progress.setLabelText(text)
self._progress.setCancelButton(None)
self._progress.setAutoClose(False)
self._progress.show()
- QApplication.processEvents()
+ widgets.QApplication.processEvents()
def set_maximum(self, maximum):
"""Set the progress maximum as soon as we know about it."""
assert self._progress is not None
self._progress.setMaximum(maximum)
- QApplication.processEvents()
+ widgets.QApplication.processEvents()
def tick(self):
"""Increase the displayed progress value."""
self._value += 1
if self._progress is not None:
self._progress.setValue(self._value)
- QApplication.processEvents()
+ widgets.QApplication.processEvents()
def finish(self):
"""Finish showing the progress dialog.
@@ -93,7 +91,7 @@ class CompletionMetaInfo(sql.SqlTable):
}
def __init__(self, database: sql.Database,
- parent: Optional[QObject] = None) -> None:
+ parent: Optional[core.QObject] = None) -> None:
self._fields = ['key', 'value']
self._constraints = {'key': 'PRIMARY KEY'}
super().__init__(database, "CompletionMetaInfo", self._fields,
@@ -141,7 +139,7 @@ class CompletionHistory(sql.SqlTable):
"""History which only has the newest entry for each URL."""
def __init__(self, database: sql.Database,
- parent: Optional[QObject] = None) -> None:
+ parent: Optional[core.QObject] = None) -> None:
super().__init__(database, "CompletionHistory", ['url', 'title', 'last_atime'],
constraints={'url': 'PRIMARY KEY',
'title': 'NOT NULL',
@@ -161,12 +159,12 @@ class WebHistory(sql.SqlTable):
"""
# All web history cleared
- history_cleared = pyqtSignal()
+ history_cleared = core.pyqtSignal()
# one url cleared
- url_cleared = pyqtSignal(QUrl)
+ url_cleared = core.pyqtSignal(core.QUrl)
def __init__(self, database: sql.Database, progress: HistoryProgress,
- parent: Optional[QObject] = None) -> None:
+ parent: Optional[core.QObject] = None) -> None:
super().__init__(database, "History", ['url', 'title', 'atime', 'redirect'],
constraints={'url': 'NOT NULL',
'title': 'NOT NULL',
@@ -300,14 +298,14 @@ class WebHistory(sql.SqlTable):
# Delete old entries
self.completion.delete_all()
- QApplication.processEvents()
+ widgets.QApplication.processEvents()
# Select the latest entry for each url
q = self.database.query('SELECT url, title, max(atime) AS atime FROM History '
'WHERE NOT redirect '
'GROUP BY url ORDER BY atime asc')
result = q.run()
- QApplication.processEvents()
+ widgets.QApplication.processEvents()
entries = list(result)
self._progress.set_maximum(len(entries))
@@ -315,7 +313,7 @@ class WebHistory(sql.SqlTable):
for entry in entries:
self._progress.tick()
- url = QUrl(entry.url)
+ url = core.QUrl(entry.url)
if self._is_excluded_from_completion(url):
continue
data['url'].append(self._format_completion_url(url))
@@ -326,10 +324,10 @@ class WebHistory(sql.SqlTable):
# We might have caused fragmentation - let's clean up.
self.database.query('VACUUM').run()
- QApplication.processEvents()
+ widgets.QApplication.processEvents()
self.completion.insert_batch(data, replace=True)
- QApplication.processEvents()
+ widgets.QApplication.processEvents()
self._progress.finish()
self.metainfo['force_rebuild'] = False
@@ -373,7 +371,7 @@ class WebHistory(sql.SqlTable):
Args:
url: URL string to delete.
"""
- qurl = QUrl(url)
+ qurl = core.QUrl(url)
qtutils.ensure_valid(qurl)
self.delete('url', self._format_url(qurl))
self.completion.delete('url', self._format_completion_url(qurl))
@@ -381,7 +379,7 @@ class WebHistory(sql.SqlTable):
self._last_url = None
self.url_cleared.emit(qurl)
- @pyqtSlot(QUrl, QUrl, str)
+ @core.pyqtSlot(core.QUrl, core.QUrl, str)
def add_from_tab(self, url, requested_url, title):
"""Add a new history entry as slot, called from a BrowserTab."""
if self._is_excluded_entirely(url) or self._is_excluded_entirely(requested_url):
@@ -390,7 +388,7 @@ class WebHistory(sql.SqlTable):
# things set via setHtml
return
- no_formatting = QUrl.UrlFormattingOption(0)
+ no_formatting = core.QUrl.UrlFormattingOption(0)
if (requested_url.isValid() and
not requested_url.matches(url, no_formatting)):
# If the url of the page is different than the url of the link
@@ -435,10 +433,10 @@ class WebHistory(sql.SqlTable):
}, replace=True)
def _format_url(self, url):
- return url.toString(QUrl.UrlFormattingOption.RemovePassword | QUrl.ComponentFormattingOption.FullyEncoded)
+ return url.toString(core.QUrl.UrlFormattingOption.RemovePassword | core.QUrl.ComponentFormattingOption.FullyEncoded)
def _format_completion_url(self, url):
- return url.toString(QUrl.UrlFormattingOption.RemovePassword)
+ return url.toString(core.QUrl.UrlFormattingOption.RemovePassword)
@cmdutils.register()
@@ -479,7 +477,7 @@ def debug_dump_history(dest):
raise cmdutils.CommandError(f'Could not write history: {e}')
-def init(db_path: pathlib.Path, parent: Optional[QObject] = None) -> None:
+def init(db_path: pathlib.Path, parent: Optional[core.QObject] = None) -> None:
"""Initialize the web history.
Args: