]> 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 3293f02dbb4983eccd9246d052bcfdce0f6c256a..2cfc251151648d13fcdd54d1eb2b4a135ccb84c0 100644 (file)
@@ -238,26 +238,21 @@ 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.
-    connect(browserViewPointer, SIGNAL(addCookie(QNetworkCookie)), this, SLOT(addCookie(QNetworkCookie)));
+    // 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();
 }
 
-void BrowserWindow::addCookie(const QNetworkCookie &newCookie) const
+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
@@ -377,10 +372,11 @@ void BrowserWindow::openCookiesDialog()
     cookiesDialogPointer->show();
 
     // 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
 {
     // Remove the focus from the URL line edit.
@@ -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.