Commit Graph

380 Commits

Author SHA1 Message Date
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
Milan Svoboda
ed032ea107 fix lint 2015-12-30 15:54:50 +01:00
Milan Svoboda
4caffccca6 fix lint, highlight properly 2015-12-30 15:32:40 +01:00
Milan Svoboda
1f3a8a60d8 escape search string, explicit boolean test 2015-12-26 23:44:03 +01:00
Milan Svoboda
a652688566 fix lint errors 2015-12-26 18:04:01 +01:00
Milan Svoboda
013df51fd2 fix lint errors 2015-12-26 17:44:30 +01:00
Milan Svoboda
f64a3451fa fix lint errors 2015-12-26 17:15:46 +01:00
Milan Svoboda
8914404d59 allow to narrow down search by adding more words separated with space 2015-12-26 16:27:53 +01:00
Florian Bruhin
ad72b26b1a Add comment why abstract-method is ignored. 2015-12-01 22:16:23 +01:00
Florian Bruhin
307fe6b109 Avoid shadowing 'model'. 2015-11-30 07:03:49 +01:00
Florian Bruhin
a4f47150b4 Simplify unneeded if. 2015-11-30 07:00:51 +01:00
Florian Bruhin
1da7996c3b Style fixes. 2015-11-13 22:27:41 +01:00
Florian Bruhin
9f11990efc Rename scrollbar.padding/scrollbar.width. 2015-10-19 05:15:52 +02:00
Nathan Isom
d326cc050e correct style string, file modeline. 2015-10-18 14:11:22 -05:00
Nathan Isom
ec3cafc293 resolve merge conflicts and merge branch scrollbar. 2015-10-18 11:42:56 -05:00
Nathan Isom
9b5c0075b9 Move min-height to correctly fix bug, edit colors to match https://github.com/The-Compiler/qutebrowser/pull/1021. 2015-10-17 19:31:47 -05:00
Nathan Isom
6391da4f6f Forgot font changes. 2015-10-16 12:02:57 -05:00
Nathan Isom
2a11adc8ac initial replace pass. 2015-10-16 10:52:02 -05:00
Nathan Isom
27db1ad891 fix scrollbar not showing up error, change test_get_stylesheet a bit. 2015-10-16 09:56:31 -05:00
Nathan Isom
57d8ebfb83 not hardcode width/padding values. 2015-10-15 14:06:16 -05:00
Nathan Isom
19c27a04e5 Add completion scrollbar settings. 2015-10-15 13:18:32 -05:00
Antoni Boucher
1acd32f697 Fixed issue #1008. 2015-10-10 11:16:06 -04:00
Florian Bruhin
d229e90724 Fix some splelling mistakes. 2015-10-04 15:41:42 +02:00
Florian Bruhin
739d2cfffd Fix displaying of web history if limited to -1.
This is a regression introduced in 2aa7e5bb35.
Fixes #991.
2015-10-02 22:56:18 +02:00
Antoni Boucher
f0a2128499 Fixed style. 2015-09-12 18:01:04 -04:00
Antoni Boucher
2aa7e5bb35 Fixed issue #934. 2015-09-12 17:48:36 -04:00
Florian Bruhin
ef9e1bef1b Improve performance when adding new history item.
Fixes #919.

There were two issues here:

- CompletionWidget didn't delete the old model when setting a new one. This
  means filterAcceptsRow was called for models which aren't even used anymore.

- setChild was used instead of appendRow for the BaseCompletionModel, which
  caused Qt to call filterAcceptsRow once for every item of the completion
  model instead of only once.
