Commit Graph

1594 Commits

Author SHA1 Message Date
Ryan Roden-Corrent
d35b47c9d8 Regenerate history completion on version change.
Incrementing _USER_VERSION in the source will cause the
HistoryCompletion table to regenerate when users update.

This is currently necessary to support some recent formatting fixes, but
could be incremented again in the future for other changes.
2017-08-21 08:45:40 -04:00
Ryan Roden-Corrent
111846a909 Merge remote-tracking branch 'upstream/master' into configmerge 2017-08-20 21:18:47 -04:00
Ryan Roden-Corrent
b5a6583559 Fix pylint/flake8/vulture errors. 2017-08-20 21:12:38 -04:00
Ryan Roden-Corrent
90c49b3fe7 Move bind completion to configmodels.
When in miscmodels, the config module was unable to find the function.
It appears to be some sort of circular import issue:

```
  File "/home/rcorre/projects/contrib/qutebrowser/qutebrowser/app.py", line 44, in <module>
    from qutebrowser.completion.models import miscmodels
  File "/home/rcorre/projects/contrib/qutebrowser/qutebrowser/completion/models/miscmodels.py", line 24, in <module>
    from qutebrowser.completion.models import completionmodel, listcategory, util
  File "/home/rcorre/projects/contrib/qutebrowser/qutebrowser/completion/models/util.py", line 24, in <module>
    from qutebrowser.config import config
  File "/home/rcorre/projects/contrib/qutebrowser/qutebrowser/config/config.py", line 223, in <module>
    class ConfigCommands:
  File "/home/rcorre/projects/contrib/qutebrowser/qutebrowser/config/config.py", line 314, in ConfigCommands
    @cmdutils.argument('command', completion=miscmodels.bind)
AttributeError: module 'qutebrowser.completion.models.miscmodels' has no attribute 'bind'
```

As configmodel imports util (and thereby config as well) it is unclear
to me why moving bind() to configmodel actually fixes this, but it does.
2017-08-20 21:12:38 -04:00
Ryan Roden-Corrent
0286e9ddf2 Fix completion tests after config merge. 2017-08-20 21:12:38 -04:00
Ryan Roden-Corrent
5f45b9b40e Fix pylint and coverage for history. 2017-08-20 20:59:48 -04:00
Ryan Roden-Corrent
8c6133e29d Regenerate history completion table if needed.
If the HistoryCompletion table is removed, regenerate it from the
History table. This allows users to manually edit History, then remove
HistoryCompletion to prompt regeneration.

See #2903.
2017-08-18 07:39:36 -04:00
Ryan Roden-Corrent
c607537319 Consistently format urls in history.
Encode urls that are inserted into the history, but do not encode urls
for completion (other than removing passwords).
Also ensure that urls read from the history text file are formatted
consistenly with those added while browsing.

Fixes #2903.
2017-08-14 21:37:43 -04:00
Ryan Roden-Corrent
5ea420b49b Fix startup crashes after config merge.
Get qutebrowser to the point where it can at least start

- Declare _messages earlier in MessageView.__init__ so it is set before
  the config trigger tries to access it.
- Remove unused configmodel completion functions
- Move bind completion to configmodel to avoid a circular import with
  the config module
- Fix some config accesses (forgot to use .val)
- Fix old Completion.CompletionKind references
2017-08-09 07:28:22 -04:00
Florian Bruhin
3a2d64ba46 version.distribution(): Handle Funtoo 2017-08-08 20:19:33 +02:00
Florian Bruhin
a20f017c7a Sort sessions in SessionMnager.list_sessions() 2017-08-08 07:56:10 +02:00
Ryan Roden-Corrent
71b71dbc58 Merge remote-tracking branch 'upstream/master' into HEAD 2017-08-06 18:13:49 -04:00
Ryan Roden-Corrent
6e025c1bb0 Don't perform alphabetical sort in listcategory.
Instead, expect the data to be given in the desired order. Completion
functions should sort their data _if_ they want it sorted in the
completion. This has a few implications:

- {book,quick}marks appear in the same order they do in the text file.
  This means users can rearrange their mark files for custom sorting.
  Fixes #2354
