diff --git a/qutebrowser/completion/models/sqlmodel.py b/qutebrowser/completion/models/sqlmodel.py index 99c47cf28..e3e5a5c5f 100644 --- a/qutebrowser/completion/models/sqlmodel.py +++ b/qutebrowser/completion/models/sqlmodel.py @@ -31,7 +31,7 @@ from qutebrowser.misc import sql class _SqlCompletionCategory(QSqlQueryModel): """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): super().__init__(parent=parent) self.tablename = name @@ -52,9 +52,6 @@ class _SqlCompletionCategory(QSqlQueryModel): assert sort_order == 'asc' or sort_order == 'desc' querystr += ' order by {} {}'.format(sort_by, sort_order) - if limit: - querystr += ' limit {}'.format(limit) - self._querystr = querystr self.set_pattern('%') @@ -106,7 +103,7 @@ class SqlCompletionModel(QAbstractItemModel): return 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. Args: @@ -115,12 +112,11 @@ class SqlCompletionModel(QAbstractItemModel): 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: Either 'asc' or 'desc', if sort_by is non-None - limit: Maximum row count to return on a query. Return: A new CompletionCategory. """ cat = _SqlCompletionCategory(name, parent=self, sort_by=sort_by, - sort_order=sort_order, limit=limit, + sort_order=sort_order, select=select, where=where, columns_to_filter=self.columns_to_filter) self._categories.append(cat) diff --git a/qutebrowser/completion/models/urlmodel.py b/qutebrowser/completion/models/urlmodel.py index 6a10d9c44..0b357c3d7 100644 --- a/qutebrowser/completion/models/urlmodel.py +++ b/qutebrowser/completion/models/urlmodel.py @@ -64,13 +64,12 @@ def url(): model = sqlmodel.SqlCompletionModel(column_widths=(40, 50, 10), columns_to_filter=[_URLCOL, _TEXTCOL], delete_cur_item=_delete_url) - limit = config.get('completion', 'web-history-max-items') timefmt = config.get('completion', 'timestamp-format') select_time = "strftime('{}', atime, 'unixepoch')".format(timefmt) model.new_category('Quickmarks', select='url, name') model.new_category('Bookmarks') model.new_category('History', - limit=limit, sort_order='desc', sort_by='atime', + sort_order='desc', sort_by='atime', select='url, title, {}'.format(select_time), where='not redirect') return model diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 0b1893fc0..e7e74cc19 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -414,6 +414,7 @@ class ConfigManager(QObject): ('storage', 'offline-storage-default-quota'), ('storage', 'offline-web-application-cache-quota'), ('content', 'css-regions'), + ('completion', 'web-history-max-items'), ] CHANGED_OPTIONS = { ('content', 'cookies-accept'): diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 28cf41ac5..fd3235c8b 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -506,11 +506,6 @@ def data(readonly=False): "How many commands to save in the command history.\n\n" "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', SettingValue(typ.Bool(), 'true'), "Whether to move on to the next part when there's only one " diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py index b866e6439..224d7ed59 100644 --- a/tests/unit/completion/test_models.py +++ b/tests/unit/completion/test_models.py @@ -274,13 +274,10 @@ def test_url_completion(qtmodeltester, config_stub, web_history, quickmarks, Verify that: - quickmarks, bookmarks, and urls are included - - no more than 'web-history-max-items' items are included (TODO) - - the most recent entries are included + - entries are sorted by access time - redirect entries are not included """ - # TODO: time formatting and item limiting - config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d', - 'web-history-max-items': 2} + config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d'} model = urlmodel.url() qtmodeltester.data_display_may_return_none = True qtmodeltester.check(model) @@ -299,6 +296,7 @@ def test_url_completion(qtmodeltester, config_stub, web_history, quickmarks, "History": [ ('https://github.com', 'https://github.com', '2016-05-01'), ('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, qtbot): """Test deleting a bookmark from the url completion model.""" - config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d', - 'web-history-max-items': 2} + config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d'} model = urlmodel.url() qtmodeltester.data_display_may_return_none = True qtmodeltester.check(model) @@ -325,8 +322,7 @@ def test_url_completion_delete_quickmark(qtmodeltester, config_stub, web_history, quickmarks, bookmarks, qtbot): """Test deleting a bookmark from the url completion model.""" - config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d', - 'web-history-max-items': 2} + config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d'} model = urlmodel.url() qtmodeltester.data_display_may_return_none = True qtmodeltester.check(model) diff --git a/tests/unit/completion/test_sqlmodel.py b/tests/unit/completion/test_sqlmodel.py index 49dc96ccf..8b9727dfd 100644 --- a/tests/unit/completion/test_sqlmodel.py +++ b/tests/unit/completion/test_sqlmodel.py @@ -206,15 +206,6 @@ def test_first_last_item(data, first, 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(): table = sql.SqlTable('test_select', ['a', 'b', 'c'], primary_key='a') table.insert(['foo', 'bar', 'baz'])