From d8083dd985b1d43b2ff1e80f7e2a9eeb4914f2f0 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 28 May 2017 18:24:58 +0800 Subject: [PATCH 1/3] 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 + + From a585b02e764f7406170cbc4cff1b43313629c9f4 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 28 May 2017 21:34:22 +0800 Subject: [PATCH 2/3] Enable alternatingRowColors for "Manage Cookie" dialog Set editTriggers property to AllEditTriggers for easier editing. Now a single mouse click can initiate item editing instead of double clicking. --- src/gui/cookiesdialog.ui | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/cookiesdialog.ui b/src/gui/cookiesdialog.ui index cf63d5dc2..0f08a69d9 100644 --- a/src/gui/cookiesdialog.ui +++ b/src/gui/cookiesdialog.ui @@ -18,6 +18,12 @@ + + QAbstractItemView::AllEditTriggers + + + true + QAbstractItemView::ExtendedSelection From 1ac7d779a74b4349a44865402cb1b29867427e4b Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 29 May 2017 00:22:59 +0800 Subject: [PATCH 3/3] Set expiration date for newly added cookie to +2 years from now, instead of +99 years. This fixes the ambiguity that users could assume the date was in the past, but in fact it's in the future. Ex. now date is 5/28/17, +99 years = 5/28/16, +2 years = 5/28/19 --- src/gui/cookiesmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/cookiesmodel.cpp b/src/gui/cookiesmodel.cpp index d3e08412b..7c283a66f 100644 --- a/src/gui/cookiesmodel.cpp +++ b/src/gui/cookiesmodel.cpp @@ -145,7 +145,7 @@ bool CookiesModel::insertRows(int row, int count, const QModelIndex &parent) if ((row < 0) || (row > m_cookies.size())) return false; QNetworkCookie newCookie; - newCookie.setExpirationDate(QDateTime::currentDateTime().addYears(99)); + newCookie.setExpirationDate(QDateTime::currentDateTime().addYears(2)); beginInsertRows(parent, row, row + count - 1); while (count-- > 0)