Sort history completion entries by atime.
This commit is contained in:
parent
56f3b3a027
commit
c4c5723a61
@ -49,9 +49,8 @@ class _SqlCompletionCategory(QSqlQueryModel):
|
||||
querystr += ' and ' + where
|
||||
|
||||
if sort_by:
|
||||
assert sort_order is not None
|
||||
sortstr = 'asc' if sort_order == Qt.AscendingOrder else 'desc'
|
||||
querystr += ' order by {} {}'.format(sort_by, sortstr)
|
||||
assert sort_order == 'asc' or sort_order == 'desc'
|
||||
querystr += ' order by {} {}'.format(sort_by, sort_order)
|
||||
|
||||
if limit:
|
||||
querystr += ' limit {}'.format(limit)
|
||||
@ -115,7 +114,7 @@ class SqlCompletionModel(QAbstractItemModel):
|
||||
select: A custom result column expression for the select statement.
|
||||
where: An optional clause to filter out some rows.
|
||||
sort_by: The name of the field to sort by, or None for no sorting.
|
||||
sort_order: Sorting order, if sort_by is non-None.
|
||||
sort_order: Either 'asc' or 'desc', if sort_by is non-None
|
||||
limit: Maximum row count to return on a query.
|
||||
|
||||
Return: A new CompletionCategory.
|
||||
|
@ -70,7 +70,7 @@ def url():
|
||||
model.new_category('Quickmarks', select='url, name')
|
||||
model.new_category('Bookmarks')
|
||||
model.new_category('History',
|
||||
limit=limit,
|
||||
limit=limit, sort_order='desc', sort_by='atime',
|
||||
select='url, title, {}'.format(select_time),
|
||||
where='not redirect')
|
||||
return model
|
||||
|
@ -73,31 +73,31 @@ def test_count(rowcounts, expected):
|
||||
|
||||
|
||||
@pytest.mark.parametrize('sort_by, sort_order, data, expected', [
|
||||
(None, Qt.AscendingOrder,
|
||||
(None, 'asc',
|
||||
[('B', 'C', 'D'), ('A', 'F', 'C'), ('C', 'A', 'G')],
|
||||
[('B', 'C', 'D'), ('A', 'F', 'C'), ('C', 'A', 'G')]),
|
||||
|
||||
('a', Qt.AscendingOrder,
|
||||
('a', 'asc',
|
||||
[('B', 'C', 'D'), ('A', 'F', 'C'), ('C', 'A', 'G')],
|
||||
[('A', 'F', 'C'), ('B', 'C', 'D'), ('C', 'A', 'G')]),
|
||||
|
||||
('a', Qt.DescendingOrder,
|
||||
('a', 'desc',
|
||||
[('B', 'C', 'D'), ('A', 'F', 'C'), ('C', 'A', 'G')],
|
||||
[('C', 'A', 'G'), ('B', 'C', 'D'), ('A', 'F', 'C')]),
|
||||
|
||||
('b', Qt.AscendingOrder,
|
||||
('b', 'asc',
|
||||
[('B', 'C', 'D'), ('A', 'F', 'C'), ('C', 'A', 'G')],
|
||||
[('C', 'A', 'G'), ('B', 'C', 'D'), ('A', 'F', 'C')]),
|
||||
|
||||
('b', Qt.DescendingOrder,
|
||||
('b', 'desc',
|
||||
[('B', 'C', 'D'), ('A', 'F', 'C'), ('C', 'A', 'G')],
|
||||
[('A', 'F', 'C'), ('B', 'C', 'D'), ('C', 'A', 'G')]),
|
||||
|
||||
('c', Qt.AscendingOrder,
|
||||
('c', 'asc',
|
||||
[('B', 'C', 2), ('A', 'F', 0), ('C', 'A', 1)],
|
||||
[('A', 'F', 0), ('C', 'A', 1), ('B', 'C', 2)]),
|
||||
|
||||
('c', Qt.DescendingOrder,
|
||||
('c', 'desc',
|
||||
[('B', 'C', 2), ('A', 'F', 0), ('C', 'A', 1)],
|
||||
[('B', 'C', 2), ('C', 'A', 1), ('A', 'F', 0)]),
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user