Commit Graph

380 Commits

Author SHA1 Message Date
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
7d04f155c8 Add missing docstring. 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
ce3c555712 Use list completion for bookmarks/quickmarks.
The RFC on moving from plaintext to SQL storage (#2340) showed that many would
be upset if bookmarks and quickmarks were no longer stored in plaintext.

This commit uses list-based completion for quickmarks and bookmarks. Now the
history storage can be moved from plaintext to an on-disk SQL database while
leaving bookmarks and quickmarks as-is.
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
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
6a8b1d51fa Avoid config -> configmodel circular import.
Avoid the config dependency by using objreg.get('config') instead of
config.get.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
21757a96a3 Add docstrings to SqlCompletionModel overrides.
Leaving QAbstractItemModel overrides undocumented made pylint angry.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
be07107b1c Fix end2end completion tests for SQL backend.
Change the logging to report the completion function name and have the end2end
tests check for this.

Remove the tests for realtime completion, as it was decided this is not an
important feature and the code is much simpler without it.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
02fb1a037c Implement canFetchMore for SQL completion.
This just forwards canFetchMore and fetchMore to the underlying tables.
It seems to be returning True and fetching in some cases (with a large
history), so I guess it is useful?
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
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
5bd047b70b Fix CompletionView.completion_item_del for new API.
The new function based completion models work a little differently so the view
needed slightly different error handling.
2017-06-19 07:42:12 -04:00
Ryan Roden-Corrent
d4f2a70f83 Slightly simplify CompletionModel.new_item.
There was no need to have a branch based on whether the misc value was None or
not.
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
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
00a7a0cee6 Reorganize pylint config
This removes various stuff we don't need anymoe, and also re-enables and fixes
the import order check.
2017-05-17 20:20:12 +02:00
Florian Bruhin
822623f2ed Finally update copyrights... 2017-05-09 21:37:03 +02:00
Florian Bruhin
70d7a56b11 Also set Fusion style for downloads and completion
This makes those UI elements look the same on different platforms/OS styles,
with the small drawback of overriding the context menu style.

This most likely fixes #80 (though I couldn't reproduce that on Windows 10).
2017-04-25 22:20:37 +02:00
Florian Bruhin
1015badb8b Disable animation for completion view 2017-04-25 09:18:31 +02:00
Florian Bruhin
1d0f187fab Adjustments for new pylint version 2017-04-13 18:22:16 +02:00
Florian Bruhin
12ed226ce6 Set COLUM_WIDTHS for :help completion
Fixes #2287
2017-02-08 09:11:58 +01:00
Florian Bruhin
c4a74c7a34 Make sure completion column widths never get negative
I discovered this because of #2287 but it doesn't actually change anything
there. When we don't have a third column, subtract the scrollbar width from the
second one.
2017-02-08 09:10:40 +01:00
Florian Bruhin
de50f30b9b Replace all GitHub links 2017-02-05 00:13:11 +01:00
Maciej Wołczyk
e613d01263 Fixed problems with tab completion after moving tabs (#2141) 2016-11-30 14:17:20 +01:00
Florian Bruhin
6184da0224 Add a comment 2016-10-05 21:16:18 +02:00
Ryan Roden-Corrent
2696f9b427 Handle unicode characters in Completer.
Just limit the cursor position to the length of the text to avoid
crashes in this case.

Resolves #2007.
2016-10-04 07:36:49 -04:00
Florian Bruhin
750dfd98af Generalize statusbar-attached website overlays
We already had some duplicated logic for completion/keyhint/messageview,
and plan to add prompt overlays too now - so here we refactor related
code to have a list of overlays instead, which are all
resized/positioned by the mainwindow when needed.

This also changes the size management, which gets moved into the
sizeHint of the respective overlay widgets.
2016-09-22 17:04:39 +02:00
Ryan Roden-Corrent
1d2cf3b648 Completer: don't try to partition search.
Exit before trying to partition if the command prefix is not ':'.

Resolves #1969:
'TypeError with refactored completion when searching for command'
2016-09-21 07:08:34 -04:00
Florian Bruhin
bb1b1c8ee8 Remove unused imports 2016-09-15 16:45:48 +02:00
Ryan Roden-Corrent
a9771007b1 Pass string, not index from on_selection_changed.
Simplify the CompletionWidget/Completer interface by changing
on_selection_changed to pass the newly selected text rather than the
index of the newly selected item.
This moves the logic from Completer to CompletionWidget but simplifies
the interaction between the two and makes testing easier.
2016-09-14 22:55:07 -04:00
Ryan Roden-Corrent
ac03095512 Small if-statement style tweak in Completer. 2016-09-14 22:35:05 -04:00
Ryan Roden-Corrent
e23d611b37 Strip quotes from completion pattern.
Given a commandline like:
`:set general editor "gvim -f"|`, the pattern should be 'gvim -f'
rather than '"gvim -f"'.
2016-09-12 22:19:44 -04:00
Ryan Roden-Corrent
69a3df174d Remove needless try/catch in on_selection_changed. 2016-09-12 22:19:44 -04:00
Ryan Roden-Corrent
d651cc75b0 Fix flake8/pylint errors. 2016-09-12 22:19:44 -04:00
Ryan Roden-Corrent
808a645b40 Fix quick-complete highlighting quirk.
When the commandline reads ':open |', quick-completing the only offered
completion will set the commandline to ':open some_url |'. Since `open`
has `maxsplit=0`, everything after ':open' is (correctly) treated as
one argument. This means completion is opened again with 'some url '
as the pattern (note trailing whitespace), which makes the comletion
menu 'flicker' and stay open even though it was 'supposed' to quick
compelte.

This is fixed by ignoring the next completion request if we just
completed something after maxsplit (because we don't expect any more
completions after the last split).

Resolves #1519.
2016-09-12 22:19:44 -04:00
Ryan Roden-Corrent
fcadde6aef Merge _split into _partition in Completer.
After the refactoring, _split is only called by _partition so just make
it part of the same method. This also removes the use of
_empty_item_index, as it can be figured out on the fly.
2016-09-12 22:19:44 -04:00
Ryan Roden-Corrent
127412d91c Simplify update_completion.
Remove the class variables _cursor_part and _empty_item_index. Instead,
split up the commandline around the cursor whenever that information is
needed. Using locals instead of class variables makes the logic easier
to follow and ends up requiring much less code.
2016-09-12 22:19:44 -04:00
Ryan Roden-Corrent
581d7659ba Clean up Completer.on_selection_changed.
Remove the dependency on the class variables _empty_item_index
and _cursor_part to make the code easier to follow. If
_update_completion is refactored in a similar way these variables can
be removed.
2016-09-12 22:19:44 -04:00
Florian Bruhin
71a89bd418 *Really* fix completion with multiple words.
Turns out re.escape also escapes spaces, so we'd need to replace '(\\ )'
groups after escaping. At this point it's easier to just combine spaces
before escaping the pattern.

Fixes #1934.
Supersedes #1935.
2016-09-09 09:03:18 +02:00
Florian Bruhin
0a3853fcb7 Fix handling of spaces in completion
This is a regression introduced in
faa052ad6f.

Fixes #1934.
2016-09-08 21:59:18 +02:00
Florian Bruhin
faa052ad6f Fix hang with multiple spaces in URL completion 2016-09-04 20:19:16 +02:00
Florian Bruhin
b9282587d0 Merge branch 'auto-open-fixes' of https://github.com/mlochbaum/qutebrowser into mlochbaum-auto-open-fixes 2016-08-29 07:12:14 +02:00
Florian Bruhin
8643f6f28d Add explicit else in :completion-item-focus
See #1885
2016-08-23 20:49:56 +02:00
Marshall Lochbaum
44411e02c6 Replace != with (is not) when testing whether a model is new 2016-08-22 13:02:13 -04:00
Marshall Lochbaum
2aef26c58b Linting 2016-08-21 23:22:46 -04:00
Marshall Lochbaum
cbecd48871 Refactor Completer/CompletionView interface, removing set_pattern() 2016-08-21 22:56:18 -04:00
Marshall Lochbaum
c5ca102d93 Fix completion flicker on quick-complete with show=auto 2016-08-20 01:01:12 -04:00
Marshall Lochbaum
08b348be50 Merge branch 'master' into auto-open-fixes 2016-08-19 22:50:26 -04:00
Ryan Roden-Corrent
7b3839b44b Focus completion by category.
Implement `completion-item-focus next-category` and
`completion-item-focus prev-category` to jump through completions by
category rather than by item.

Resolves #1567.
2016-08-15 07:14:28 -04:00
Ryan Roden-Corrent
1de465f42b Filter buffer completion by all columns.
In addition to the url and text column, also filter by the index column
so the user can enter a number to navigate to that tab.

Resolves #1830.
2016-08-10 10:20:04 -04:00
Ryan Roden-Corrent
0c43ca9f09 Don't sort command completions in models.
The sortfilter already handles sorting, there is no reason to pre-sort
the entries in the model.
2016-08-10 06:58:34 -04:00
Ryan Roden-Corrent
97a971624b Show bindings for aliases in completion.
Command completions for `:bind` and `:` will now show bindings for
aliases. The binding is only included if it is bound to that alias, not
if it is bound to the command the alias points to.
2016-08-10 06:56:44 -04:00
Ryan Roden-Corrent
051a00804b Use regular dict in get_reverse_bindings_for.
Returning a defaultdict made the caller's code look confusing, as it
wasn't clear why there wouldn't be a Keyerror in some cases. Instead,
let the caller explicitly use `get`.
2016-08-10 06:56:44 -04:00
Ryan Roden-Corrent
709470fbe6 Clean up miscmodels and test_models.
- Split up a long conditional into multiple variables.
- Fix a small typo in a related test.
- Remove a trailing comma from an argument list.
2016-08-10 06:56:44 -04:00
Ryan Roden-Corrent
8dbc368d08 Refactor duplicate code for command completion.
Consolidate the logic used to generate the command completion category
into one place. This is shared by CommandCompletionModel,
HelpCompletionModel, and BindCompletionModel.
2016-08-10 06:56:44 -04:00
Ryan Roden-Corrent
0ea61d5f15 Show hidden commands in completion for :bind.
There is a fair amount of duplicate code around command completion that
could probably be refactored.

Resolves #1707.
2016-08-10 06:56:44 -04:00
Ryan Roden-Corrent
dd9470af94 Show hidden commands in help completion.
Hidden commands are not shown in command completion as they typically
would not be run directly. However, a user might still might like to see
help for them if, for example, they are writing a script or creating a
binding.

Addresses #1707.
2016-08-10 06:55:46 -04:00
Ryan Roden-Corrent
91ec5cc356 Update command completion on setting an alias.
Wire up the config change event to update command completion on
changing aliases, so the new aliases will be included.

Fixes #1814.

Currently we do not have tests at a high enough level to test whether
signals are wired up correctly to update completions.
2016-08-09 21:37:12 -04:00
Marshall Lochbaum
8da8441623 Merge auto-open option into show 2016-08-09 13:11:32 -04:00
Marshall Lochbaum
d98c81c9d6 Correct widget behavior when there is no completion 2016-08-09 13:03:38 -04:00
Marshall Lochbaum
b2067ef186 Remove unused _signals_connected 2016-08-08 18:15:13 -04:00
Marshall Lochbaum
80db69904d Move auto-open handling to CompletionView from Completer 2016-08-08 16:56:11 -04:00
Ryan Roden-Corrent
7038db6b17 Combine completion-item-{prev,next}.
- Use a single command completion-item-focus with a next/prev argument.
- Add a rule to translate old configs.
- Regenerate the docs.

See #1095.
2016-08-08 07:37:53 -04:00
Jan Verbeek
6bbde59de7 Rebuild buffer completion when tab title changes 2016-08-07 16:15:24 +02:00
Florian Bruhin
26e0383d45 Merge branch 'refactor_command_completion' of https://github.com/rcorre/qutebrowser into rcorre-refactor_command_completion 2016-08-07 11:29:50 +02:00
Ryan Roden-Corrent
adc428e525 Perfect coverage for sortfilter.
Mark an area of sortfilter with `#pragma no coverage` and add it to
perfect_files.
2016-08-06 20:48:21 -04:00
Ryan Roden-Corrent
66358e5b0f Remove usertypes.Completion.empty.
Completion.empty existed to fill a slot in the old Command.completions
interface if the first positional arg had no completions but the second
did, as is the case for the `bind` command. Now that
`Command.completions` is replaced by `Command.get_pos_arg_info`, this
is no longer needed.
2016-08-06 12:01:09 -04:00
Ryan Roden-Corrent
c792ffda67 Remove Command.completion.
Command completion types are now identified by ArgInfo, so just use
that directly and cut out the middle-man. This shouldn't change any
completion behavior.

Adds a test for get_pos_arg_info to test_cmdutils.

Modifies test_completer to test the use of get_pos_arg_info. Instead of
using FakeCommand, real Command objects are used, to validate that the
Completer works with the real Command interface. This also cleans out
some test cases that were testing things already covered by other cases.
2016-08-06 11:59:04 -04:00
Florian Bruhin
b17296db0d Return with invalid index 2016-08-02 12:03:29 +02:00
Florian Bruhin
b8aeb9f80e Fix lint 2016-08-02 12:03:29 +02:00
Ryan Roden-Corrent
a393adc6c7 Don't crash completion with auto-open/show False.
If both are false, the selectionModel may be None.
In this case, don't try to move the index.
Resolves #1722.
2016-08-01 22:36:04 -04:00
Ryan Roden-Corrent
6e2d78b826 Don't crash on tab with no completions.
first_item and last_item return an invalid index when there are no
items in the completion, and the completionwidget will throw on an
invalid index. However, setting an invalid index on the selection view
is fine, so just remove the assertion.

Resolves #1731.
2016-08-01 22:16:55 -04:00
Florian Bruhin
62f9161d03 Merge branch 'completer_tests' of https://github.com/rcorre/qutebrowser into rcorre-completer_tests 2016-08-01 16:02:53 +02:00
Florian Bruhin
c421f44f4e Specify completion category font in HTML
It seems like specifying a font for QTreeView::item in a Qt stylesheet
doesn't actually do anything.
2016-08-01 14:56:51 +02:00
Florian Bruhin
3d1f28ac9c Merge branch 'master' of https://github.com/nanjekyejoannah/qutebrowser into nanjekyejoannah-master 2016-08-01 14:35:06 +02:00
nanjekyejoannah
3d4e76b1a4 commit resolving issue#1395 2016-08-01 15:20:44 +03:00
nanjekyejoannah
1e94685653 Refactoring to resolve issue #1395 2016-08-01 14:00:30 +03:00
Florian Bruhin
2baadaf565 Remove now useless pylint suppressions 2016-08-01 12:47:19 +02:00
nanjekyejoannah
212d5fe932 commit resolving issue #1395 2016-08-01 11:28:27 +03:00
Ryan Roden-Corrent
fbadc5e668 Remove second arg from on_selection_changed.
The deselected argument was unused, so remove it from the signal and
the slot.
2016-07-29 08:48:24 -04:00
Florian Bruhin
14eabc7160 Merge branch 'completion_trivial' of https://github.com/lahwaacz/qutebrowser into lahwaacz-completion_trivial 2016-07-29 12:08:10 +02:00
Florian Bruhin
cffe2281b1 Use qtmodeltester for completion model tests
See http://pytest-qt.readthedocs.io/en/latest/modeltester.html
See #1702
2016-07-29 10:26:55 +02:00
Jakub Klinkovský
2a70146db1 Remove unneeded invalidateFilter call.
First done in b5781f0ed3 and later
reverted in a6f1bf29ae because it had
broken "completion->shrink", but that is no longer the case.
2016-07-29 10:15:21 +02:00
Jakub Klinkovský
119f9c0e18 completion: get rid of model-specific sort method (see #545) 2016-07-29 10:13:32 +02:00
Jakub Klinkovský
49327dfcbb completion: highlight only the matched terms
closes #1650
2016-07-29 10:13:32 +02:00
Jakub Klinkovský
caf5937585 completion: get rid of custom_filter (see #545) 2016-07-29 10:13:27 +02:00
Ryan Roden-Corrent
dd827332c0 Clean up unused imports from completion refactor. 2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
f31e890862 Move completion_item_{next,prev} to CompletionView.
These commands are more closely tied to the CompletionView than
Completer. This removes the need for an extra signal tying the
CompletionView to the Completer.

The call to _open_completion_if_needed was moved to
on_selection_changed, as this will already be called when a new item is
selected.
2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
ffc5a42d04 Don't use objreg to get CompletionView.
The CompletionView is the parent of the Completer, so there's no need
to use objreg to get it.
See #640.
2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
b9cf9d180b Decouple Completer and CompletionView.
Rather than having a CompletionView instantiate and register a
Completer, instantiate both in MainWindow. The CompletionView is the
parent of the Completer, and communicates by emitting
selection_changed, meaning it no longer needs to contain a reference to
the Completer.
2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
d836fcb118 Code review for completion tests.
- clean up docstring typos
- use _ to name an unused loop variable
- parent the filter model to avoid an issue with disposal
- use mocker.patch instead of monkeypatch to mock Completer creation
- use is instead of == to compare by identity
2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
e5da179ebf Limit the public interface of Completer.
Only schedule_completion_update and selection_changed are used
externally, so mark the rest of the API as private.
2016-07-28 12:20:24 -04:00
Florian Bruhin
73cd0e01ef Fix deleting of quickmarks with ctrl-d 2016-07-27 19:44:34 +02:00
Florian Bruhin
49977a32c4 Remove unused imports 2016-07-26 11:09:24 +02:00
Florian Bruhin
36b0054238 Add keyconf.get_reverse_bindings_for 2016-07-26 10:50:50 +02:00
Florian Bruhin
76eab7617b Remove @pyqtSlot for functions and non-QObjects
Fixes #1669
2016-07-23 11:42:50 +02:00
Florian Bruhin
9b75e661e2 Fix missed url_text substitutions 2016-07-11 14:59:35 +02:00
Florian Bruhin
a470bfc3f3 Get rid of url_text_changed signal
Instead we simply use url_changed which (similar to Qt's urlChanged)
simply has a QUrl argument.
2016-07-11 14:28:51 +02:00
Florian Bruhin
b791095324 Rename browser.tab module and classes 2016-07-10 17:27:02 +02:00
Florian Bruhin
2befebaf3a Don't use properties for AbstractTab
Otherwise exceptions in there could be hidden by Python/PyQt.

Some places are not changed yet, as there are also other renames in the
next commits.
2016-07-08 10:05:46 +02:00
Florian Bruhin
09f025628f Use tab.AbstractTab for signals/slots 2016-07-07 18:32:52 +02:00
Florian Bruhin
5dd4b2d56a Fix :buffer completion 2016-07-07 18:32:52 +02:00
Florian Bruhin
b429b919b5 Merge branch 'completer_tests' of https://github.com/rcorre/qutebrowser into rcorre-completer_tests 2016-07-06 13:35:13 +02:00
Florian Bruhin
70117265d6 Fix some a/an misspellings
Thanks to https://github.com/jwilk/anorack
2016-07-05 08:34:03 +02:00
Ryan Roden-Corrent
1ea28890b5 Move completion_item_del to completion widget.
It was implemented as a member of the Completer object, but registered
to the CompletionWidget. This led to the weird scenario where self was
actually a CompletionWidget, even though it was declared in Completer.
2016-07-03 17:35:17 -04:00
Florian Bruhin
900ad1ba6d Merge branch 'alias-multi-commands' of https://github.com/mgoral/qutebrowser into mgoral-alias-multi-commands 2016-06-30 12:34:18 +02:00
Florian Bruhin
4fccc89d7d Split browser into browser/browser.webkit 2016-06-13 11:18:21 +02:00
Michał Góral
7ee99ba043 Moved searching for aliases to CommandRunner.parse_all()
This addresses issue with having alias for multiple commands splitted by ';;'.

See: The-Compiler/qutebrowser#956.
2016-06-12 21:09:10 +02:00
Florian Bruhin
66938ed44b Full redirect support for history
When a redirect occurs, the item is saved in history with a -r suffix
now. When opening qutebrowser that's picked up and the item is hidden
from completion.
2016-06-10 14:40:42 +02:00
Florian Bruhin
79e0aa2418 Merge branch 'history-title' of https://github.com/toofar/qutebrowser into toofar-history-title 2016-06-08 12:53:07 +02:00
Florian Bruhin
21d53b0265 Merge branch 'history-clear' of https://github.com/EliteTK/qutebrowser into EliteTK-history-clear 2016-06-08 09:28:36 +02:00
Nick Ginther
2065f292ab fix crash on empty parts[] (#1523) 2016-05-25 16:45:06 -05:00
Ryan Roden-Corrent
b1440a1804 Implement utils.is_special_key.
The check `key.startswith('<') and key.endswith('>') is repeated many
times in code to check for a special key. Replace all these with a call
to the same function.
2016-05-19 20:48:48 -04:00
Ryan Roden-Corrent
4dd1478d2c Use ', '.join instead of str.join(', ', ...). 2016-05-18 08:55:17 -04:00
Ryan Roden-Corrent
0a0f0feaec Update command completions when keyconf changes.
When a user changes keybindings, update the command completion model so
the new keybindings are shown.
2016-05-18 08:00:21 -04:00
Ryan Roden-Corrent
c050b4973b Show special keys last in command completion.
When showing the currently bound key in the misc column for command
completion, if the command has multiple bindings, show special bindings
(e.g. <ctrl-a>) after non-special bindings.
2016-05-18 07:54:06 -04:00
Ryan Roden-Corrent
06caee41b8 Clean up command_binding_completion.
- Add a space after the comman for multiple binding suggestions.
- Use defaultdict(list) instead of defaultdict(lambda: [])
- Move the pylint comment back to the top of the class
2016-05-18 07:46:27 -04:00
Ryan Roden-Corrent
52641e25f5 Show currently bound keys in command completion.
The command completion menu now uses the misc colum to show a
comma-separated list of normal-mode keybindings for each command.
2016-05-17 20:25:09 -04:00
Jimmy
1524f29f71 Add titles to history entry.
Adds a title to the HistoryEntry class and includes it in the serialization
stuff. Not currently set from anywhere.

Not sure if anything more needs to be done to support non-ascii characters.
Everything works fine for me with unicode chars in url and title but
everything in my stack is utf-8.
2016-05-17 17:15:22 +12:00
Florian Bruhin
24d16dd0a7 Merge branch 'show_binding2' of https://github.com/rcorre/qutebrowser into rcorre-show_binding2 2016-05-10 23:39:32 +02:00
Florian Bruhin
e4e98c6c23 Delete QTextDocument properly in completion.
The CompletionItemDelegate gets reused by Qt for various items in the
completion. Every time _get_textdoc() was called we created a new
QTextDocument, but since it has a long-living parent set (the delegate)
the old one was never actually garbage collected.

We now explicitly delete the old QTextDocument as it's not needed
anymore by either Qt or Python.

See #1476.
2016-05-09 09:11:14 +02:00
Ryan Roden-Corrent
b8a593cac5 Show command completions for :bind.
All commands will be offered as completions for the <command> argument
of :bind.

Due to the way completers parse the command line, the following

bind --mode caret j

will throw off completions as 'caret' is treated as a positional arg in
terms of the argument count for completions.
In the above example, completion will be triggered for 'j' and no
completions will be given for the actual command.

bind --mode=caret j will complete correctly, though completions are not
filtered by the given mode.
I attempted an approach to filter the commands based on the mode but it
ended up being messy and flaky.
2016-05-03 23:29:34 -04:00
Florian Bruhin
2f10ab4e9a Clean up coding style 2016-04-28 07:07:49 +02:00
Florian Bruhin
15a145cf92 Merge branch 'buffer_completion_delete_item-1443' of https://github.com/toofar/qutebrowser into toofar-buffer_completion_delete_item-1443
Merge conflict in qutebrowser/completion/models/miscmodels.py due to a simple
style fix in the old code.
2016-04-28 07:03:27 +02:00
Florian Bruhin
2a343cb3a1 Various code style improvements 2016-04-27 20:25:27 +02:00
Florian Bruhin
48b069e89c Remove @pyqtSlot for on_new_window
This worked fine with Python 3.5 but causes a circular import which is
hard to break with Python 3.4.

The original solution was to do @pyqtSlot(object), but that doesn't work
with PyQt 5.6 anymore...
2016-04-26 22:16:04 +02:00
Florian Bruhin
37b5f49c85 Fix types in @pyqtSlot decorations
PyQt 5.5 enforces correct type signatures, and there were a lot of
places where we were simply wrong, causing qutebrowser to not start at
all...
2016-04-26 20:34:38 +02:00
Jimmy
32edd35c7a buffer completion: handle deleting items see issue #1443
Allows to use ctrl+d to close tabs from the buffer completion widget
when they are selected. Respects current tab settings like whether you
can close the last tab in a window.

Had to change the `rebuild()` method to use `setData()` when possible
because the selection was being lost if the whole model was being rebuilt.

Current problems are:

1) When opening a new window while you already the tab completion open on
   one window a category is added for the new window but new rows in
   that category aren't picked up. Interesting if you open a third
   window then close the second window the completion display is now
   correct... I can see that the model is being updated correctly but I
   am not sure why that isn't propagating to the view. Not sure whether
   it is worth looking into (further) either.

2) Bit of duplication of code, it iterates over the window registry
   twice. Could put everything in one loop but then that would be
   dependant on the current behaviour of the `tab_closed` signal being
   called with the relevant `tabbed_browser` still existing but with the
   `shutting_down` flag set.

3) I'm still using just the one `rebuild()` method and removing items from
   the end then calling `setData` on everything rather than having special
   `on_tab/window_closed` methods (or partial functions) that delete the
   actual corresponding item. Because if I did that I would also have to
   special case tab moves etc.
2016-04-23 02:55:53 +12:00
Florian Bruhin
642dc46ba9 flake8: Add hacking 2016-04-08 07:35:53 +02:00
Jimmy
1c10a1aecf Adds new buffer command with completion.
`buffer` takes either a tab index or a string and focuses the specified
tab. The index can be of the form [0-9]+ which will switch to the
relevant tab in the current window or [0-9]+/[0-9]+ (that is
win_id/index) which will focus the specified window before switching
tabs. If a string is passed the list of open tabs across all windows is
sorted based on title and url (just like in the completion widget) and
the top result is selected.
2016-03-31 14:00:36 +13:00
Tomasz Kramkowski
399aaa2b70 history: Add clear() method and history-clear command
WebHistory now has a clear() method which is also a command
(history-clear) which clears the qutebrowser history using the new
lineparser clear() method and emits a cleared signal.

The completion model urlmodel connects to the WebHistory.cleared signal
and clears its history category completion list.

I am adding this as a temporary fix before #58 or #1051 get implemented.
2016-01-23 22:36:24 +00:00
Florian Bruhin
fc3c928326 Merge branch 'autocompletion_enhancement' of https://github.com/tex/qutebrowser into tex-autocompletion_enhancement 2016-01-20 20:04:53 +01:00
Milan Svoboda
20cdb45da5 use greedy highlighting 2016-01-06 21:52:56 +01:00
Milan Svoboda
ec8dc35a68 rename patternre, use ignorecase in re instead of casefold 2016-01-06 07:38:55 +01:00
Florian Bruhin
a5f2ac5f03 Adjust copyright years. 2016-01-04 07:12:39 +01:00
Milan Svoboda
382f7c6bf1 fix lint 2015-12-30 16:15:17 +01:00