summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2013-10-03 08:53:59 +0200
committerMontel Laurent <montel@kde.org>2013-10-03 08:53:59 +0200
commita4b659ec7f4abbf50508d5c2e4a34dc3700e0f7e (patch)
tree864ea819382a4512e481cab278ebdafa18d61e1e
parentConst'ify. Don't add duplicate filter (diff)
downloadrekonq-a4b659ec7f4abbf50508d5c2e4a34dc3700e0f7e.tar.xz
const'ify. Don't add empty string
-rw-r--r--src/adblock/adblocksettingwidget.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/adblock/adblocksettingwidget.cpp b/src/adblock/adblocksettingwidget.cpp
index 88eaa549..68377955 100644
--- a/src/adblock/adblocksettingwidget.cpp
+++ b/src/adblock/adblocksettingwidget.cpp
@@ -79,7 +79,7 @@ void AdBlockSettingWidget::slotInfoLinkActivated(const QString &url)
{
Q_UNUSED(url)
- QString hintHelpString = i18n("<qt><p>Enter an expression to filter. Filters can be defined as either:"
+ const QString hintHelpString = i18n("<qt><p>Enter an expression to filter. Filters can be defined as either:"
"<ul><li>a shell-style wildcard, e.g. <tt>http://www.example.com/ads*</tt>, "
"the wildcards <tt>*?[]</tt> may be used</li>"
"<li>a full regular expression by surrounding the string with '<tt>/</tt>', "
@@ -203,19 +203,19 @@ void AdBlockSettingWidget::save()
// automatic filters
KConfigGroup autoFiltersGroup(_adblockConfig, "FiltersList");
- for (int i = 0; i < automaticFiltersListWidget->count(); i++)
+ for (int i = 0; i < automaticFiltersListWidget->count(); ++i)
{
QListWidgetItem *subItem = automaticFiltersListWidget->item(i);
bool active = true;
if (subItem->checkState() == Qt::Unchecked)
active = false;
- QString n = QString::number(i + 1);
+ const QString n = QString::number(i + 1);
autoFiltersGroup.writeEntry("FilterEnabled-" + n, active);
}
// local filters
- QString localRulesFilePath = KStandardDirs::locateLocal("appdata" , QL1S("adblockrules_local"));
+ const QString localRulesFilePath = KStandardDirs::locateLocal("appdata" , QL1S("adblockrules_local"));
QFile ruleFile(localRulesFilePath);
if (!ruleFile.open(QFile::WriteOnly | QFile::Text))
@@ -225,11 +225,12 @@ void AdBlockSettingWidget::save()
}
QTextStream out(&ruleFile);
- for (int i = 0; i < manualFiltersListWidget->count(); i++)
+ for (int i = 0; i < manualFiltersListWidget->count(); ++i)
{
QListWidgetItem *subItem = manualFiltersListWidget->item(i);
- QString stringRule = subItem->text();
- out << stringRule << '\n';
+ const QString stringRule = subItem->text();
+ if (!stringRule.trimmed().isEmpty())
+ out << stringRule << '\n';
}
// -------------------------------------------------------------------------------