Cleanup
This commit is contained in:
parent
553d8cf986
commit
693ea0c312
@ -52,8 +52,7 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
|||||||
history = utils.newest_slice(self._history, max_history)
|
history = utils.newest_slice(self._history, max_history)
|
||||||
|
|
||||||
for entry in history:
|
for entry in history:
|
||||||
self.new_item(self._history_cat, entry.url.toDisplayString(), "",
|
self._add_history_entry(entry)
|
||||||
self._fmt_atime(entry.atime), sort=int(entry.atime))
|
|
||||||
|
|
||||||
self._history.item_about_to_be_added.connect(
|
self._history.item_about_to_be_added.connect(
|
||||||
self.on_history_item_added)
|
self.on_history_item_added)
|
||||||
@ -66,6 +65,11 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
|||||||
return ''
|
return ''
|
||||||
return datetime.datetime.fromtimestamp(atime).strftime(fmt)
|
return datetime.datetime.fromtimestamp(atime).strftime(fmt)
|
||||||
|
|
||||||
|
def _add_history_entry(self, entry):
|
||||||
|
"""Add a new history entry to the completion."""
|
||||||
|
self.new_item(self._history_cat, entry.url.toDisplayString(), "",
|
||||||
|
self._fmt_atime(entry.atime), sort=int(entry.atime))
|
||||||
|
|
||||||
@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."""
|
||||||
@ -76,20 +80,18 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
|||||||
atime_item.setText(self._fmt_atime(atime))
|
atime_item.setText(self._fmt_atime(atime))
|
||||||
|
|
||||||
@pyqtSlot(object)
|
@pyqtSlot(object)
|
||||||
def on_history_item_added(self, item):
|
def on_history_item_added(self, entry):
|
||||||
"""Slot called when a new history item was added."""
|
"""Slot called when a new history item was added."""
|
||||||
if item.url:
|
if entry.url:
|
||||||
if self._history.historyContains(item.url_string):
|
if self._history.historyContains(entry.url_string):
|
||||||
for i in range(self._history_cat.rowCount()):
|
for i in range(self._history_cat.rowCount()):
|
||||||
name_item = self._history_cat.child(i, 0)
|
name_item = self._history_cat.child(i, 0)
|
||||||
atime_item = self._history_cat.child(i, 2)
|
atime_item = self._history_cat.child(i, 2)
|
||||||
if not name_item:
|
if not name_item:
|
||||||
continue
|
continue
|
||||||
if name_item.text() == item.url:
|
if name_item.text() == entry.url:
|
||||||
atime_item.setText(self._fmt_atime(item.atime))
|
atime_item.setText(self._fmt_atime(entry.atime))
|
||||||
name_item.setData(int(item.atime), base.Role.sort)
|
name_item.setData(int(entry.atime), base.Role.sort)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.new_item(self._history_cat, item.url.toDisplayString(),
|
self._add_history_entry(entry)
|
||||||
"", self._fmt_atime(item.atime),
|
|
||||||
sort=int(item.atime))
|
|
||||||
|
Loading…
Reference in New Issue
Block a user