Web history changed signal now emits the new entry.
Each new HistoryEntry is emitted after being added to the global history store. Current members of the HistoryEntry are `url` and `atime`. `title` should be coming soon.
This commit is contained in:
parent
59948a038c
commit
834832e3ba
@ -68,7 +68,7 @@ class WebHistory(QWebHistoryInterface):
|
||||
_old_miss: How many times an URL was not found in _old_urls.
|
||||
"""
|
||||
|
||||
changed = pyqtSignal()
|
||||
item_added = pyqtSignal(HistoryEntry)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
@ -89,7 +89,7 @@ class WebHistory(QWebHistoryInterface):
|
||||
self._old_hit = 0
|
||||
self._old_miss = 0
|
||||
objreg.get('save-manager').add_saveable(
|
||||
'history', self.save, self.changed)
|
||||
'history', self.save, self.item_added)
|
||||
|
||||
def __repr__(self):
|
||||
return utils.get_repr(self, new_length=len(self._new_history))
|
||||
@ -122,7 +122,7 @@ class WebHistory(QWebHistoryInterface):
|
||||
if not config.get('general', 'private-browsing'):
|
||||
entry = HistoryEntry(time.time(), url_string)
|
||||
self._new_history.append(entry)
|
||||
self.changed.emit()
|
||||
self.item_added.emit(entry)
|
||||
|
||||
def historyContains(self, url_string):
|
||||
"""Called by WebKit to determine if an URL is contained in the history.
|
||||
|
@ -230,9 +230,9 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
||||
WebHistoryCompletionModel.fill_model(self, cat=self._histcat)
|
||||
QuickmarkCompletionModel.fill_model(self, cat=self._quickcat)
|
||||
|
||||
self._histstore.changed.connect(lambda :
|
||||
self._histstore.item_added.connect(lambda e:
|
||||
WebHistoryCompletionModel.history_changed(
|
||||
self, self._histcat, self._histstore))
|
||||
self, e, self._histcat))
|
||||
|
||||
def sort(self, column, order=Qt.AscendingOrder):
|
||||
# sort on atime, descending
|
||||
@ -255,9 +255,8 @@ class WebHistoryCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
self.fill_model(self, self._histcat, self._histstore)
|
||||
|
||||
self._histstore.changed.connect(lambda :
|
||||
self.history_changed(self._histcat,
|
||||
self._histstore))
|
||||
self._histstore.item_added.connect(lambda e:
|
||||
self.history_changed(e, self._histcat))
|
||||
|
||||
@staticmethod
|
||||
def fill_model(model, cat=None, histstore=None):
|
||||
@ -269,14 +268,9 @@ class WebHistoryCompletionModel(base.BaseCompletionModel):
|
||||
for entry in histstore:
|
||||
model.new_item(cat, entry.url, "", entry.atime)
|
||||
|
||||
def history_changed(self, cat, histstore=None):
|
||||
if not histstore:
|
||||
histstore = objreg.get('web-history')
|
||||
# Assuming the web-history.changed signal is emitted once for each
|
||||
# new history item and that signal handlers are run immediately.
|
||||
if histstore._history[-1].url:
|
||||
self.new_item(cat, histstore._history[-1].url, "",
|
||||
str(histstore._history[-1].atime))
|
||||
def history_changed(self, entry, cat):
|
||||
if entry.url:
|
||||
self.new_item(cat, entry.url, "", str(entry.atime))
|
||||
|
||||
class QuickmarkCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user