Reapply "Hide quickmark/bookmark completion if empty."
This reverts commit e72e8b8556
.
Now that the SQL category works in isolation, it is possible to hide
quickmarks/bookmarks when those categories are empty.
Fixes #960
This commit is contained in:
parent
40e4e73e36
commit
b6dcd4d387
@ -56,14 +56,17 @@ def url(*, info):
|
|||||||
"""
|
"""
|
||||||
model = completionmodel.CompletionModel(column_widths=(40, 50, 10))
|
model = completionmodel.CompletionModel(column_widths=(40, 50, 10))
|
||||||
|
|
||||||
quickmarks = ((url, name) for (name, url)
|
quickmarks = [(url, name) for (name, url)
|
||||||
in objreg.get('quickmark-manager').marks.items())
|
in objreg.get('quickmark-manager').marks.items()]
|
||||||
bookmarks = objreg.get('bookmark-manager').marks.items()
|
bookmarks = objreg.get('bookmark-manager').marks.items()
|
||||||
|
|
||||||
model.add_category(listcategory.ListCategory(
|
if quickmarks:
|
||||||
'Quickmarks', quickmarks, delete_func=_delete_quickmark, sort=False))
|
model.add_category(listcategory.ListCategory(
|
||||||
model.add_category(listcategory.ListCategory(
|
'Quickmarks', quickmarks, delete_func=_delete_quickmark,
|
||||||
'Bookmarks', bookmarks, delete_func=_delete_bookmark, sort=False))
|
sort=False))
|
||||||
|
if bookmarks:
|
||||||
|
model.add_category(listcategory.ListCategory(
|
||||||
|
'Bookmarks', bookmarks, delete_func=_delete_bookmark, sort=False))
|
||||||
|
|
||||||
if info.config.get('completion.web_history_max_items') != 0:
|
if info.config.get('completion.web_history_max_items') != 0:
|
||||||
hist_cat = histcategory.HistoryCategory(delete_func=_delete_history)
|
hist_cat = histcategory.HistoryCategory(delete_func=_delete_history)
|
||||||
|
@ -356,6 +356,50 @@ def test_url_completion(qtmodeltester, web_history_populated,
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def test_url_completion_no_quickmarks(qtmodeltester, web_history_populated,
|
||||||
|
quickmark_manager_stub, bookmarks, info):
|
||||||
|
"""Test that the quickmark category is gone with no quickmarks."""
|
||||||
|
model = urlmodel.url(info=info)
|
||||||
|
model.set_pattern('')
|
||||||
|
qtmodeltester.data_display_may_return_none = True
|
||||||
|
qtmodeltester.check(model)
|
||||||
|
|
||||||
|
_check_completions(model, {
|
||||||
|
"Bookmarks": [
|
||||||
|
('https://github.com', 'GitHub', None),
|
||||||
|
('https://python.org', 'Welcome to Python.org', None),
|
||||||
|
('http://qutebrowser.org', 'qutebrowser | qutebrowser', None),
|
||||||
|
],
|
||||||
|
"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'),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def test_url_completion_no_bookmarks(qtmodeltester, web_history_populated,
|
||||||
|
quickmarks, bookmark_manager_stub, info):
|
||||||
|
"""Test that the bookmarks category is gone with no bookmarks."""
|
||||||
|
model = urlmodel.url(info=info)
|
||||||
|
model.set_pattern('')
|
||||||
|
qtmodeltester.data_display_may_return_none = True
|
||||||
|
qtmodeltester.check(model)
|
||||||
|
|
||||||
|
_check_completions(model, {
|
||||||
|
"Quickmarks": [
|
||||||
|
('https://wiki.archlinux.org', 'aw', None),
|
||||||
|
('https://wikipedia.org', 'wiki', None),
|
||||||
|
('https://duckduckgo.com', 'ddg', None),
|
||||||
|
],
|
||||||
|
"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'),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('url, title, pattern, rowcount', [
|
@pytest.mark.parametrize('url, title, pattern, rowcount', [
|
||||||
('example.com', 'Site Title', '', 1),
|
('example.com', 'Site Title', '', 1),
|
||||||
('example.com', 'Site Title', 'ex', 1),
|
('example.com', 'Site Title', 'ex', 1),
|
||||||
@ -382,7 +426,7 @@ def test_url_completion_pattern(web_history, quickmark_manager_stub,
|
|||||||
model = urlmodel.url(info=info)
|
model = urlmodel.url(info=info)
|
||||||
model.set_pattern(pattern)
|
model.set_pattern(pattern)
|
||||||
# 2, 0 is History
|
# 2, 0 is History
|
||||||
assert model.rowCount(model.index(2, 0)) == rowcount
|
assert model.rowCount(model.index(0, 0)) == rowcount
|
||||||
|
|
||||||
|
|
||||||
def test_url_completion_delete_bookmark(qtmodeltester, bookmarks,
|
def test_url_completion_delete_bookmark(qtmodeltester, bookmarks,
|
||||||
|
Loading…
Reference in New Issue
Block a user