Use CompletionFilterModel's sort implementation.
This commit is contained in:
parent
834832e3ba
commit
fe4f32606d
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
"""Completer attached to a CompletionView."""
|
"""Completer attached to a CompletionView."""
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSlot, QObject, QTimer
|
from PyQt5.QtCore import pyqtSlot, QObject, QTimer, Qt
|
||||||
|
|
||||||
from qutebrowser.config import config, configdata
|
from qutebrowser.config import config, configdata
|
||||||
from qutebrowser.commands import cmdutils, runners
|
from qutebrowser.commands import cmdutils, runners
|
||||||
@ -86,7 +86,8 @@ class Completer(QObject):
|
|||||||
self._models[usertypes.Completion.helptopic] = CFM(
|
self._models[usertypes.Completion.helptopic] = CFM(
|
||||||
models.HelpCompletionModel(self), self)
|
models.HelpCompletionModel(self), self)
|
||||||
self._models[usertypes.Completion.url_history_and_quickmarks] = CFM(
|
self._models[usertypes.Completion.url_history_and_quickmarks] = CFM(
|
||||||
models.UrlCompletionModel('url', self), self)
|
models.UrlCompletionModel('url', self), self,
|
||||||
|
dumb_sort=Qt.DescendingOrder)
|
||||||
|
|
||||||
def _init_setting_completions(self):
|
def _init_setting_completions(self):
|
||||||
"""Initialize setting completion models."""
|
"""Initialize setting completion models."""
|
||||||
|
@ -234,12 +234,6 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
|||||||
WebHistoryCompletionModel.history_changed(
|
WebHistoryCompletionModel.history_changed(
|
||||||
self, e, self._histcat))
|
self, e, self._histcat))
|
||||||
|
|
||||||
def sort(self, column, order=Qt.AscendingOrder):
|
|
||||||
# sort on atime, descending
|
|
||||||
# Ignoring the arguments because they are hardcoded in the CFM
|
|
||||||
# anyway.
|
|
||||||
self._histcat.sortChildren(2, Qt.DescendingOrder)
|
|
||||||
|
|
||||||
|
|
||||||
class WebHistoryCompletionModel(base.BaseCompletionModel):
|
class WebHistoryCompletionModel(base.BaseCompletionModel):
|
||||||
|
|
||||||
@ -266,11 +260,14 @@ class WebHistoryCompletionModel(base.BaseCompletionModel):
|
|||||||
cat = model.new_category("History")
|
cat = model.new_category("History")
|
||||||
|
|
||||||
for entry in histstore:
|
for entry in histstore:
|
||||||
model.new_item(cat, entry.url, "", entry.atime)
|
atime = int(entry.atime)
|
||||||
|
model.new_item(cat, entry.url, "", str(atime), sort=atime)
|
||||||
|
|
||||||
def history_changed(self, entry, cat):
|
def history_changed(self, entry, cat):
|
||||||
if entry.url:
|
if entry.url:
|
||||||
self.new_item(cat, entry.url, "", str(entry.atime))
|
atime = int(entry.atime)
|
||||||
|
self.new_item(cat, entry.url, "", str(atime), sort=atime)
|
||||||
|
|
||||||
|
|
||||||
class QuickmarkCompletionModel(base.BaseCompletionModel):
|
class QuickmarkCompletionModel(base.BaseCompletionModel):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user