1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

CookieManager: Add support for selecting more than one cookie at once

Summary:
When manually cleaning cookies, it is very convenient to be able to delete
a bunch of them at once, when we do not want to delete all cookies.

Reviewers: #falkon, drosca

Reviewed By: #falkon, drosca

Subscribers: falkon

Tags: #falkon

Differential Revision: https://phabricator.kde.org/D24967
This commit is contained in:
David Rosca 2019-10-31 10:15:07 +01:00
parent 8f2cf86117
commit 7b404e73a8
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
2 changed files with 25 additions and 12 deletions

View File

@ -119,22 +119,22 @@ void CookieManager::removeAll()
void CookieManager::remove()
{
QTreeWidgetItem* current = ui->cookieTree->currentItem();
if (!current) {
return;
}
QList<QNetworkCookie> cookies;
auto selection = ui->cookieTree->selectedItems();
if (current->childCount()) {
for (int i = 0; i < current->childCount(); ++i) {
QTreeWidgetItem *item = current->child(i);
if (item && m_itemHash.contains(item)) {
cookies.append(m_itemHash.value(item));
for (int i = 0; i < selection.count(); i++) {
QTreeWidgetItem* current = selection[i];
if (current->childCount()) {
for (int i = 0; i < current->childCount(); ++i) {
QTreeWidgetItem *item = current->child(i);
if (item && m_itemHash.contains(item)) {
cookies.append(m_itemHash.value(item));
}
}
} else if (m_itemHash.contains(current)) {
cookies.append(m_itemHash.value(current));
}
} else if (m_itemHash.contains(current)) {
cookies.append(m_itemHash.value(current));
}
foreach (const QNetworkCookie &cookie, cookies) {
@ -157,6 +157,16 @@ void CookieManager::currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem
ui->secure->setText(tr("<cookie not selected>"));
ui->expiration->setText(tr("<cookie not selected>"));
ui->removeOne->setText(tr("Remove cookies"));
return;
} else if (ui->cookieTree->selectedItems().count() > 1) {
ui->name->setText(tr("<multiple cookies selected>"));
ui->value->setText(tr("<multiple cookies selected>"));
ui->server->setText(tr("<multiple cookies selected>"));
ui->path->setText(tr("<multiple cookies selected>"));
ui->secure->setText(tr("<multiple cookies selected>"));
ui->expiration->setText(tr("<multiple cookies selected>"));
ui->removeOne->setText(tr("Remove cookies"));
return;
}

View File

@ -55,6 +55,9 @@
</item>
<item row="2" column="0" colspan="2">
<widget class="TreeWidget" name="cookieTree">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>