1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

CookieManager: Don't add same server to different filters,

- Also don't allow duplicate entries in filters.
This commit is contained in:
S. Razi Alavizadeh 2014-12-01 20:17:07 +03:30
parent e60df0c9f4
commit 9301a5a2a8

View File

@ -254,12 +254,20 @@ void CookieManager::slotRefreshFilters()
void CookieManager::addWhitelist() void CookieManager::addWhitelist()
{ {
const QString server = QInputDialog::getText(this, tr("Add to whitelist"), tr("Server:")); const QString server = QInputDialog::getText(this, tr("Add to whitelist"), tr("Server:"));
if (server.isEmpty()) { if (server.isEmpty()) {
return; return;
} }
if (!ui->blackList->findItems(server, Qt::MatchFixedString).isEmpty()) {
QMessageBox::information(this, tr("Already blacklisted!"), tr("The server \"%1\" is already in blacklist, please remove it first.").arg(server));
return;
}
if (ui->whiteList->findItems(server, Qt::MatchFixedString).isEmpty()) {
ui->whiteList->addItem(server); ui->whiteList->addItem(server);
} }
}
void CookieManager::removeWhitelist() void CookieManager::removeWhitelist()
{ {
@ -269,12 +277,20 @@ void CookieManager::removeWhitelist()
void CookieManager::addBlacklist() void CookieManager::addBlacklist()
{ {
const QString server = QInputDialog::getText(this, tr("Add to blacklist"), tr("Server:")); const QString server = QInputDialog::getText(this, tr("Add to blacklist"), tr("Server:"));
if (server.isEmpty()) { if (server.isEmpty()) {
return; return;
} }
if (!ui->whiteList->findItems(server, Qt::MatchFixedString).isEmpty()) {
QMessageBox::information(this, tr("Already whitelisted!"), tr("The server \"%1\" is already in whitelist, please remove it first.").arg(server));
return;
}
if (ui->blackList->findItems(server, Qt::MatchFixedString).isEmpty()) {
ui->blackList->addItem(server); ui->blackList->addItem(server);
} }
}
void CookieManager::removeBlacklist() void CookieManager::removeBlacklist()
{ {