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.
|
_old_miss: How many times an URL was not found in _old_urls.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
changed = pyqtSignal()
|
item_added = pyqtSignal(HistoryEntry)
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@ -89,7 +89,7 @@ class WebHistory(QWebHistoryInterface):
|
|||||||
self._old_hit = 0
|
self._old_hit = 0
|
||||||
self._old_miss = 0
|
self._old_miss = 0
|
||||||
objreg.get('save-manager').add_saveable(
|
objreg.get('save-manager').add_saveable(
|
||||||
'history', self.save, self.changed)
|
'history', self.save, self.item_added)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return utils.get_repr(self, new_length=len(self._new_history))
|
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'):
|
if not config.get('general', 'private-browsing'):
|
||||||
entry = HistoryEntry(time.time(), url_string)
|
entry = HistoryEntry(time.time(), url_string)
|
||||||
self._new_history.append(entry)
|
self._new_history.append(entry)
|
||||||
self.changed.emit()
|
self.item_added.emit(entry)
|
||||||
|
|
||||||
def historyContains(self, url_string):
|
def historyContains(self, url_string):
|
||||||
"""Called by WebKit to determine if an URL is contained in the history.
|
"""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)
|
WebHistoryCompletionModel.fill_model(self, cat=self._histcat)
|
||||||
QuickmarkCompletionModel.fill_model(self, cat=self._quickcat)
|
QuickmarkCompletionModel.fill_model(self, cat=self._quickcat)
|
||||||
|
|
||||||
self._histstore.changed.connect(lambda :
|
self._histstore.item_added.connect(lambda e:
|
||||||
WebHistoryCompletionModel.history_changed(
|
WebHistoryCompletionModel.history_changed(
|
||||||
self, self._histcat, self._histstore))
|
self, e, self._histcat))
|
||||||
|
|
||||||
def sort(self, column, order=Qt.AscendingOrder):
|
def sort(self, column, order=Qt.AscendingOrder):
|
||||||
# sort on atime, descending
|
# sort on atime, descending
|
||||||
@ -255,9 +255,8 @@ class WebHistoryCompletionModel(base.BaseCompletionModel):
|
|||||||
|
|
||||||
self.fill_model(self, self._histcat, self._histstore)
|
self.fill_model(self, self._histcat, self._histstore)
|
||||||
|
|
||||||
self._histstore.changed.connect(lambda :
|
self._histstore.item_added.connect(lambda e:
|
||||||
self.history_changed(self._histcat,
|
self.history_changed(e, self._histcat))
|
||||||
self._histstore))
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fill_model(model, cat=None, histstore=None):
|
def fill_model(model, cat=None, histstore=None):
|
||||||
@ -269,14 +268,9 @@ class WebHistoryCompletionModel(base.BaseCompletionModel):
|
|||||||
for entry in histstore:
|
for entry in histstore:
|
||||||
model.new_item(cat, entry.url, "", entry.atime)
|
model.new_item(cat, entry.url, "", entry.atime)
|
||||||
|
|
||||||
def history_changed(self, cat, histstore=None):
|
def history_changed(self, entry, cat):
|
||||||
if not histstore:
|
if entry.url:
|
||||||
histstore = objreg.get('web-history')
|
self.new_item(cat, entry.url, "", str(entry.atime))
|
||||||
# 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))
|
|
||||||
|
|
||||||
class QuickmarkCompletionModel(base.BaseCompletionModel):
|
class QuickmarkCompletionModel(base.BaseCompletionModel):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user