2015-09-06 16:59:43 +02:00
Thorsten Wißmann
830136540d Hide the border of the completionwidget
Having a light Qt theme but a dark qutebrowser theme, one can see an
ugly white border around the completion widget which is some relict from
the underlying Qt widget QTreeView. As qutebrowser has its own theming
settings for the mainwindow, it should hide the Qt theme as far as
possible.
2015-08-25 11:01:25 +02:00
Florian Bruhin
4577659342 Fix crash when there's no completion. 2015-08-24 00:08:55 +02:00
Florian Bruhin
fc6c49f57c Cleanup 2015-08-22 22:59:41 +02:00
Alexander Cogneau
7ed4977d64 Change parent of filter models 2015-08-21 16:56:36 +02:00
Alexander Cogneau
729c10e0a9 Fix PEP issue 2015-08-21 16:23:28 +02:00
Alexander Cogneau
387c84beff Completion model filters are now per-window (via completer.py) 2015-08-21 16:05:33 +02:00
Alexander Cogneau
8be433f5f6 Add tests:
- sum of column widths equals 100
- column widths tuple has 3 elements
2015-08-11 09:17:46 +02:00
Alexander Cogneau
753f87aa15 Default size of third column is now 0 2015-08-08 23:49:54 +02:00
Alexander Cogneau
e29c642bc2 Fix wrong propertyname 2015-08-08 18:12:51 +02:00
Alexander Cogneau
f2c3cc6a3e Module import of completion.models instead of class. 2015-08-08 17:58:12 +02:00
Alexander Cogneau
0e9f268817 CompletionView:
- column_widths -> _column_widths
- removed if-statement to verify if source model has 'column_widths'-property
2015-08-08 17:47:18 +02:00
Alexander Cogneau
36372418ca Added the default column_widths as a class attribute instead of a config option. 2015-08-08 17:27:21 +02:00
Alexander Cogneau
5c2d3ec96a Add a column_widths property to the base class for completion models. 2015-08-08 16:46:57 +02:00
Florian Bruhin
5a25f0b98b Don't crash on :completion-item-del with no item.
If :completion-item-del was invoked with no item selected (e.g. directly after
pressing 'o'), there was a crash because the currentIndex was invalid.

/cc @antoyo (but I believe one of my changes on top of yours caused this)
2015-08-05 06:55:39 +02:00
Florian Bruhin
cc66feac09 Handle invalid history timestamps. 2015-08-01 00:57:34 +02:00
Florian Bruhin
57e79db136 Fix undefined name error. 2015-07-29 15:04:07 +02:00
Florian Bruhin
d9d68db5df Simplify delete_cur_item for UrlCompletionModel. 2015-07-29 12:44:38 +02:00
Florian Bruhin
08fe1d59e6 Get rid of bookmark_by_title completion. 2015-07-29 12:36:45 +02:00
Florian Bruhin
69ade32cb9 Get rid of quickmark_by_name completion. 2015-07-29 12:35:43 +02:00
Florian Bruhin
b962fff7f1 Don't show message when deleting items. 2015-07-26 18:48:00 +02:00
Florian Bruhin
ecf3e166ff Fix wrong column attribute. 2015-07-26 18:47:02 +02:00
Florian Bruhin
660b5531e5 Share code between on_{quick,book}mark_removed. 2015-07-26 18:43:01 +02:00
Florian Bruhin
b5a9467b5c Get rid of _add_*mark_entry in urlmodel. 2015-07-26 18:35:49 +02:00
Florian Bruhin
2d2779d6f3 Clean up column handling in urlmodel. 2015-07-26 18:23:12 +02:00
Florian Bruhin
aaa523ce7c Filter by cols_to_filter in CompletionFilterModel. 2015-07-26 17:41:32 +02:00
Florian Bruhin
3b0125e8cd Rename cols_to_highlight to _filter and simplify. 2015-07-26 17:22:45 +02:00
Florian Bruhin
c7f88c93b2 Style fix. 2015-07-26 17:11:34 +02:00
Florian Bruhin
2f11b41ae6 Merge bookmarks and quickmarks into urlmarks. 2015-07-26 16:37:10 +02:00
Antoni Boucher
91561e2c5b Fixed style. 2015-07-12 20:46:40 -04:00
Antoni Boucher
5bca951c21 Removed casefold() function call when using a custom filter. 2015-07-12 20:29:40 -04:00
Antoni Boucher
1b24cfd618 Removed useless bookmark by title model. 2015-07-12 20:21:49 -04:00
Antoni Boucher
d4c91f7b0c Fixed completion highlighting. 2015-07-12 20:18:32 -04:00
Antoni Boucher
96a2178a25 Renamed bookmark_del to delete in bookmark manager. 2015-07-11 19:23:21 -04:00
Antoni Boucher
8159c5f567 Fixed last merge. 2015-07-11 18:56:19 -04:00
Antoni Boucher
fe829699be Merge remote-tracking branch 'upstream/master' 2015-07-11 17:40:43 -04:00
Florian Bruhin
7b8490b6c0 Fix 'an user' spelling. 2015-06-29 17:49:19 +02:00
Florian Bruhin
bf4e968c67 Add new completion -> auto-open option.
Closes #557.
2015-06-27 19:55:04 +02:00
Florian Bruhin
c64d9520ff Fix lint.
Thanks to @Carpetsmoker for spotting this in #705.
2015-06-18 08:10:14 +02:00
Florian Bruhin
dfe98d1053 completion: Fix initial _cursor_part value.
Fixes #749.
2015-06-16 13:22:55 +02:00
Florian Bruhin
a545b919f7 Do history loading after qutebrowser has started. 2015-06-16 07:06:56 +02:00
Florian Bruhin
f17131f6c2 Change Qt links to point to qt.io. 2015-06-12 16:59:33 +02:00
Antoni Boucher
57a72a7120 Refactored bookmark removal to use a command. 2015-06-07 19:36:19 -04:00
Antoni Boucher
cf4b89efe3 Merge remote-tracking branch 'upstream/master' 2015-06-07 14:38:17 -04:00
Florian Bruhin
622938e3d3 Fix completion performance with shrink=True.
Before, the completion was shrinked every time any item was removed/added to
the completion (rowsRemoved/rowsInserted signals), which was >3000 times when
completing history.

