Bug 113497

Summary: JJ: Konqueror cookie settings delete ALL cookies, even if filter is used
Product: [Applications] konqueror Reporter: Jens <jens-bugs.kde.org>
Component: kcookiejarAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: lex.lists, mueller, richih-kde
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Patch for KDE bug #113497
Improved patch for KDE bug #113497

Description Jens 2005-09-28 13:35:57 UTC
Version:            (using KDE 3.4.2 Level "b" , SUSE 10.0)
Compiler:          Target: i586-suse-linux
OS:                Linux (i686) release 2.6.13-9-default

In Konq's settings page for cookies there is a button "Delete All".

If you use the search bar above the cookie list, the "Delete All" should only delete "all" DISPLAYED cookies, not also the ones that have been filtered out. Konqueror currently deletes really *all* cookies. This is ambiguous at best.

Thank you,

Jens
Comment 1 lexual 2005-10-31 09:46:14 UTC
I agree this needs fixing.

perhaps the button could be changed to "Delete All..." and then make you confirm that you REALLY want to delete ALL cookies.
Comment 2 Michael 2006-01-22 21:47:43 UTC
I just lost all my cookies because of this bug. This is certainly not the behaviour I expected.
Comment 3 Philip Rodrigues 2006-08-09 21:38:13 UTC
Almost certainly the same thing as in bug 122158: need to iterate over only the visible items in the delete list.
Comment 4 Philip Rodrigues 2006-11-19 23:20:29 UTC
Makes a nice Junior Job...
Comment 5 Thomas Fischer 2007-02-11 13:35:07 UTC
Created attachment 19618 [details]
Patch for KDE bug #113497

This is a patch that modifies the "delete all" behaviour for both cookie policy
and cookie management so that only visible (filtered) list items will be
deleted.
Comment 6 Philip Rodrigues 2007-02-11 15:11:50 UTC
Thomas, you might want to also send the patch to the kde-core-devel@kde.org mailing list - there are more people reading that list than this bug, so someone there should be able to review and commit it for you :-)
Comment 7 Thomas Fischer 2007-02-12 23:41:24 UTC
Created attachment 19652 [details]
Improved patch for KDE bug #113497

Created new patch based on comments by John Tapsell. It should work better by
now.
Comment 8 Dawit Alemayehu 2007-09-03 07:28:36 UTC
SVN commit 707822 by adawit:

When delete all is pressed, only delete the visible cookies if the view is filtered.

BUG:113497


 M  +44 -13    kcookiesmanagement.cpp  
 M  +4 -1      kcookiesmanagement.h  


--- branches/KDE/3.5/kdebase/kcontrol/kio/kcookiesmanagement.cpp #707821:707822
@@ -152,7 +152,6 @@
       KMessageBox::sorry (this, caption, message);
       return;
     }
-    
     m_bDeleteAll = false; // deleted[Cookies|Domains] have been cleared yet    
   }
 
@@ -215,11 +214,8 @@
   emit changed (false);
 }
 
-void KCookiesManagement::reset(bool deleteAll)
+void KCookiesManagement::reset()
 {
-  if ( !deleteAll )
-    m_bDeleteAll = false;
-  
   clearCookieDetails();
   dlg->lvCookies->clear();
   deletedDomains.clear();
@@ -405,10 +401,9 @@
 }
 
 
-void KCookiesManagement::deleteCookie()
+void KCookiesManagement::deleteCookie(QListViewItem* deleteItem)
 {
-  QListViewItem* currentItem = dlg->lvCookies->currentItem();
-  CookieListViewItem *item = static_cast<CookieListViewItem*>( currentItem );
+  CookieListViewItem *item = static_cast<CookieListViewItem*>( deleteItem );
   if( item->cookie() )
   {
     CookieListViewItem *parent = static_cast<CookieListViewItem*>(item->parent());
@@ -419,8 +414,10 @@
       list->setAutoDelete(true);
       deletedCookies.insert(parent->domain(), list);
     }
+
     list->append(item->leaveCookie());
     delete item;
+
     if(parent->childCount() == 0)
       delete parent;
   }
@@ -429,8 +426,14 @@
     deletedDomains.append(item->domain());
     delete item;
   }
+}
 
-  currentItem = dlg->lvCookies->currentItem();
+void KCookiesManagement::deleteCookie()
+{
+  deleteCookie(dlg->lvCookies->currentItem());
+
+  QListViewItem* currentItem = dlg->lvCookies->currentItem();
+
   if ( currentItem )
   {
     dlg->lvCookies->setSelected( currentItem, true );
@@ -439,18 +442,46 @@
   else
     clearCookieDetails();
 
-  dlg->pbDelete->setEnabled(dlg->lvCookies->selectedItem());
   dlg->pbDeleteAll->setEnabled(dlg->lvCookies->childCount());
-  dlg->pbPolicy->setEnabled(dlg->lvCookies->selectedItem());
 
+  const bool hasSelectedItem = dlg->lvCookies->selectedItem();
+  dlg->pbDelete->setEnabled(hasSelectedItem);
+  dlg->pbPolicy->setEnabled(hasSelectedItem);
+
   emit changed( true );
 }
 
 void KCookiesManagement::deleteAllCookies()
 {
-  m_bDeleteAll = true;
-  reset(true);
+  if ( dlg->kListViewSearchLine->text().isEmpty())
+  {
+    reset();
+    m_bDeleteAll = true;
+  }
+  else
+  {
+    QListViewItem* item = dlg->lvCookies->firstChild();
 
+    while (item)
+    {
+      if (item->isVisible())
+      {
+        deleteCookie(item);
+        item = dlg->lvCookies->currentItem();
+      }
+      else
+        item = item->nextSibling();
+    }
+
+    const int count = dlg->lvCookies->childCount();
+    m_bDeleteAll = (count == 0);
+    dlg->pbDeleteAll->setEnabled(count);
+
+    const bool hasSelectedItem = dlg->lvCookies->selectedItem();
+    dlg->pbDelete->setEnabled(hasSelectedItem);
+    dlg->pbPolicy->setEnabled(hasSelectedItem);
+  }
+
   emit changed( true );
 }
 
--- branches/KDE/3.5/kdebase/kcontrol/kio/kcookiesmanagement.h #707821:707822
@@ -81,10 +81,13 @@
     void doPolicy();
 
 private:
-    void reset (bool deleteAll = false);
+    void reset ();
+    void deleteCookie(QListViewItem*);
     bool cookieDetails(CookieProp *cookie);
     void clearCookieDetails();
     bool policyenabled();
+
+private:
     bool m_bDeleteAll;
 
     QWidget* mainWidget;
Comment 9 Dominik Tritscher 2008-08-03 20:27:29 UTC
*** Bug 144055 has been marked as a duplicate of this bug. ***