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
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.
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.