Also, the signals got connected multiple times if setting the same model, which
made the situation worse.

Fixes #734.
2015-06-05 07:16:33 +02:00
Antoni Boucher
8b14145a4d Fixed style. 2015-06-03 19:31:31 -04:00
Antoni Boucher
f1874ff44f Added possibility to remove bookmarks and quickmarks. 2015-06-01 20:00:21 -04:00
Antoni Boucher
5085844550 Added highlighting for completion in name column. 2015-06-01 17:55:09 -04:00
Antoni Boucher
e92c493b07 Fixed bug making the application crash. 2015-05-30 12:37:21 -04:00
Antoni Boucher
cbc4ec6531 Added filter bookmarks by name as well as url. 2015-05-28 19:55:29 -04:00
Antoni Boucher
ece32e930c Added bookmarks command. 2015-05-24 19:18:40 -04:00
Antoni Boucher
0ee7e40e69 Fixed broken quickmarks completion. 2015-05-23 15:57:52 -04:00
Antoni Boucher
2c0c2e220e Fixed style issue. 2015-05-21 19:38:30 -04:00
Antoni Boucher
28caf45707 First version of bookmarks. 2015-05-21 18:17:22 -04:00
Florian Bruhin
8eb483d66b Set Qt.ItemNeverHasChildren for leaf model items.
This allows Qt to do some optimizations.
2015-05-18 21:35:14 +02:00
Florian Bruhin
f85ba8645f Handle a missing session folder at some places. 2015-04-13 08:38:12 +02:00
Florian Bruhin
e24b06cdf9 Refactor and fix split commands in CommandRunner.
- split() now returns a ParseResult namedtuple with (cmd, args, cmdline)
  arguments instead of only returning cmdline and setting self._cmd/self._args.

- Handling of split commands (;;) is now done in a separate parse_all()
  function instead of run() to make testing easier.

See #615.
2015-04-13 07:38:25 +02:00
Florian Bruhin
2876ba5cfa Pass a parent to global QObjects. 2015-04-06 00:10:37 +02:00
Florian Bruhin
a504bd1436 Don't quote completions for maxsplit-commands.
Fixes #564.
Obsoletes #313 and #453.
2015-04-03 19:03:30 +02:00
Florian Bruhin
214347497a Fix handling of first :completion-item-prev call.
Before, the first item was unconditionally selected when none was selected
before. With :completion-item-prev (e.g. Shift-Tab), it makes more sense to
select the *last* one.
2015-04-02 07:41:56 +02:00
Florian Bruhin
37ab5296a7 Adjust URL completion when quickmarks are changed.
Fixes #590.
2015-04-02 07:40:00 +02:00
Florian Bruhin
068e1c14b6 Don't display internal sessions in completion. 2015-04-01 22:32:41 +02:00
Florian Bruhin
8ebac8d38c Various spelling fixes. 2015-03-31 21:11:47 +02:00
Florian Bruhin
94bc10405a Merge branch 'histcomplete' 2015-03-17 06:16:26 +01:00
Florian Bruhin
59bbca9b40 Fix updating of existing items in hist-completion.
Before we limited the history items we could simply call WebHistory's
historyContains before iterating through all items in the history completion.

