Merge branch 'toofar-buffer_completion_delete_item-1443'
This commit is contained in:
commit
c39800675e
@ -36,6 +36,8 @@ Changed
|
||||
the right.
|
||||
- `:yank` can now yank the pretty/decoded URL by adding `--pretty`
|
||||
- `:navigate` now clears the URL fragment
|
||||
- `:completion-item-del` (`Ctrl-D`) can now be used in `:buffer` completion to
|
||||
close a tab
|
||||
|
||||
Fixed
|
||||
~~~~~
|
||||
|
@ -162,12 +162,12 @@ Contributors, sorted by the number of commits in descending order:
|
||||
* Kevin Velghe
|
||||
* Austin Anderson
|
||||
* Panagiotis Ktistakis
|
||||
* Jimmy
|
||||
* Alexey "Averrin" Nabrodov
|
||||
* avk
|
||||
* ZDarian
|
||||
* Milan Svoboda
|
||||
* John ShaggyTwoDope Jenkins
|
||||
* Jimmy
|
||||
* Peter Vilim
|
||||
* Clayton Craft
|
||||
* Oliver Caldwell
|
||||
|
@ -23,7 +23,7 @@ from PyQt5.QtCore import Qt, QTimer, pyqtSlot
|
||||
|
||||
from qutebrowser.browser import webview
|
||||
from qutebrowser.config import config, configdata
|
||||
from qutebrowser.utils import objreg, log
|
||||
from qutebrowser.utils import objreg, log, qtutils
|
||||
from qutebrowser.commands import cmdutils
|
||||
from qutebrowser.completion.models import base
|
||||
|
||||
@ -153,7 +153,7 @@ class TabCompletionModel(base.BaseCompletionModel):
|
||||
# https://github.com/The-Compiler/qutebrowser/issues/545
|
||||
# pylint: disable=abstract-method
|
||||
|
||||
#IDX_COLUMN = 0
|
||||
IDX_COLUMN = 0
|
||||
URL_COLUMN = 1
|
||||
TEXT_COLUMN = 2
|
||||
|
||||
@ -201,15 +201,56 @@ class TabCompletionModel(base.BaseCompletionModel):
|
||||
make sure we handled background loads too ... but iterating over a
|
||||
few/few dozen/few hundred tabs doesn't take very long at all.
|
||||
"""
|
||||
self.removeRows(0, self.rowCount())
|
||||
window_count = 0
|
||||
for win_id in objreg.window_registry:
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=win_id)
|
||||
if not tabbed_browser.shutting_down:
|
||||
window_count += 1
|
||||
|
||||
if window_count < self.rowCount():
|
||||
self.removeRows(window_count, self.rowCount() - window_count)
|
||||
|
||||
for i, win_id in enumerate(objreg.window_registry):
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=win_id)
|
||||
if tabbed_browser.shutting_down:
|
||||
continue
|
||||
c = self.new_category("{}".format(win_id))
|
||||
for i in range(tabbed_browser.count()):
|
||||
tab = tabbed_browser.widget(i)
|
||||
self.new_item(c, "{}/{}".format(win_id, i + 1),
|
||||
tab.url().toDisplayString(),
|
||||
tabbed_browser.page_title(i))
|
||||
if i >= self.rowCount():
|
||||
c = self.new_category("{}".format(win_id))
|
||||
else:
|
||||
c = self.item(i, 0)
|
||||
c.setData("{}".format(win_id), Qt.DisplayRole)
|
||||
if tabbed_browser.count() < c.rowCount():
|
||||
c.removeRows(tabbed_browser.count(),
|
||||
c.rowCount() - tabbed_browser.count())
|
||||
for idx in range(tabbed_browser.count()):
|
||||
tab = tabbed_browser.widget(idx)
|
||||
if idx >= c.rowCount():
|
||||
self.new_item(c, "{}/{}".format(win_id, idx + 1),
|
||||
tab.url().toDisplayString(),
|
||||
tabbed_browser.page_title(idx))
|
||||
else:
|
||||
c.child(idx, 0).setData("{}/{}".format(win_id, idx + 1),
|
||||
Qt.DisplayRole)
|
||||
c.child(idx, 1).setData(tab.url().toDisplayString(),
|
||||
Qt.DisplayRole)
|
||||
c.child(idx, 2).setData(tabbed_browser.page_title(idx),
|
||||
Qt.DisplayRole)
|
||||
|
||||
def delete_cur_item(self, completion):
|
||||
"""Delete the selected item.
|
||||
|
||||
Args:
|
||||
completion: The Completion object to use.
|
||||
"""
|
||||
index = completion.currentIndex()
|
||||
qtutils.ensure_valid(index)
|
||||
category = index.parent()
|
||||
qtutils.ensure_valid(category)
|
||||
index = category.child(index.row(), self.IDX_COLUMN)
|
||||
win_id, tab_index = index.data().split('/')
|
||||
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=int(win_id))
|
||||
tabbed_browser.on_tab_close_requested(int(tab_index) - 1)
|
||||
|
Loading…
Reference in New Issue
Block a user