- Sessions are sorted as they appear in the session manager
- Tabs are sorted numerically, not alphabetically (Fixes #2883)

Note that prefix-based filter sorting is still performed, so items
starting with the filter pattern come first.
2017-08-06 10:00:18 -04:00
Florian Bruhin
49b858e359 Add more variants of fake apple URL to ignored ones 2017-08-01 16:00:53 +02:00
Florian Bruhin
695769d1b4 Merge pull request #2875 from rcorre/obsolete-signals
Remove obsolete signals.
2017-07-29 20:30:25 +02:00
Florian Bruhin
ba92ea9fb4 Merge pull request #2873 from rcorre/completion-del-marks
Support delete from :{quick,book}mark-load.
2017-07-29 19:27:25 +02:00
Ryan Roden-Corrent
8e34b54cd7 Remove obsolete signals.
The added/removed signals for the urlmark managers are no longer used as
the completion models are generated on-the-fly. The changed signal is
still needed so the save-manager knows when to trigger a write to disk.

Also removes session_manager.update_completion, which is no longer
needed for the same reason as above.

keyconf.changed cannot be removed, as it is still wired up to
basekeyparser.

Resolves #2874.
2017-07-29 13:09:10 -04:00
Ryan Roden-Corrent
1ab7bb83cc Support delete from :{quick,book}mark-load.
Pressing ctrl-d in the completion menu for
:quickmark-load/:bookmark-load  will now delete the selected
quickmark/bookmark.

Resolves #2840.
2017-07-29 12:49:20 -04:00
Ryan Roden-Corrent
c6cb6ccd07 Fix fetch/delete sql category bug.
Fixes #2868, where pressing <shift-tab> then <ctrl-d> in history
completion (with > 256 items) would cause later items to disappear (and
cause a crash if you try to delete again).

Cause:
Scrolling to the bottom would fetch an additional 256 items (in addition
to the 256 that are fetched at first). Deleting causes the query to
re-run, but it only fetches the initial 256 items, so the current index
is now invalid.

Fix:
After deleting from the history category, call fetchMore until it has
enough rows populated that the current index is valid.
2017-07-28 09:07:30 -04:00
Florian Bruhin
8f63bb1edc Merge pull request #2853 from rcorre/fix-completionview
Expand history completion results if on last index.
2017-07-27 12:31:01 +02:00
Florian Bruhin
a942613d7f Use ctypes instead of PyOpenGL for QtWebEngine Nvidia workaround
Fixes #2821
2017-07-27 09:22:12 +02:00
Ryan Roden-Corrent
32fa1ff1e9 Expand history completion results if on last index.
When tabbing to the last index of history completion, call expandAll
which will call fetchMore to retrieve more query results, if available.

Calling fetchMore directly will not update the view, and for some
reason self.expand(idx.parent()) and
self.expand(self.model().index(idx.row(), 0)) did not work, so I'm using
expandAll.

Fixes #2841.
2017-07-26 07:46:12 -04:00
Ryan Roden-Corrent
1929883485 Fix bind completion for bindings with arguments.
When a key is bound to a command line that includes one or more
arguments to a command, bind completion should show the whole command
for the "Current" category, and use only the command name to look up the
description.

Fixes #2859, where a crash was caused by looking up the description by
the full command text rather than just the name.
2017-07-25 12:55:44 -04:00
Ryan Roden-Corrent
f09423efe5 Abort resizeEvent if model is None.
Some reports came in that a resizeEvent was causing a crash due to the
model being none in the CompletionView.

Fixes #2854.
2017-07-24 08:16:14 -04:00
Florian Bruhin
df3ba278e9 Merge pull request #2852 from rcorre/fix-max-items
Fix web-history-max-items-crash.
2017-07-24 07:29:15 +02:00
Florian Bruhin
837ee5c626 Merge pull request #2846 from rcorre/completion-fixes
Completion fixes
2017-07-24 07:27:11 +02:00
Ryan Roden-Corrent
2ad4cdd729 Fix web-history-max-items-crash.
Fixes #2849, where pressing 'o' with web-history-max-items set and no
history items would cause a crash as the query result is empty.
2017-07-23 21:17:22 -04:00
Ryan Roden-Corrent
ff9efe22ae Fix unused imports and removeRow override.
Override removeRows instead of removeRow.

> removeRow is not virtual in C++, so if this gets called by Qt
> internally for some reason, it wouldn't use the overloaded version -
> so I think it'd be better to implement removeRows and then use
> removeRow without overloading that

- The-Compiler
2017-07-23 17:30:09 -04:00
Florian Bruhin
56b4989f44 Fix tests for QProcess changes 2017-07-23 22:10:50 +02:00
Ryan Roden-Corrent
b61691684e Clear selection when setting completion pattern.
It doesn't make sense to have an active selection while you are
filtering by entering text. You should be in one of two states:

1. Tabbing through completions (valid selection)
2. Entering a filter pattern (invalid selection)

Fixes #2843, where a crash would occur after the following:

1. tab to an item other than the first
2. <backspace>
3. re-type last character
4. <ctrl-d>

This would try to delete an out of range index.
2017-07-22 18:06:16 -04:00
Ryan Roden-Corrent
bc21904fef Fix completion-item-del on undeletable item.
Even though no item was deleted, it was manipulating the completion
model because beginRemoveRows was called before the exception was
raised.

This fixes that problem by moving the removal logic (and delete_func
check) into the parent model, so it can check whether deletion is
possible before calling beginRemoveRows.

Fixes #2839.
2017-07-22 17:16:35 -04:00
Florian Bruhin
118a7942a5 Add maximum bound for web-history-max-items
sqlite can't handle values bigger than uint64_t for LIMIT.
2017-07-21 18:30:12 +02:00
Florian Bruhin
544094ba72 Use simpler way of preventing History completion 2017-07-21 17:55:47 +02:00
Florian Bruhin
6660297871 Fix new completion with web-history-max-items set to 0
We get no last_atime limit at all otherwise:

qutebrowser.misc.sql.SqlException: Failed to prepare query "SELECT url, title,
strftime('%Y-%m-%d', last_atime, 'unixepoch', 'localtime') FROM
CompletionHistory WHERE (url LIKE :pat escape '\' or title LIKE :pat escape '\')
AND last_atime >= ORDER BY last_atime DESC": "near "ORDER": syntax error Unable
to execute statement"
2017-07-21 17:11:38 +02:00
Florian Bruhin
fba25338be Merge pull request #2295 from rcorre/really_complete
Completion refactor V3
2017-07-21 15:05:43 +02:00
Ryan Roden-Corrent
0eb347186c Add 'localtime' to sql history query.
We need to tell sqlite to convert the timestamps to localtime during
formatting, otherwise it formats them as though you are in UTC.

Also fix up a few uses of mktime.
2017-07-20 09:06:29 -04:00
Florian Bruhin
0f85898137 Add a config version to the YAML file 2017-07-19 08:22:00 +02:00
Ryan Roden-Corrent
c32d452786 Add LIMIT to history query.
For performance, re-introduce web-history-max-items.
As the history query has now become a very specific multi-part query and
history completion was the only consumer of SqlCategory, SqlCategory is
now replaced by a HistoryCategory class.
2017-07-16 18:13:51 -04:00
Ryan Roden-Corrent
8745f80d90 Fix qute://history SQL bug.
The javascript history page was requesting the new start_time in ms, but
the python code was expecting seconds. This is fixed by removing all the
millisecond translations in the python code and only translating to
milliseconds in the javascript code that formats dates.
2017-07-13 08:54:21 -04:00
Ryan Roden-Corrent
1aed2470e5 SQL code review.
- Fix flake8
- history.clear should also clear completion table
- call _resize_columns in set_model, not set_pattern
- add more unit-testing for the history completion table
2017-07-12 22:14:27 -04:00
Ryan Roden-Corrent
ea459a1eca SQL code review fixes.
- Ignore invalid variable name in flake8 (pylint already checks this and
  we don't want to have to double-ignore)
- Fix and test completion bug with `:set asdf `
- Remove unused import
- Use `assert not func.called` instead of `func.assert_not_called` for
  backwards compatibility
2017-07-12 08:19:31 -04:00
Ryan Roden-Corrent
182d067ff8 SQL code review fixes.
- Fix comment and empty line check in _parse_entry
- connect layoutAboutToBeChanged signal
- assert sort_order is None if sort_by is None
- modify sql init failure message to ask about Qt sqlite support.
2017-07-11 08:07:48 -04:00
Florian Bruhin
1e58c87380 Improve test for messageview timeout 2017-07-11 09:25:53 +02:00
Florian Bruhin
a91e6c3405 Fix test_adblock on Windows
We can't simply have an absolute filename as URL path there, so we only deal
with paths relative to tmpdir in the URLs now.
2017-07-10 22:22:44 +02:00
Florian Bruhin
237362663a Fix test_configfiles.test_init on Windows 2017-07-10 20:37:36 +02:00
Yashar Shahi
a631c971d9 Add tests for show messages longer
Add tests for "Show messages longer if there are multiple of them."
2017-07-10 20:52:42 +04:30
Florian Bruhin
e81dcccace Add a test for a None currentWidget with backforward widget 2017-07-10 09:29:45 +02:00
Florian Bruhin
5fb6cb713b Hide back/forward widget when there's no text 2017-07-10 07:59:56 +02:00
Florian Bruhin
0e8175b8eb Update docstrings/docs 2017-07-09 23:27:34 +02:00
Daniel Hahler
b3a9e09d6c Add statusline widget for back/forward indicator
Fixes https://github.com/qutebrowser/qutebrowser/issues/2737.
2017-07-09 22:38:44 +02:00
Florian Bruhin
bb567a61b6 Fix ipc test coverage 2017-07-09 22:09:31 +02:00
Florian Bruhin
84c2289aa5 Merge branch 'master' of https://github.com/iordanisg/qutebrowser 2017-07-09 12:56:52 +02:00
Florian Bruhin
cd063c74d9 Why is my commit -a broken 2017-07-09 12:54:19 +02:00
Florian Bruhin
6a2163d36f ipc: Remove support for connecting to legacy servers 2017-07-09 12:49:47 +02:00
Ryan Roden-Corrent
cf4ac1a5b7 SQL code review changes.
- use mocker.Mock instead of mock.Mock to avoid an extra import
- attach model to validator sooner so it can validate changes in the
  model during the test
2017-07-08 16:34:38 -04:00
Iordanis Grigoriou
c9fd182dba Adjust suggested_fn_from_title, add tests 2017-07-08 16:28:58 +02:00
Ryan Roden-Corrent
f9f8900fe9 More sql code review fixes.
- remove outdated comment
- fix sql init error message
- clean up history text import code
- fix test_history file path in coverage check
- use real web history, not stub, for completion model tests
- use qtmodeltester in sql/list_category tests
- test url encoding in history tests
- fix test_clear by using a callable mock
- remove test_debug_dump_history_oserror as the check is now the same as
  for the file not existing
- rename nonempty to data in test_completionmodel
- add more delete_cur_item tests
- test empty option/value completion
2017-07-08 09:57:32 -04:00
Florian Bruhin
ad615941a2 Replace OS X with macOS 2017-07-08 11:12:43 +02:00
Ryan Roden-Corrent
515e82262d Merge remote-tracking branch 'upstream/master' into really_complete 2017-07-07 20:42:21 -04:00
Florian Bruhin
215503ba59 Remove now useless suppression 2017-07-07 15:21:18 +02:00
Iordanis Grigoriou
82d194cf2e Improve function docstring, add more tests 2017-07-06 21:37:11 +02:00
Iordanis Grigoriou
3bfafb5e50 Refactor suggested_fn_from_title, add unit tests 2017-07-06 17:41:54 +02:00
Florian Bruhin
338d62204e Make TestModuleVersions in test_version more maintainable 2017-07-06 12:36:11 +02:00
Florian Bruhin
66168a5b49 Add test ids to test_version_output 2017-07-06 12:25:11 +02:00
Florian Bruhin
911e59b0f4 Improve version output without SSL support 2017-07-06 12:23:08 +02:00
Florian Bruhin
94951d92a1 Simplify arg handling in test_version_output 2017-07-06 12:15:42 +02:00
Ryan Roden-Corrent
dc4472470e Merge remote-tracking branch 'upstream/master' into really_complete 2017-07-05 08:45:57 -04:00
Ryan Roden-Corrent
81f5b7115f Add spec=[] to two mock functions in tests. 2017-07-05 08:44:56 -04:00
Florian Bruhin
28410b8533 Release v0.11.0 2017-07-04 18:02:34 +02:00
Florian Bruhin
0cdd3ff82f Update some more references to old config options 2017-07-04 16:46:02 +02:00
Florian Bruhin
cff61fa0bc Fix pylint
This also reverts commit 8df0b063be.
2017-07-04 15:34:10 +02:00
Florian Bruhin
88b878098d Implement pretty-printing of configtypes for the doc
This is also needed to make the docs environment work on Travis - as otherwise,
doc generation wasn't deterministic because of changing dict key order.
2017-07-04 15:09:23 +02:00
Florian Bruhin
f98b8a240e Fix flake8 2017-07-04 15:09:23 +02:00
Florian Bruhin
79c11d6008 Skip test_configdata.test_init_benchmark on Travis in Docker
See #2777
2017-07-04 15:09:23 +02:00
Florian Bruhin
65585b313d test_configtypes: Rename test_to_py to _valid for consistency 2017-07-04 15:09:23 +02:00
Florian Bruhin
9ac2dbcc80 Disallow surrogate escapes in dicts and lists in the config
In Dict.to_str() and List.to_str() we use json.dump to get a value. However,
JSON includes surrogate escapes in the dumped values, which breaks round trips.

>>> yaml.load(json.dumps({'\U00010000': True}))
{'\ud800\udc00': True}

>>> yaml.load(json.dumps({'\U00010000': True}, ensure_ascii=False))
yaml.reader.ReaderError: unacceptable character #x10000: special characters are not allowed

See:
https://stackoverflow.com/a/38552626/2085149
https://news.ycombinator.com/item?id=12798032
2017-07-04 15:09:23 +02:00
Florian Bruhin
fa0f4e1101 Improve test_configtypes.TestDict
We didn't have to_py tests there before.
2017-07-04 15:09:23 +02:00
Florian Bruhin
f00e91e85e Don't set valid_values in test_configtypes.TestList
Most of the time we want to check values without them being outright rejected by
ValidValues.
2017-07-04 15:09:23 +02:00
Florian Bruhin
05f4f2e742 Fix TestDict.test_hypothesis_text for unordered dicts 2017-07-04 15:09:23 +02:00
Florian Bruhin
ea2b9f5596 Remove old comment
The recursion is caught in test_config
2017-07-04 15:09:15 +02:00
Florian Bruhin
0528a800f2 Fix config things relying on dict order 2017-07-04 15:08:04 +02:00
Florian Bruhin
8933b4c5da Avoid calling configdata.init() in tests
It takes unnecessary time (20ms without C extensions) to initialize it over and
over again - and for some reason, it takes 20s (!) on Travis.
2017-07-04 15:08:04 +02:00
Florian Bruhin
9db4a8cb43 Clean up test_cache 2017-07-04 15:08:04 +02:00
Florian Bruhin
9dfe4429d7 Import qutebrowser.app in conftest 2017-07-04 15:08:04 +02:00
Florian Bruhin
b42265212b Update test_keyhints for new config
This also makes the keyhint display things sorted
2017-07-04 15:08:04 +02:00
Florian Bruhin
4bebfd8d5f Update test_modeparsers for new config 2017-07-04 15:08:04 +02:00
Florian Bruhin
d5cd0b19b0 Update test_basekeyparser for new config 2017-07-04 15:08:04 +02:00
Florian Bruhin
22b0f2fd24 Various simple test updates for new config
test_cache
test_cookies
test_webkitelem
test_cmdutils
test_runners
test_completionwidget
test_messageview
test_editor
test_miscwidgets
test_sessions
test_urlutils
test_utils
test_prompt
statusbar/test_*
test_cmdhistory
test_tabwidget
test_tab
test_downloads
test_networkmanager
2017-07-04 15:08:04 +02:00
Florian Bruhin
1663280f53 Update test_shared for new config
Also, make accept_language none_ok=True like it was in the old configdata.py
2017-07-04 15:08:04 +02:00
Florian Bruhin
7dd5e4b2e6 Skip broken completion tests
This skips test_completer and test_models - we'll reintroduce them when merging
the new completion.
2017-07-04 15:08:04 +02:00
Florian Bruhin
ff05560047 Update test_adblock for new config
This required some changes on how URLs are handled during those tests. Before,
we simply could return a path and (since we had a patched QNAM), nobody
complained.

Now this actually needs to be a valid URL, so we use
https://www.example.com/path everywhere instead.
2017-07-04 15:08:04 +02:00
Florian Bruhin
78d7ac311f Use fonts.monospace properly 2017-07-04 15:08:04 +02:00
Florian Bruhin
d641652a92 More test_config improvements 2017-07-04 15:08:04 +02:00
Florian Bruhin
c214acd899 Remove config from objreg 2017-07-04 15:08:04 +02:00
Florian Bruhin
f8a88ae042 Clean up objreg properly in config tests 2017-07-04 15:08:04 +02:00
Florian Bruhin
54adf3898a Add test_configfiles.py 2017-07-04 15:08:04 +02:00
Florian Bruhin
1a492e9f4a Re-add backend checks to new config 2017-07-04 15:08:04 +02:00
Florian Bruhin
556f49d367 Add PACFetcher.fetch
Let's not try to download proxies during tests...
2017-07-04 15:08:04 +02:00
Florian Bruhin
215fd2f055 More test_config fixes/tests 2017-07-04 15:08:04 +02:00
Florian Bruhin
009ed3584d Reorder tests 2017-07-04 15:08:04 +02:00
Florian Bruhin
2b9b54cf6b Tests and improvements for ConfigContainer 2017-07-04 15:08:03 +02:00
Florian Bruhin
4495e721d8 Tests and fixes for config.Config 2017-07-04 15:08:03 +02:00
Florian Bruhin
07d0ea6a54 Unit tests and improvements for :bind/:unbind 2017-07-04 15:08:03 +02:00
Florian Bruhin
3edebce833 Add tests for :set 2017-07-04 15:08:03 +02:00
Florian Bruhin
31b999ea59 Tests and improvements for KeyConfig 2017-07-04 15:08:03 +02:00
Florian Bruhin
725ffef5f3 Use a real config object in unit tests 2017-07-04 15:08:03 +02:00
Florian Bruhin
978013e750 Fix CommandParser and don't use a generator 2017-07-04 15:08:03 +02:00
Florian Bruhin
a8c7e8ba05 Add first config tests 2017-07-04 15:08:03 +02:00
Florian Bruhin
28670f8e48 Move config.style into config.config and refactor it 2017-07-04 15:08:03 +02:00
Florian Bruhin
81d6406e14 Update test_stylesheet 2017-07-04 15:08:03 +02:00
Florian Bruhin
a5c8a52dd5 Update config_stub for tests 2017-07-04 15:08:03 +02:00
Florian Bruhin
0dc95aceed Clean up old test_config.py 2017-07-04 15:08:03 +02:00
Florian Bruhin
065f82f485 Fix endless recursion while validating aliases 2017-07-04 15:08:03 +02:00
Florian Bruhin
ac78039171 Use aliases for :w and :q 2017-07-04 15:08:03 +02:00
Florian Bruhin
ac64ea287a Rename tabs.new_position/_explicit to .related/.unrelated 2017-07-04 15:08:03 +02:00
Florian Bruhin
441b3a4df4 Allow missing fixed_keys for configtypes.Dict
We just fill them up with a None value for the value type, so we can e.g. only
specify a subset of modes for bindings and the rest is {}.
2017-07-04 15:08:03 +02:00
Florian Bruhin
9d8b76e497 Simplify _none_value for List/Dict configtypes
We don't need to check for fixed_keys/required_keys in get_obj (only get_py),
and we don't need to care about mutability in get_py.
2017-07-04 15:08:03 +02:00
Florian Bruhin
da0a2b8578 Handle {} and [] with none_ok for configtypes.Dict/List 2017-07-04 15:08:03 +02:00
Florian Bruhin
2ba637891a Add required_keys for configtypes.Dict 2017-07-04 15:08:03 +02:00
Florian Bruhin
7ee222af88 Return [] for none-values for configtypes.List 2017-07-04 15:08:03 +02:00
Florian Bruhin
9cbacf3264 Use {} for none-dicts and fix keybindings 2017-07-04 15:08:03 +02:00
Florian Bruhin
127db2fe42 Be a bit more relaxed about values for Perc
We now allow float/int for objects, and strings without a trailing % sign.
2017-07-04 15:08:03 +02:00
Florian Bruhin
9bd438618a Add a test for DuplicateKeyError 2017-07-04 15:08:03 +02:00
Florian Bruhin
2a40401398 Fix config tests for new Command type 2017-07-04 15:08:03 +02:00
Florian Bruhin
383968d948 Add a Key config type
Make sure any key we get from the config is normalized).
2017-07-04 15:08:02 +02:00
Florian Bruhin
d0904a9f67 Adjust test settings 2017-07-04 15:08:02 +02:00
Florian Bruhin
bc8176ff21 Remove most legacy config code 2017-07-04 15:08:02 +02:00
Florian Bruhin
f5d2c48bbb Fix new keyconfig issues 2017-07-04 15:08:02 +02:00
Florian Bruhin
dc74a55b84 Fix remaining configtypes issues 2017-07-04 15:08:02 +02:00
Florian Bruhin
3392ccc58b test_configtypes fixes 2017-07-04 15:08:02 +02:00
Florian Bruhin
ecba175b16 Test and fix configtypes to_str. 2017-07-04 15:08:02 +02:00
Florian Bruhin
d69c6d0c66 Reorganize how configtypes store their data
Now the "object" kind of value (like in YAML) is stored internally, and that's
the canonical value. The methods changed their meaning slightly, see the
docstring in configtypes.py for details.
2017-07-04 15:08:02 +02:00
Florian Bruhin
1cbb4ece4b Force configtype.Dict keys to be strings 2017-07-04 15:08:02 +02:00
Florian Bruhin
41655e7852 Fix handling of none_ok in List/Dict
We now always return None (and '' as string) when the user configured an empty
list or dict.
2017-07-04 15:08:01 +02:00
Florian Bruhin
8ea3d92697 Initial implementation of to_str for configtypes 2017-07-04 15:08:01 +02:00
Florian Bruhin
fede64ba7a Add test for configdata.is_valid_prefix 2017-07-04 15:08:01 +02:00
Florian Bruhin
18eb133811 configdata: Make sure default values are valid 2017-07-04 15:08:01 +02:00
Florian Bruhin
0857a45b0a configtypes: parse regex flags properly 2017-07-04 15:08:01 +02:00
Florian Bruhin
6733e92b50 Handle files correctly in utils.yaml_dump 2017-07-04 15:08:01 +02:00
Florian Bruhin
001312ca82 Disallow Booleans for configtypes.Int.from_py 2017-07-04 14:42:56 +02:00
Florian Bruhin
4e729bb9ec Back to using json in test_configtypes
It returns one-line data and is YAML compatible
2017-07-04 14:42:56 +02:00
Florian Bruhin
dfee857466 Make utils.yaml_dump return str 2017-07-04 14:42:56 +02:00
Florian Bruhin
05dc94ccc4 Improve configtypes tests 2017-07-04 14:42:56 +02:00
Florian Bruhin
7416164aca Rename old validate tests 2017-07-04 14:42:56 +02:00
Florian Bruhin
71f2e8c577 None validation fixups for test_configtypes 2017-07-04 14:42:56 +02:00
Florian Bruhin
61ba92ae18 configtypes: Separate str/py basic validation
This also ensures the behavior for none_ok is consistent.
2017-07-04 14:42:56 +02:00
Florian Bruhin
cdbd64a30d Move test_configtypes_hypothesis to test_configtypes 2017-07-04 14:42:56 +02:00
Florian Bruhin
7e7fbf106b Fix lint and old config options 2017-07-04 14:42:56 +02:00
Florian Bruhin
63bdee8b55 Initial configtype tests update 2017-07-04 14:42:56 +02:00
Ryan Roden-Corrent
1e1335aa5e Make various SQL code review changes.
- Fix outdated comments
- Use mock specs when possible
- More precise error message check in test_import_txt_invalid.
- Fix copyright message
- Tweak missing pyqt error message
- Dead code: remove group_by and where from sqlcategory.
  With the new separate completion table, these are no longer used.
- Move test_history out of webkit/. History is no longer purely webkit
  related, it could be webengine.
2017-07-03 09:45:08 -04:00
Ryan Roden-Corrent
a34df34208 Fix various test/flake8/pylint errors. 2017-07-03 08:12:47 -04:00
Florian Bruhin
3b53ec1cb6 Skip tests with permission changes if they didn't work
This e.g. wouldn't work inside of a Docker container otherwise.
2017-07-03 10:07:40 +02:00
Florian Bruhin
1022b7ea32 Make jinja templating more strict
This ensures we actually know when an AttributeError happens.

It also changes most external code to use the correct environment, rather than
simply creating a jinja2.Template, which wouldn't use the more tightened
environment.
2017-07-02 22:17:33 +02:00
Florian Bruhin
aa6f229e6b Add utils.yaml_{load,dump} 2017-07-02 22:17:33 +02:00
Florian Bruhin
3e3685b68b Initial configexc refactoring 2017-07-02 22:17:33 +02:00
Florian Bruhin
5ec47da127 Get rid of configtypes.AutoSearch and IgnoreCase 2017-07-02 22:17:33 +02:00
Florian Bruhin
938946c48b configdata: Add check for shadowing keys 2017-07-02 22:17:33 +02:00
Florian Bruhin
52f6ea2525 Initial parsing 2017-07-02 22:17:33 +02:00
Ryan Roden-Corrent
c1f5e77fc6 Implement "Current" completion for bind.
When binding a key, the first row will be the current binding if the key
is already bound. This should make it easier for users to tell when they
are binding a key that is already bound, and what it is bound to.
2017-06-29 21:44:44 -04:00
Ryan Roden-Corrent
262b028ee9 Match error message in lineparser test. 2017-06-29 20:49:05 -04:00
Ryan Roden-Corrent
c007f592b3 Use more intuitive argument order in sql.delete. 2017-06-29 20:43:42 -04:00
Ryan Roden-Corrent
6ac940fa32 Fix pylint/coverage errors.
Ensure 100% coverage for sqlcategory and history, and fix some linter
errors
2017-06-27 12:33:51 -04:00
Ryan Roden-Corrent
f06880c6e2 Fix history completion delete function.
In order to update SqlQueryModel's rowCount after re-running the query,
we must call setQuery again.
2017-06-27 08:42:10 -04:00
Ryan Roden-Corrent
62a849c2db Fix bugs introduced in test_models 2017-06-26 12:41:48 -04:00
Ryan Roden-Corrent
46161c3af0 Refactor delete_cur_item.
Taking the completion widget as an argument was overly complex.
The process now looks like:

1. CompletionView gets deletion request
2. CompletionView passes selected index to CompletionModel
3. CompletionModel passes the row data to the owning category
4. The category runs its custom completion function.

This also fixes a bug. With the switch to the hybrid (list/sql)
completion model, the view was no longer updating when items were
deleted. This fixes that by ensuring the correct signals are emitted.

The SQL model must be refreshed by running the query. We could try using
a SqlTableModel so we can call removeRows instead.

The test for deleting a url fails because qmodeltester claims the length
of the query model is still 3.
2017-06-26 08:57:36 -04:00
Ryan Roden-Corrent
866f4653c7 Fix spelling existant -> existent. 2017-06-25 22:14:38 -04:00
Ryan Roden-Corrent
0f585eda4f Bring history.py back to 100% coverage.
The code of debug_dump_history was tweaked to handle a possible
OSException that can be thrown by open, which I noticed while trying to
test it.
2017-06-20 21:41:43 -04:00
Florian Bruhin
cb5cd1a910 Remove old test_commands.py 2017-06-20 15:20:32 +02:00
Florian Bruhin
994e8c692f Merge different FakeTabbedBrowser objects 2017-06-20 15:19:53 +02:00
Florian Bruhin
750ef834dc Make PyOpenGL a required dependency
Looks like the "black screen" issue isn't the only thing going wrong, some
people even report segfaults since the vendor check was added.
2017-06-20 13:05:53 +02:00
Ryan Roden-Corrent
891a6bcf14 Fix flake8 errors 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
c7a18a8b8d Fix tests for recent sql changes 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
4e87773d89 Use a dict instead of named params for insert.
This allows replace to be a named parameter and allows consolidating
some duplicate code between various insert methods.

This also fixes some tests that broke because batch insert was broken.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
f4f52ee204 Remove history.Entry.
No longer needed with sql backend. Query results build their own
namedtuple from the returned columns, and inserting new entries is just
done with named parameters.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
1fe1813431 Fix pylint errors. 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
679e001a48 Separate sqlcategory title from table name.
Also fix a number of sql/completion tests that were failing.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
fa39b82b3c Backup old history file after import.
Instead of removing it, move it to history.bak.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
a6a9ad72f9 Fix test_history_interface.
This was still using a history dict instead of SQL history.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
22b7b21d5a Use named placeholders for sql queries. 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
3a4ef09f58 More sql code review fixes 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
6fc61d12fc Assorted small fixes for sql code review. 2017-06-19 07:44:11 -04:00
Florian Bruhin
57d96a4512 Add a CompletionHistory instead of HistoryVisits table 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
309b6ba32c Move _import_history to history.py.
Also adjusts the history import test to operate at a higher level and
ensure the old text file is removed (or isn't, in the case of an error).
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
478a719f77 Use a prepared query for historyContains.
This is called often, hopefully a prepared query will speed it up.
This also modifies Query.run to return self for easier chaining, so you
can use `query.run.value()` instead of `query.run` ; query.value()`.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
565ba23f8c Don't instantiate completion models nedlessly.
For real this time. A mistake on the last commit like this meant models
were still spuriously instantiated.
Now that the completion model is reused, the layoutChanged signal needs
to be forwarded through, otherwise the view will not update.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
a01c76db54 Remove 'group by' from url completion query.
This seemed to have a significant performance impact. Removing it means
that instead of just seeing the most recent atime for a given url, you
will see multiple entries.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
c297f047d2 Don't regenerate completion model needlessly.
If the completion model would stay the same, just keep it and update the
filter pattern rather than instantiating a new model each time the
pattern changes.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
2cd02be7b1 Remove CompletionModel.columns_to_filter.
Instead set this on inidividual categories, as that is where it actually
gets used. This makes it easier for SqlCompletionCategory to reuse a
prepared query (as it gets the filter field names in its constructor).
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
8fb6f45bec Don't set pattern in SqlCategory constructor.
This will be called by the Completer after construction anyways, this
was a duplicate call that could be expensive.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
cf89ffa971 Fix pylint/flake8 errors 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
2c501f7fb7 Fix url completion benchmark.
Still had old code from pre-SQL era.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
39b561a182 Fix BaseLineParser::test_double_open.
Don't tie the test to a particular error message. Ths failed because a
typo was fixed (AppendLineParser -> LineParser).
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
e67da51662 Use prepared SQL queries. 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
20000088de Add debug-dump-history and fix sql history tests.
Trying to read from the sql database from another process was flaky.
This adds a debug-dump-history command which is used by the history BDD
tests to validate the history contents.

It outputs history in the old pre-SQL text format, so it might be
useful for those who want to manipulate their history as text.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
87643040a4 Fix test_history for python < 3.6.
Mock.assert_called is only in python 3.6. For earlier versions we must
use `assert m.called`.

Weird errors only appearing in CI, trying to debug...
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
eb61269068 Fix qute://history javascript for SQL.
Returning "next" was no longer possible as the SQL query does not fetch
more items than necessary. This is solved by using a start time, a
limit, and an offset. The offset is needed to prevent fetching duplicate
items if multiple entries have the same timestamp.

Two of the history tests that relied on qute://history were changed to
rely on qute://history/data instead to make them less failure-prone.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
71191f10a2 Only complete most recent atime for url.
The history completion query is extended to pick only the most recent item for
a given url.

The tests in test_models now check for ordering of elements.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
9d4888a772 Optimize qute://history for SQL backend.
The old implementation was looping through the whole history list, which for
SQL was selecting every row in the database. The history benchmark was taking
~2s. If this is rewritten as a specialized SQL query, the benchmark takes
~10ms, an order of magnitude faster than the original non-SQL implementation.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
784d9bb043 Remove code rendered dead by sql implementation.
Vulture exposed the following dead code:

- AppendLineParse was only used for reading the history text file, which is now
  a sql database (and the import code for the old text file is simpler and does
  not need a complex line parser)

- async_read_done is no longer used as importing the history text file is
  synchronous (and should only happen once)

- config._init_key_config is unused as it was moved to keyconf.init
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
a8ed9f1c2f Fix qute://version sql init bug.
Calling sql.init() in version.version() would replace the existing sql
connection and cause a crash when accessed by opening qute://version.

Now version relies on sql already being initted, and app.py inits sql early if
the --version arg is given.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
44080b8ad4 Fix flake8 errors in test_history 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
e661fb7446 Fix test_history.
History doesn't depend on standarddir anymore, the history file path get passed
by app.py.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
f110cf4d53 Fix long hang after importing history.
Turns out historyContains was getting called for the webkit backend multiple
times when the browser starts. This was calling `url in history`, which was
enumerating the entire history as `__contains__` was not defined.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
024386d189 Fail on history file parsing errors.
Instead of skipping bad history lines during the import to sql, fail hard. We
don't want to delete the user's old history file if we couldn't parse all of
the lines.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
6412c88277 Clean up history module.
Eliminate out-of-date docstring and remove an unused signal.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
3e63b62d6e Fix pylint/flake8 for sql work. 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
8ff45331df Clean up sql implementation.
Now that sql is only used for history (not quickmarks/bookmarks) a number of
functions are no longer needed. In addition, primary key support was removed as
we actually need to support multiple entries for the same url with different
access times. The completion model will have to handle this by selecting
something like (url, title, max(atime)).

This also fixes up a number of tests that were broken with the last few
sql-related commits.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
80647b062a Convert old history file to sqlite.
If qutebrowser detects a history text file when it starts
(~/.local/share/qutebrowser/history by default on Linux), it will import this
file into the new sqlite database, then delete it.

The read is done as a coroutine as it can take some time.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
de5be0dc5a Store history in an on-disk sqlite database.
Instead of reading sqlite history from a file and storing it in an in-memory
database, just directly use an on-disk database. This resolves #755, where
history entries don't pop in to the completion menu immediately as they are
still being read asynchronously for a few seconds after the browser starts.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
b47c3b6a60 Test deleting a history entry from completion.
Deleting a history entry should do nothing, but we want a test to ensure this
and get 100% branch coverage for urlmodel.

This also un-skips the bookmark/quickmark tests.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
2eea115b3a Rename sqlcategory and add to perfect_files.
There was a typo in the file name.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
4296eed429 Fix test_history cleanup failure.
The test may be skipped if the PyQt5.QtWebKitWidget import fails, but the
cleanup was still running and trying to delete a nonexistant web-history.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
5dce6fa494 Fix pylint/flake8 errors 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
f95dff4d9e Decouple categories from completionmodel.
Instead of add_list and add_sqltable, the completion model now supports
add_category, and callees either pass in a SqlCategory or ListCategory. This
makes unit testing much easier.

This also folds CompletionFilterModel into the ListCategory class.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
1d54688b0b Revert "Use SQL completer for quickmarks/bookmarks."
This reverts commit bcf1520132df84552f69419f3b1cbf3ede20ccad.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
e3a33ca427 Implement a hybrid list/sql completion model.
Now all completion models are of a single type called CompletionModel.
This model combines one or more categories. A category can either be a
ListCategory or a SqlCategory.

This simplifies the API, and will allow the use of models that combine simple
list-based and sql sources. This is important for two reasons:

- Adding searchengines to url completion
- Using an on-disk sqlite database for history, while keeping bookmarks and
  quickmars as text files.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
921211bbaa 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.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
99c9b2d396 Fix two small mistakes after SQL code review.
urlmodel is now sorted, so the test had to be adjusted. Also remove one unused
import.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
c4c5723a61 Sort history completion entries by atime. 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
56f3b3a027 Small review fixups for SQL implementation.
Respond to the low-hanging code review fruit:

- Clean up some comments
- Remove an acidentally added duplicate init_autosave
- Combine two test_history tests
- Move test_init cleanup into a fixture to ensure it gets called.
- Name the _ argument of bind(_) to _key
- Ensure index is valid for first_item/last_item
- Move SqlException to top of module
- Rename test_index to test_getitem
- Return QItemFlags.None instead of None
- Fix copyright dates (its 2017 now!)
- Use * to force some args to be keyword-only
- Make some returns explicit
- Add sql to LOGGER_NAMES
- Add a comment to explain the sql escape statement
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
3c676f9562 Fix pylint/flake8 errors for SQL work. 2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
a050cb94f6 Report sqlite version with --version. 2017-06-19 07:44:11 -04:00
Florian Bruhin
df0bd23d79 Make pylint shut up about test_version 2017-06-19 13:42:19 +02:00
Ryan Roden-Corrent
c6645d47ba Remove newest_slice and StatusBar._option.
newest_slice is no longer needed after the completion refactor. Now that
history is based on the SQL backend, LIMIT is used instead.

StatusBar._option is not used, though I'm not sure why vulture only caught it
now.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
fc5fd6096a Revert "Initialize SQL for two failing tests."
This reverts commit 386e227ce7534f1e427db7ba6d4e53dc153a49f3.
The problem was really state leakage, initializing sql for these tests isn't
necessary.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
788babbb61 Further prevent state leakage from test_init.
test_history.test_init also leaked state by leaving the instantiated history as
the parent of the QApp, which was causing test_debug to fail because it was
trying to dump the history object left from test_history.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
d658378af3 Eliminate test interference from webkit history.
Initializing the qtwebkit history backend left some global state that was
leaking into other tests.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
490250f5be Initialize SQL for two failing tests.
test_selectors and test_get_all_objects were running fine on my machine, but
for some reason is failing with "Driver not loaded" on Travis. Let's try
initializing SQL and see what happens.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
ffd044b52b Fix pylint and flake8 for SQL work.
Vanity commit. This also touches up a few comments.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
ea9217a61f Fix qutescheme for new SQL backend.
The qute://history and qute://bookmarks handlers were added during my work, and
had to be adapted to the SQL-based history backend.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
0e650ad719 Return namedtuples from SqlTable.
Instead of returning a regular tuple and trying to remember which index maps to
which field, return named tuples that allow accessing the fields by name.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
d89898ef7d Implement delete_cur_item for sql completion.
This re-enables bookmark/quickmark deletion for url completions via the new SQL
interface.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
fe80878788 Implement custom where clause in SQL.
Allow categories to specify a WHERE clause that applies in addition to the
pattern filter. This allows the url completion model to filter out redirect
entries.

This also fixed the usage of ESCAPE so it applies to all the LIKE statements.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
9f27a9a5d7 Implement column selectors for sql completion.
A SQL completion category can now provide a customized column expression for
the select statement. This enables the url model to format timestamps, as well
as rearrange the name and url in the quickmark section.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
3f6f03e325 Respect web-history-max-items with SQL.
Use a LIMIT with the sql competion model to limit history entries as the old
completion implementation did.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
df995c02a3 Get rid of varargs in sql.run_query.
Things are clearer when just passing a list.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
b70d5ba901 Use QSqlQueryModel instead of QSqlTableModel.
This allows setting the query as a QSqlQuery instead of a string, which allows:

- Escaping quotes
- Using LIMIT (needed for history-max-items)
- Using ORDER BY (needed for sorting history)
- SELECTing columns (needed for quickmark completion)
- Creating a custom select (needed for history timestamp formatting)
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
52d7d1df0c Use SQL completer for quickmarks/bookmarks. 2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
839d49a8ac Fix up pylint/flake8 for completion revamp. 2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
b381148e06 Unittest CompletionView.completion_item_del.
There were no unit tests for this and the various ways it can fail, and I'm
about to screw with it a bit.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
a774647c26 Get test_models mostly working again.
- Adjust _check_completions to work for CompletionModel and SqlCompletionModel
- Move sql initialization into a reusable fixture
- Remove the bookmark/quickmark/history stubs, as they're now handled by sql
- Disable quickmark/bookmark model tests until their completion is ported to
  sql.
- Disable urlmodel tests for features that have to be implemented in SQL:
    - LIMIT (for history-max-items)
    - Configurable column order (for quickmarks)
    - Configurable formatting (for timestamp-format
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
3005374ada Simplify sorting logic in sortfilter.
For URL completion, time-based sorting is handled by the SQL model.
All the other models use simple alphabetical sorting. This allowed cleaning up
some logic in the sortfilter, removing DUMB_SORT, and removing the
completion.Role.sort.

This also removes the userdata completion field as it was only used in url
completion and is no longer necessary with the SQL model.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
acea0d3c67 Use SQL completion for the open command.
Now that history, bookmark, and quickmark storage are SQL-backed, use
a sql completion model to serve url completions.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
6e1ea89ca1 Implement SQL completion model.
This model wraps one or more SQL tables and exposes data in a tiered
manner that can be consumed by the tree view used for completion.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
9477a2eeb2 Use SQL for history storage.
The browser-wide in-memory web history is now stored in an in-memory sql
database instead of a python dict. Long-term storage is not affected, it
is still persisted in a text file of the same format.

This will set the stage for SQL-based history completion.
See #1765.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
f43f78c40f Implement SQL interface.
When qutebrowser starts, it creates an in-memory sqlite database. One
can instantiate a SqlTable to create a new table in the database. The
object provides an interface to query and modify the table.

This intended to serve as the base class for the quickmark, bookmark,
and history manager objects in objreg. Instead of reading their data
into an in-memory dict, they will read into an in-memory sql table.

Eventually the completion models for history, bookmarks, and quickmarks
can be replaced with SqlQuery models for faster creation and filtering.

See #1765.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
3b30b42211 Remove completion.instances, usertypes.Completion.
The new completion API no longer needs either of these. Instead of
referencing an enum member, cmdutils.argument.completion now points to
a function that returnsthe desired completion model.
This vastly simplifies the addition of new completion types. Previously
it was necessary to define the new model as well as editing usertypes
and completion.models.instances. Now it is only necessary to define a
single function under completion.models.

This is the next step of Completion Model/View Revamping (#74).
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
08bb3f4f19 Implement completion models as functions.
First step of Completion Model/View revamping (#74). Rewrite the
completion models as functions that each return an instance of a
CompletionModel class.

Caching is removed from all models except the UrlModel. Models other
than the UrlModel can be generated very quickly so caching just adds
needless complexity and can lead to incorrect results if one forgets to
wire up a signal.
2017-06-19 07:42:12 -04:00
Florian Bruhin
4ae8e247d0 Show 'legacy QtWebKit' in version output 2017-06-19 10:24:33 +02:00
Florian Bruhin
df6c4c6e73 Fix earlyinit.qt_version issues 2017-06-19 09:42:49 +02:00