Also save the QUrl in a HistoryEntry.
We also use QUrl::toDisplayString for the completion so things like spaces or umlauts are decoded properly.
This commit is contained in:
parent
46c31911a6
commit
553d8cf986
@ -22,7 +22,7 @@
|
||||
import time
|
||||
import collections
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtCore import pyqtSignal, QUrl
|
||||
from PyQt5.QtWebKit import QWebHistoryInterface
|
||||
|
||||
from qutebrowser.utils import utils, objreg, standarddir
|
||||
@ -36,19 +36,21 @@ class HistoryEntry:
|
||||
|
||||
Attributes:
|
||||
atime: The time the page was accessed.
|
||||
url: The URL which was accessed as string
|
||||
url: The URL which was accessed as QUrl.
|
||||
url_string: The URL which was accessed as string.
|
||||
"""
|
||||
|
||||
def __init__(self, atime, url):
|
||||
self.atime = float(atime)
|
||||
self.url = url
|
||||
self.url = QUrl(url)
|
||||
self.url_string = url
|
||||
|
||||
def __repr__(self):
|
||||
return utils.get_repr(self, constructor=True, atime=self.atime,
|
||||
url=self.url)
|
||||
url=self.url.toDisplayString())
|
||||
|
||||
def __str__(self):
|
||||
return '{} {}'.format(int(self.atime), self.url)
|
||||
return '{} {}'.format(int(self.atime), self.url_string)
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, s):
|
||||
|
@ -52,7 +52,7 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
||||
history = utils.newest_slice(self._history, max_history)
|
||||
|
||||
for entry in history:
|
||||
self.new_item(self._history_cat, entry.url, "",
|
||||
self.new_item(self._history_cat, entry.url.toDisplayString(), "",
|
||||
self._fmt_atime(entry.atime), sort=int(entry.atime))
|
||||
|
||||
self._history.item_about_to_be_added.connect(
|
||||
@ -79,7 +79,7 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
||||
def on_history_item_added(self, item):
|
||||
"""Slot called when a new history item was added."""
|
||||
if item.url:
|
||||
if self._history.historyContains(item.url):
|
||||
if self._history.historyContains(item.url_string):
|
||||
for i in range(self._history_cat.rowCount()):
|
||||
name_item = self._history_cat.child(i, 0)
|
||||
atime_item = self._history_cat.child(i, 2)
|
||||
@ -90,6 +90,6 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
||||
name_item.setData(int(item.atime), base.Role.sort)
|
||||
break
|
||||
else:
|
||||
self.new_item(self._history_cat, item.url, "",
|
||||
self._fmt_atime(item.atime),
|
||||
self.new_item(self._history_cat, item.url.toDisplayString(),
|
||||
"", self._fmt_atime(item.atime),
|
||||
sort=int(item.atime))
|
||||
|
Loading…
Reference in New Issue
Block a user