Implement :download-clear command.

Fixes #1013.
This commit is contained in:
Panagiotis Ktistakis 2015-11-03 20:27:02 +02:00
parent 17396e1030
commit 7dadd97f01
3 changed files with 13 additions and 3 deletions

View File

@ -14,6 +14,7 @@
|<<close,close>>|Close the current window.
|<<download,download>>|Download a given URL, or current page if no URL given.
|<<download-cancel,download-cancel>>|Cancel the last/[count]th download.
|<<download-clear,download-clear>>|Remove all finished downloads from the list.
|<<download-delete,download-delete>>|Delete the last/[count]th download from disk.
|<<download-open,download-open>>|Open the last/[count]th download.
|<<download-remove,download-remove>>|Remove the last/[count]th download from the list.
@ -158,6 +159,10 @@ Cancel the last/[count]th download.
==== count
The index of the download to cancel.
[[download-clear]]
=== download-clear
Remove all finished downloads from the list.
[[download-delete]]
=== download-delete
Delete the last/[count]th download from disk.

View File

@ -964,6 +964,12 @@ class DownloadManager(QAbstractListModel):
"""Check if there are finished downloads to clear."""
return any(download.done for download in self.downloads)
@cmdutils.register(instance='download-manager', scope='window')
def download_clear(self):
"""Remove all finished downloads from the list."""
finished_items = [d for d in self.downloads if d.done]
self.remove_items(finished_items)
@cmdutils.register(instance='download-manager', scope='window',
count='count')
def download_remove(self, all_=False, count=0):
@ -974,8 +980,7 @@ class DownloadManager(QAbstractListModel):
count: The index of the download to cancel.
"""
if all_:
finished_items = [d for d in self.downloads if d.done]
self.remove_items(finished_items)
self.download_clear()
else:
try:
download = self.downloads[count - 1]

View File

@ -1373,7 +1373,7 @@ KEY_DATA = collections.OrderedDict([
('inspector', ['wi']),
('download', ['gd']),
('download-cancel', ['ad']),
('download-remove --all', ['cd']),
('download-clear', ['cd']),
('view-source', ['gf']),
('tab-focus last', ['<Ctrl-Tab>']),
('enter-mode passthrough', ['<Ctrl-V>']),