+void CookiesDialog::deleteCookieFromDatabase(const QNetworkCookie &cookie) const
+{
+ // Get a list of the matching domains. There should only be one item in this list
+ QList<QStandardItem *> domainList = treeModelPointer->findItems(cookie.domain());
+
+ // Find any matching cookies.
+ for (QStandardItem *domainItemPointer : domainList)
+ {
+ // Get the number of cookies in the domain.
+ int numberOfCookies = domainItemPointer->rowCount();
+
+ // Initialize the tracking variables.
+ bool cookieFound = false;
+ int currentRow = 0;
+
+ // Find the cookie in the tree model.
+ while (!cookieFound && (currentRow < numberOfCookies))
+ {
+ // Get the name item.
+ QStandardItem *nameItemPointer = domainItemPointer->child(currentRow);
+
+ // Get the name model index.
+ QModelIndex nameModelIndex = nameItemPointer->index();
+
+ // Check to see if the name and the path match.
+ if ((nameModelIndex.data().toString() == cookie.name()) && (nameModelIndex.siblingAtColumn(2).data().toString() == cookie.path()))
+ {
+ // Set the current index.
+ treeSelectionModelPointer->setCurrentIndex(nameModelIndex, QItemSelectionModel::ClearAndSelect);
+
+ // Delete the cookie.
+ deleteCookieFromDialog(cookie);
+
+ // Mark the cookie as found.
+ cookieFound = true;
+ }
+
+ // Move to the next row.
+ ++currentRow;
+ }
+ }
+}