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.
`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.
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.
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.
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.
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.
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.
Otherwise we would construct a QStandardItem with the
QStandardItem(int rows, int columns = 1) constructor, which will most likely
not do what we want.
- 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.
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.
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.
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.
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.
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.