]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/windows/BrowserWindow.cpp
Change the cookie implementation to a QTreeView.
[PrivacyBrowserPC.git] / src / windows / BrowserWindow.cpp
index c70bab18cbffbc5539d43b12b858eb2fb051eac2..2cfc251151648d13fcdd54d1eb2b4a135ccb84c0 100644 (file)
@@ -238,10 +238,11 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow()
     connect(browserViewPointer, SIGNAL(updateDomainSettingsIndicator(bool, QString)), this, SLOT(updateDomainSettingsIndicator(bool, QString)));
 
     // Initialize the cookie list.
-    cookieListPointer = new QList<QNetworkCookie>;
+    cookieListPointer = new std::forward_list<QNetworkCookie>;
 
-    // Add new cookies to the list.
+    // Process cookie changes.
     connect(browserViewPointer, SIGNAL(addCookie(QNetworkCookie)), this, SLOT(addCookieToList(QNetworkCookie)));
+    connect(browserViewPointer, SIGNAL(removeCookie(QNetworkCookie)), this, SLOT(removeCookieFromList(QNetworkCookie)));
 
     // Load the initial website.
     browserViewPointer->loadInitialWebsite();
@@ -249,15 +250,9 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow()
 
 void BrowserWindow::addCookieToList(const QNetworkCookie &newCookie) const
 {
-    // Check to see if the list already contains a cookie with this ID.
-    for (QNetworkCookie existingCookie : *cookieListPointer)
-    {
-        // Remove the old version of the cookie.
-        if (existingCookie.hasSameIdentifier(newCookie)) cookieListPointer->removeOne(existingCookie);
-    }
-
+    qDebug() << "Add cookie:  " << newCookie.toRawForm();
     // Add the new cookie to the list.
-    cookieListPointer->append(newCookie);
+    cookieListPointer->push_front(newCookie);
 }
 
 void BrowserWindow::addOrEditDomainSettings() const
@@ -379,6 +374,7 @@ void BrowserWindow::openCookiesDialog()
     // Connect the dialog signals.
     connect(cookiesDialogPointer, SIGNAL(addCookie(QNetworkCookie)), browserViewPointer, SLOT(addCookieToStore(QNetworkCookie)));
     connect(cookiesDialogPointer, SIGNAL(deleteAllCookies()), browserViewPointer, SLOT(deleteAllCookies()));
+    connect(cookiesDialogPointer, SIGNAL(deleteCookie(QNetworkCookie)), browserViewPointer, SLOT(deleteCookieFromStore(QNetworkCookie)));
 }
 
 void BrowserWindow::openDomainSettings() const
@@ -405,6 +401,14 @@ void BrowserWindow::refresh() const
     browserViewPointer->refresh();
 }
 
+void BrowserWindow::removeCookieFromList(const QNetworkCookie &cookie) const
+{
+    qDebug() << "Remove cookie:  " << cookie.toRawForm();
+
+    // Remove the cookie from the list.
+    cookieListPointer->remove(cookie);
+}
+
 void BrowserWindow::showProgressBar(const int &progress) const
 {
     // Set the progress bar value.