本文整理汇总了C++中QNetworkCookieJar::deleteCookie方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkCookieJar::deleteCookie方法的具体用法?C++ QNetworkCookieJar::deleteCookie怎么用?C++ QNetworkCookieJar::deleteCookie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkCookieJar
的用法示例。
在下文中一共展示了QNetworkCookieJar::deleteCookie方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeDomainCookies
void CookiesContentsWidget::removeDomainCookies()
{
const QModelIndexList indexes = m_ui->cookiesView->selectionModel()->selectedIndexes();
if (indexes.isEmpty())
{
return;
}
QNetworkCookieJar *cookieJar = NetworkManagerFactory::getCookieJar();
QList<QNetworkCookie> cookies;
for (int i = 0; i < indexes.count(); ++i)
{
QStandardItem *domainItem = ((indexes.at(i).isValid() && indexes.at(i).parent() == m_model->invisibleRootItem()->index()) ? findDomain(indexes.at(i).sibling(indexes.at(i).row(), 0).data(Qt::ToolTipRole).toString()) : m_model->itemFromIndex(indexes.at(i).parent()));
if (domainItem)
{
for (int j = 0; j < domainItem->rowCount(); ++j)
{
QStandardItem *cookieItem = domainItem->child(j, 0);
if (cookieItem)
{
const QNetworkCookie cookie = getCookie(cookieItem->index());
if (!cookies.contains(cookie))
{
cookies.append(cookie);
}
}
}
}
}
if (cookies.isEmpty())
{
return;
}
QMessageBox messageBox;
messageBox.setWindowTitle(tr("Question"));
messageBox.setText(tr("You are about to delete %n cookies.", "", cookies.count()));
messageBox.setInformativeText(tr("Do you want to continue?"));
messageBox.setIcon(QMessageBox::Question);
messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
messageBox.setDefaultButton(QMessageBox::Yes);
if (messageBox.exec() == QMessageBox::Yes)
{
for (int i = 0; i < cookies.count(); ++i)
{
cookieJar->deleteCookie(cookies.at(i));
}
}
}
示例2: removeCookies
void CookiesContentsWidget::removeCookies()
{
const QModelIndexList indexes = m_ui->cookiesView->selectionModel()->selectedIndexes();
if (indexes.isEmpty())
{
return;
}
QNetworkCookieJar *cookieJar = NetworkManagerFactory::getCookieJar();
QList<QNetworkCookie> cookies;
for (int i = 0; i < indexes.count(); ++i)
{
if (!indexes.at(i).isValid())
{
continue;
}
if (indexes.at(i).data(Qt::UserRole).toString().isEmpty())
{
QStandardItem *domainItem = m_model->itemFromIndex(indexes.at(i));
if (!domainItem)
{
continue;
}
for (int j = 0; j < domainItem->rowCount(); ++j)
{
QStandardItem *cookieItem = domainItem->child(j, 0);
if (cookieItem)
{
cookies.append(getCookie((cookieItem->index())));
}
}
}
else
{
QStandardItem *cookieItem = m_model->itemFromIndex(indexes.at(i));
if (cookieItem)
{
cookies.append(getCookie(cookieItem->index()));
}
}
}
for (int i = 0; i < cookies.count(); ++i)
{
cookieJar->deleteCookie(cookies.at(i));
}
}