From d8083dd985b1d43b2ff1e80f7e2a9eeb4914f2f0 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 28 May 2017 18:24:58 +0800 Subject: [PATCH] Allow to select & delete multiple entries in "Manage Cookies" dialog --- src/gui/cookiesdialog.cpp | 15 ++++++++++++++- src/gui/cookiesdialog.ui | 6 +++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/gui/cookiesdialog.cpp b/src/gui/cookiesdialog.cpp index cec21f8f2..f030a52b6 100644 --- a/src/gui/cookiesdialog.cpp +++ b/src/gui/cookiesdialog.cpp @@ -28,6 +28,8 @@ #include "cookiesdialog.h" +#include + #include "base/settingsstorage.h" #include "base/net/downloadmanager.h" #include "guiiconprovider.h" @@ -85,5 +87,16 @@ void CookiesDialog::onButtonAddClicked() void CookiesDialog::onButtonDeleteClicked() { - m_cookiesModel->removeRow(m_ui->treeView->selectionModel()->currentIndex().row()); + QModelIndexList idxs = m_ui->treeView->selectionModel()->selectedRows(); + + // sort in descending order + std::sort(idxs.begin(), idxs.end(), + [](const QModelIndex &l, const QModelIndex &r) + { + return (l.row() > r.row()); + } + ); + + for (const QModelIndex &idx : idxs) + m_cookiesModel->removeRow(idx.row()); } diff --git a/src/gui/cookiesdialog.ui b/src/gui/cookiesdialog.ui index 631cbc999..cf63d5dc2 100644 --- a/src/gui/cookiesdialog.ui +++ b/src/gui/cookiesdialog.ui @@ -17,7 +17,11 @@ - + + + QAbstractItemView::ExtendedSelection + +