Merge branch 'antoyo-bug/web-history-max-items'
This commit is contained in:
commit
8a01dc9194
@ -69,8 +69,8 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
|||||||
bookmark_manager.removed.connect(self.on_bookmark_removed)
|
bookmark_manager.removed.connect(self.on_bookmark_removed)
|
||||||
|
|
||||||
self._history = objreg.get('web-history')
|
self._history = objreg.get('web-history')
|
||||||
max_history = config.get('completion', 'web-history-max-items')
|
self._max_history = config.get('completion', 'web-history-max-items')
|
||||||
history = utils.newest_slice(self._history, max_history)
|
history = utils.newest_slice(self._history, self._max_history)
|
||||||
for entry in history:
|
for entry in history:
|
||||||
self._add_history_entry(entry)
|
self._add_history_entry(entry)
|
||||||
self._history.add_completion_item.connect(
|
self._history.add_completion_item.connect(
|
||||||
@ -92,12 +92,19 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
|||||||
else:
|
else:
|
||||||
return dt.strftime(fmt)
|
return dt.strftime(fmt)
|
||||||
|
|
||||||
|
def _remove_oldest_history(self):
|
||||||
|
"""Remove the oldest history entry."""
|
||||||
|
self._history_cat.removeRow(0)
|
||||||
|
|
||||||
def _add_history_entry(self, entry):
|
def _add_history_entry(self, entry):
|
||||||
"""Add a new history entry to the completion."""
|
"""Add a new history entry to the completion."""
|
||||||
self.new_item(self._history_cat, entry.url.toDisplayString(), "",
|
self.new_item(self._history_cat, entry.url.toDisplayString(), "",
|
||||||
self._fmt_atime(entry.atime), sort=int(entry.atime),
|
self._fmt_atime(entry.atime), sort=int(entry.atime),
|
||||||
userdata=entry.url)
|
userdata=entry.url)
|
||||||
|
|
||||||
|
if self._history_cat.rowCount() > self._max_history:
|
||||||
|
self._remove_oldest_history()
|
||||||
|
|
||||||
@config.change_filter('completion', 'timestamp-format')
|
@config.change_filter('completion', 'timestamp-format')
|
||||||
def reformat_timestamps(self):
|
def reformat_timestamps(self):
|
||||||
"""Reformat the timestamps if the config option was changed."""
|
"""Reformat the timestamps if the config option was changed."""
|
||||||
|
Loading…
Reference in New Issue
Block a user