Fix adding of URLs to history completion.

Before, the item_added signal was emitted *after* an item was added, which
means the on_history_item_added slot always assumed the item already is in the
history.
This commit is contained in:
Florian Bruhin 2015-03-15 21:16:45 +01:00
parent 9512a52d21
commit d266665955
2 changed files with 10 additions and 1 deletions

View File

@ -65,8 +65,15 @@ class WebHistory(QWebHistoryInterface):
_history_dict: An OrderedDict of URLs read from the on-disk history.
_new_history: A list of HistoryEntry items of the current session.
_saved_count: How many HistoryEntries have been written to disk.
Signals:
item_about_to_be_added: Emitted before a new HistoryEntry is added.
arg: The new HistoryEntry.
item_added: Emitted after a new HistoryEntry is added.
arg: The new HistoryEntry.
"""
item_about_to_be_added = pyqtSignal(HistoryEntry)
item_added = pyqtSignal(HistoryEntry)
def __init__(self, parent=None):
@ -120,6 +127,7 @@ class WebHistory(QWebHistoryInterface):
"""
if not config.get('general', 'private-browsing'):
entry = HistoryEntry(time.time(), url_string)
self.item_about_to_be_added.emit(entry)
self._new_history.append(entry)
self._history_dict[url_string] = entry
self._history_dict.move_to_end(url_string)

View File

@ -55,7 +55,8 @@ class UrlCompletionModel(base.BaseCompletionModel):
self.new_item(self._history_cat, entry.url, "",
self._fmt_atime(entry.atime), sort=int(entry.atime))
self._history.item_added.connect(self.on_history_item_added)
self._history.item_about_to_be_added.connect(
self.on_history_item_added)
objreg.get('config').changed.connect(self.reformat_timestamps)
def _fmt_atime(self, atime):