Remove web-history-max-items.
This was a performance optimization that shouldn't be needed with the new SQL history backend. This also removes support for the LIMIT feature from SqlTable as it only existed to support web-history-max-items.
This commit is contained in:
parent
99c9b2d396
commit
921211bbaa
@ -31,7 +31,7 @@ from qutebrowser.misc import sql
|
|||||||
class _SqlCompletionCategory(QSqlQueryModel):
|
class _SqlCompletionCategory(QSqlQueryModel):
|
||||||
"""Wraps a SqlQuery for use as a completion category."""
|
"""Wraps a SqlQuery for use as a completion category."""
|
||||||
|
|
||||||
def __init__(self, name, *, sort_by, sort_order, limit, select, where,
|
def __init__(self, name, *, sort_by, sort_order, select, where,
|
||||||
columns_to_filter, parent=None):
|
columns_to_filter, parent=None):
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
self.tablename = name
|
self.tablename = name
|
||||||
@ -52,9 +52,6 @@ class _SqlCompletionCategory(QSqlQueryModel):
|
|||||||
assert sort_order == 'asc' or sort_order == 'desc'
|
assert sort_order == 'asc' or sort_order == 'desc'
|
||||||
querystr += ' order by {} {}'.format(sort_by, sort_order)
|
querystr += ' order by {} {}'.format(sort_by, sort_order)
|
||||||
|
|
||||||
if limit:
|
|
||||||
querystr += ' limit {}'.format(limit)
|
|
||||||
|
|
||||||
self._querystr = querystr
|
self._querystr = querystr
|
||||||
self.set_pattern('%')
|
self.set_pattern('%')
|
||||||
|
|
||||||
@ -106,7 +103,7 @@ class SqlCompletionModel(QAbstractItemModel):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def new_category(self, name, *, select='*', where=None, sort_by=None,
|
def new_category(self, name, *, select='*', where=None, sort_by=None,
|
||||||
sort_order=None, limit=None):
|
sort_order=None):
|
||||||
"""Create a new completion category and add it to this model.
|
"""Create a new completion category and add it to this model.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -115,12 +112,11 @@ class SqlCompletionModel(QAbstractItemModel):
|
|||||||
where: An optional clause to filter out some rows.
|
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_by: The name of the field to sort by, or None for no sorting.
|
||||||
sort_order: Either 'asc' or 'desc', 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.
|
Return: A new CompletionCategory.
|
||||||
"""
|
"""
|
||||||
cat = _SqlCompletionCategory(name, parent=self, sort_by=sort_by,
|
cat = _SqlCompletionCategory(name, parent=self, sort_by=sort_by,
|
||||||
sort_order=sort_order, limit=limit,
|
sort_order=sort_order,
|
||||||
select=select, where=where,
|
select=select, where=where,
|
||||||
columns_to_filter=self.columns_to_filter)
|
columns_to_filter=self.columns_to_filter)
|
||||||
self._categories.append(cat)
|
self._categories.append(cat)
|
||||||
|
@ -64,13 +64,12 @@ def url():
|
|||||||
model = sqlmodel.SqlCompletionModel(column_widths=(40, 50, 10),
|
model = sqlmodel.SqlCompletionModel(column_widths=(40, 50, 10),
|
||||||
columns_to_filter=[_URLCOL, _TEXTCOL],
|
columns_to_filter=[_URLCOL, _TEXTCOL],
|
||||||
delete_cur_item=_delete_url)
|
delete_cur_item=_delete_url)
|
||||||
limit = config.get('completion', 'web-history-max-items')
|
|
||||||
timefmt = config.get('completion', 'timestamp-format')
|
timefmt = config.get('completion', 'timestamp-format')
|
||||||
select_time = "strftime('{}', atime, 'unixepoch')".format(timefmt)
|
select_time = "strftime('{}', atime, 'unixepoch')".format(timefmt)
|
||||||
model.new_category('Quickmarks', select='url, name')
|
model.new_category('Quickmarks', select='url, name')
|
||||||
model.new_category('Bookmarks')
|
model.new_category('Bookmarks')
|
||||||
model.new_category('History',
|
model.new_category('History',
|
||||||
limit=limit, sort_order='desc', sort_by='atime',
|
sort_order='desc', sort_by='atime',
|
||||||
select='url, title, {}'.format(select_time),
|
select='url, title, {}'.format(select_time),
|
||||||
where='not redirect')
|
where='not redirect')
|
||||||
return model
|
return model
|
||||||
|
@ -414,6 +414,7 @@ class ConfigManager(QObject):
|
|||||||
('storage', 'offline-storage-default-quota'),
|
('storage', 'offline-storage-default-quota'),
|
||||||
('storage', 'offline-web-application-cache-quota'),
|
('storage', 'offline-web-application-cache-quota'),
|
||||||
('content', 'css-regions'),
|
('content', 'css-regions'),
|
||||||
|
('completion', 'web-history-max-items'),
|
||||||
]
|
]
|
||||||
CHANGED_OPTIONS = {
|
CHANGED_OPTIONS = {
|
||||||
('content', 'cookies-accept'):
|
('content', 'cookies-accept'):
|
||||||
|
@ -506,11 +506,6 @@ def data(readonly=False):
|
|||||||
"How many commands to save in the command history.\n\n"
|
"How many commands to save in the command history.\n\n"
|
||||||
"0: no history / -1: unlimited"),
|
"0: no history / -1: unlimited"),
|
||||||
|
|
||||||
('web-history-max-items',
|
|
||||||
SettingValue(typ.Int(minval=-1), '1000'),
|
|
||||||
"How many URLs to show in the web history.\n\n"
|
|
||||||
"0: no history / -1: unlimited"),
|
|
||||||
|
|
||||||
('quick-complete',
|
('quick-complete',
|
||||||
SettingValue(typ.Bool(), 'true'),
|
SettingValue(typ.Bool(), 'true'),
|
||||||
"Whether to move on to the next part when there's only one "
|
"Whether to move on to the next part when there's only one "
|
||||||
|
@ -274,13 +274,10 @@ def test_url_completion(qtmodeltester, config_stub, web_history, quickmarks,
|
|||||||
|
|
||||||
Verify that:
|
Verify that:
|
||||||
- quickmarks, bookmarks, and urls are included
|
- quickmarks, bookmarks, and urls are included
|
||||||
- no more than 'web-history-max-items' items are included (TODO)
|
- entries are sorted by access time
|
||||||
- the most recent entries are included
|
|
||||||
- redirect entries are not included
|
- redirect entries are not included
|
||||||
"""
|
"""
|
||||||
# TODO: time formatting and item limiting
|
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d'}
|
||||||
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d',
|
|
||||||
'web-history-max-items': 2}
|
|
||||||
model = urlmodel.url()
|
model = urlmodel.url()
|
||||||
qtmodeltester.data_display_may_return_none = True
|
qtmodeltester.data_display_may_return_none = True
|
||||||
qtmodeltester.check(model)
|
qtmodeltester.check(model)
|
||||||
@ -299,6 +296,7 @@ def test_url_completion(qtmodeltester, config_stub, web_history, quickmarks,
|
|||||||
"History": [
|
"History": [
|
||||||
('https://github.com', 'https://github.com', '2016-05-01'),
|
('https://github.com', 'https://github.com', '2016-05-01'),
|
||||||
('https://python.org', 'Welcome to Python.org', '2016-03-08'),
|
('https://python.org', 'Welcome to Python.org', '2016-03-08'),
|
||||||
|
('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -307,8 +305,7 @@ def test_url_completion_delete_bookmark(qtmodeltester, config_stub,
|
|||||||
web_history, quickmarks, bookmarks,
|
web_history, quickmarks, bookmarks,
|
||||||
qtbot):
|
qtbot):
|
||||||
"""Test deleting a bookmark from the url completion model."""
|
"""Test deleting a bookmark from the url completion model."""
|
||||||
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d',
|
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d'}
|
||||||
'web-history-max-items': 2}
|
|
||||||
model = urlmodel.url()
|
model = urlmodel.url()
|
||||||
qtmodeltester.data_display_may_return_none = True
|
qtmodeltester.data_display_may_return_none = True
|
||||||
qtmodeltester.check(model)
|
qtmodeltester.check(model)
|
||||||
@ -325,8 +322,7 @@ def test_url_completion_delete_quickmark(qtmodeltester, config_stub,
|
|||||||
web_history, quickmarks, bookmarks,
|
web_history, quickmarks, bookmarks,
|
||||||
qtbot):
|
qtbot):
|
||||||
"""Test deleting a bookmark from the url completion model."""
|
"""Test deleting a bookmark from the url completion model."""
|
||||||
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d',
|
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d'}
|
||||||
'web-history-max-items': 2}
|
|
||||||
model = urlmodel.url()
|
model = urlmodel.url()
|
||||||
qtmodeltester.data_display_may_return_none = True
|
qtmodeltester.data_display_may_return_none = True
|
||||||
qtmodeltester.check(model)
|
qtmodeltester.check(model)
|
||||||
|
@ -206,15 +206,6 @@ def test_first_last_item(data, first, last):
|
|||||||
assert model.data(model.last_item()) == last
|
assert model.data(model.last_item()) == last
|
||||||
|
|
||||||
|
|
||||||
def test_limit():
|
|
||||||
table = sql.SqlTable('test_limit', ['a'], primary_key='a')
|
|
||||||
for i in range(5):
|
|
||||||
table.insert([i])
|
|
||||||
model = sqlmodel.SqlCompletionModel()
|
|
||||||
model.new_category('test_limit', limit=3)
|
|
||||||
assert model.count() == 3
|
|
||||||
|
|
||||||
|
|
||||||
def test_select():
|
def test_select():
|
||||||
table = sql.SqlTable('test_select', ['a', 'b', 'c'], primary_key='a')
|
table = sql.SqlTable('test_select', ['a', 'b', 'c'], primary_key='a')
|
||||||
table.insert(['foo', 'bar', 'baz'])
|
table.insert(['foo', 'bar', 'baz'])
|
||||||
|
Loading…
Reference in New Issue
Block a user