From e0271eff34b115ae9c513cd1a11df1c30aa1ef01 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 16 Dec 2014 14:02:01 +0100 Subject: [PATCH] Open and remove clicked downloads. Fixes #343. --- qutebrowser/browser/downloadview.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qutebrowser/browser/downloadview.py b/qutebrowser/browser/downloadview.py index d595fd740..a25ddf0f9 100644 --- a/qutebrowser/browser/downloadview.py +++ b/qutebrowser/browser/downloadview.py @@ -93,6 +93,7 @@ class DownloadView(QListView): self.setWrapping(True) self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.show_context_menu) + self.clicked.connect(self.on_clicked) def __repr__(self): model = self.model() @@ -102,6 +103,20 @@ class DownloadView(QListView): count = model.rowCount() return utils.get_repr(self, count=count) + @pyqtSlot('QModelIndex') + def on_clicked(self, index): + """Handle clicking of an item. + + Args: + index: The QModelIndex of the clicked item. + """ + if not index.isValid(): + return + item = self.model().data(index, downloads.ModelRole.item) + if item.done: + item.open_file() + self.model().remove_item(item) + @pyqtSlot('QPoint') def show_context_menu(self, point): """Show the context menu."""