diff options
author | Montel Laurent <montel@kde.org> | 2013-10-03 08:51:35 +0200 |
---|---|---|
committer | Montel Laurent <montel@kde.org> | 2013-10-03 08:51:35 +0200 |
commit | 613fead12b5d5279533f11139cdc19e60cb6a6ef (patch) | |
tree | 834c9060af18cfd422ad9021ef533cbcc8425cf1 | |
parent | Allow to remove multi manual filters. Send hasChanged when necessary (diff) | |
download | rekonq-613fead12b5d5279533f11139cdc19e60cb6a6ef.tar.xz |
Const'ify. Don't add duplicate filter
-rw-r--r-- | src/adblock/adblockelementhiding.cpp | 2 | ||||
-rw-r--r-- | src/adblock/adblockelementhiding.h | 2 | ||||
-rw-r--r-- | src/adblock/adblocksettingwidget.cpp | 11 |
3 files changed, 11 insertions, 4 deletions
diff --git a/src/adblock/adblockelementhiding.cpp b/src/adblock/adblockelementhiding.cpp index bac693cb..d284975c 100644 --- a/src/adblock/adblockelementhiding.cpp +++ b/src/adblock/adblockelementhiding.cpp @@ -65,7 +65,7 @@ bool AdBlockElementHiding::addRule(const QString &rule) return true; } -void AdBlockElementHiding::apply(QWebElement &document, QString domain) const +void AdBlockElementHiding::apply(QWebElement &document, const QString &domain) const { //first apply generic rules diff --git a/src/adblock/adblockelementhiding.h b/src/adblock/adblockelementhiding.h index b480277e..032420f9 100644 --- a/src/adblock/adblockelementhiding.h +++ b/src/adblock/adblockelementhiding.h @@ -36,7 +36,7 @@ public: AdBlockElementHiding(); bool addRule(const QString &rule); - void apply(QWebElement &document, QString domain) const; + void apply(QWebElement &document, const QString &domain) const; void clear(); diff --git a/src/adblock/adblocksettingwidget.cpp b/src/adblock/adblocksettingwidget.cpp index 3f3af557..88eaa549 100644 --- a/src/adblock/adblocksettingwidget.cpp +++ b/src/adblock/adblocksettingwidget.cpp @@ -67,7 +67,6 @@ AdBlockSettingWidget::AdBlockSettingWidget(KSharedConfig::Ptr config, QWidget *p spinBox->setSuffix(ki18np(" day", " days")); // emit changed signal - connect(insertButton, SIGNAL(clicked()), this, SLOT(hasChanged())); connect(checkEnableAdblock, SIGNAL(stateChanged(int)), this, SLOT(hasChanged())); connect(checkHideAds, SIGNAL(stateChanged(int)), this, SLOT(hasChanged())); connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(hasChanged())); @@ -94,12 +93,20 @@ void AdBlockSettingWidget::slotInfoLinkActivated(const QString &url) void AdBlockSettingWidget::insertRule() { - QString rule = addFilterLineEdit->text(); + const QString rule = addFilterLineEdit->text(); if (rule.isEmpty()) return; + const int numberItem(manualFiltersListWidget->count()); + for (int i = 0; i < numberItem; ++i) { + if (manualFiltersListWidget->item(i)->text() == rule) { + addFilterLineEdit->clear(); + return; + } + } manualFiltersListWidget->addItem(rule); addFilterLineEdit->clear(); + hasChanged(); } |