Now however it's possible an item is in the real WebHistory, but not actually
in the completion - so we always have to check the whole completion.
2015-03-16 09:20:09 +01:00
Florian Bruhin
3df5e13c65 Fix exception in filtermodel if model has no items. 2015-03-16 07:42:21 +01:00
Florian Bruhin
503060881a Compare history items based on QUrl. 2015-03-16 07:42:10 +01:00
Florian Bruhin
693ea0c312 Cleanup 2015-03-16 07:10:06 +01:00
Florian Bruhin
553d8cf986 Also save the QUrl in a HistoryEntry.
We also use QUrl::toDisplayString for the completion so things like spaces or
umlauts are decoded properly.
2015-03-16 07:03:30 +01:00
Florian Bruhin
001bf982e5 Alternate row colors in completion. 2015-03-15 23:16:57 +01:00
Florian Bruhin
d266665955 Fix adding of URLs to history completion.
Before, the item_added signal was emitted *after* an item was added, which
means the on_history_item_added slot always assumed the item already is in the
history.
2015-03-15 21:16:45 +01:00
Florian Bruhin
9512a52d21 completion: Don't unnecessarily expand all items.
Instead of calling expandAll() and iterating through all items, we can just
force the top-level items to be expanded.
2015-03-14 22:51:53 +01:00
Florian Bruhin
cdbb118238 Also measure the time it takes to set the pattern. 2015-03-14 13:35:32 +01:00
Florian Bruhin
70cd8e74eb Measure time it takes to init URL completion. 2015-03-14 13:32:47 +01:00
Florian Bruhin
833830d5e9 Limit the count of history items in the completion. 2015-03-13 19:50:08 +01:00
Florian Bruhin
96da7d9fe6 Fix lint. 2015-03-13 16:26:27 +01:00
Florian Bruhin
74892ac8e4 Initialize completions lazily and only once.
Before, we initialized the completions once for every window spawned, which was
a waste of CPU-time and RAM.

Now we only initialize them once, when the user uses the completion for the
first time.
2015-03-13 16:25:13 +01:00
Florian Bruhin
389feab1df Make sure args are not int in new_item().
Otherwise we would construct a QStandardItem with the
QStandardItem(int rows, int columns = 1) constructor, which will most likely
not do what we want.
2015-03-12 15:35:53 +01:00
Florian Bruhin
dbd121a079 Set data of existing item. 2015-03-12 15:34:32 +01:00
Florian Bruhin
97dd86735a Improve types of history model values.
- HistoryItem.atime now always should be an int/float.
- The data for the sort role should also be an int, not a string.
  A float would also work, but maybe be slower for no real benefit.
2015-03-12 15:34:32 +01:00
Florian Bruhin
8023b1456d Make it possible to configure the timestamp format. 2015-03-12 15:25:39 +01:00
Florian Bruhin
7a28b6c821 Fix lint. 2015-03-12 14:55:54 +01:00
Jimmy
1efe18ecc6 Prevent duplicates in history completion.
Two things here. One is to use `WebHistory._new_history` only as a to-save
queue, so we now add entries to `_old_urls` when they are first created and
can now no longer iterate of `_new_history` in `__iter__()`.

Second is to stop blindly tacking new history entries on the end of the
history completion model. It does involve iterating over the model to find the
existing entry but we only do that if we know the duplicate is there, which is
fast to check.

