X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=src%2Fwindows%2FBrowserWindow.cpp;h=2cfc251151648d13fcdd54d1eb2b4a135ccb84c0;hb=cba9a47f00b59f59f76f1b5195086285ca0cdb59;hp=3293f02dbb4983eccd9246d052bcfdce0f6c256a;hpb=8933c941521c591a962034ecf3486c9143bf1f80;p=PrivacyBrowserPC.git diff --git a/src/windows/BrowserWindow.cpp b/src/windows/BrowserWindow.cpp index 3293f02..2cfc251 100644 --- a/src/windows/BrowserWindow.cpp +++ b/src/windows/BrowserWindow.cpp @@ -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; + cookieListPointer = new std::forward_list; - // 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.