This also ads another point of mutation to the history completion model which
may prove problematic if it leads to more segfaults.
2015-03-12 20:15:03 +13:00
Florian Bruhin
0b975db4dd Refactor how completions are organized. 2015-03-11 23:07:58 +01:00
Florian Bruhin
34b24aafa8 Fix lint 2015-03-11 22:22:49 +01:00
Florian Bruhin
fe4f32606d Use CompletionFilterModel's sort implementation. 2015-03-11 21:50:16 +01:00
Jimmy
834832e3ba Web history changed signal now emits the new entry.
Each new HistoryEntry is emitted after being added to the global history
store. Current members of the HistoryEntry are `url` and `atime`. `title`
should be coming soon.
2015-03-11 21:50:16 +01:00
Jimmy
59948a038c Add new UrlCompletion model which includes web history and quickmarks.
I went to some effort to avoid duplipcating code which which leads to some
arguably ugly class method calling.
2015-03-11 21:50:16 +01:00
Jimmy
f6a7ef3985 Add url history completion for open.
Adds a basic completion model implementation around the global browser
history and registers that for the open command.

Modifies WebHistory to add an __iter__ method and to use a dict instead of a
set to store an entire HistoryEntry for each archived item instead of just the
URL. Brief tests showed that the lookup time for set and dict are very
similar. They are at least on the same order of magnitude. Testing membership
of a list on the other hand, as was the case before a set was used, was four
orders of magnitude slower on my machine.
2015-03-11 21:50:16 +01:00
Florian Bruhin
0f5391c4fa Scroll completion to top when showing it.
See #531.
2015-03-11 07:50:51 +01:00
Florian Bruhin
1b879faf84 completion: Highlight text case-insensitively.
See #531.
2015-03-11 07:50:45 +01:00
Florian Bruhin
5b4f6d39c2 Add a dumb sorting option to CompletionFilterModel.
This makes it possible to use Qt's QSortFilterProxyModel::lessThan option for
completions where it doesn't make sense to priorize matches starting with the
entered string, e.g. for URLs. In return, we get a *much* better performance
(several seconds when opening the completion).

See #531.
2015-03-11 07:50:33 +01:00
Florian Bruhin
3d5012ccca Rename 'Allowed' header for value completions. 2015-02-19 07:10:40 +01:00
Florian Bruhin
8f1d81a644 Add session support.
Closes #12.
See #499.
See #11.

This adds PyYAML as a new dependency.

It adds the following new commands:

    :session-delete <name>
    Delete a session.

    :session-load <name>
    Load a session.

    :session-save [<name>]
    Save a session.

    :wq [<name>]
    Save open pages and quit.

And the following new settings:

    general -> save-session:
    Whether to always save the open pages.
2015-02-16 20:26:09 +01:00
Florian Bruhin
66ec4f0599 Resize completion when it's shown, and only then.
Before this, we always resized the completion when the mainwindow was resized.
If the statusbar is hidden during the resize (ui -> hide-statusbar is true), we
got an invalid calculated QRect for the completion, causing the update to be
not applied at all - so the completion showed up incorrectly.

With this change, another resize is done when the completion is shown - at this
point it's certain the statusbar is visible. Also we only update it while it's
shown - it doesn't make sense to always adjust its size when it's hidden
anyways.
2015-01-28 22:16:22 +01:00
Peter Vilim
c30978be2f Add quotes for empty default value 2015-01-19 13:17:17 -06:00
Florian Bruhin
a32f1e6180 Make it possible to deprecate commands.
See #448.
2015-01-15 22:29:00 +01:00
Peter Vilim
14afb3ef14 show-default-value: update heading 2015-01-08 12:52:21 -06:00
Peter Vilim
eba4b58a7c Show default config value in completion 2015-01-07 18:16:59 -06:00
Florian Bruhin
450d1ab70d Update copyright years 2015-01-03 15:51:31 +01:00
Florian Bruhin
b703028411 Clean up and temporarily disable alias completion.
Fixes #358.
2014-12-28 22:08:38 +01:00
Florian Bruhin
be2c67aa19 Don't filter completion parts if there's only one.
This fixes a regression (completion not showing with :) introduced in
b1501a691d.
2014-12-27 22:50:28 +01:00
Florian Bruhin
b1501a691d Ignore empty parts when calculating cursor part.
Fixes #389.
2014-12-26 16:57:08 +01:00
Florian Bruhin
512d7c4448 Simplify config exception tree and handling.
Also make sure we catch all config-related errors in all related places.
Fixes #324.
2014-12-17 11:17:18 +01:00
Florian Bruhin
06ec1a3885 Big file tree reorganisation.
Closes #255.
Should make a lot more sense now ;)
2014-12-13 17:28:50 +01:00