aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/blockersubscription.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/blockersubscription.cpp')
-rw-r--r--src/webengine/blockersubscription.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/webengine/blockersubscription.cpp b/src/webengine/blockersubscription.cpp
index 5a0664b..c7f647b 100644
--- a/src/webengine/blockersubscription.cpp
+++ b/src/webengine/blockersubscription.cpp
@@ -24,6 +24,9 @@ int BlockerSubscription::loadFromFile(const QString &file)
return -1;
}
+ // clear all lists
+ m_urlBlacklist.clear();
+ m_urlWhitelist.clear();
int rules = 0;
while(!subscription.atEnd()) {
@@ -33,14 +36,23 @@ int BlockerSubscription::loadFromFile(const QString &file)
parseComment(line);
} else {
// The line is not a comment
- BlockerRule *rule = new BlockerRule(line, this);
- m_urlBlacklist.append(rule);
+
rules++;
+ BlockerRule *rule = new BlockerRule(line, this);
+
+ if(rule->isValid()) {
+ if(rule->isException()) {
+ m_urlWhitelist.append(rule);
+ } else {
+ m_urlBlacklist.append(rule);
+ }
+ }
+
}
}
}
- qDebug("Loaded %i rules from subscription %s", rules, qUtf8Printable(file));
+ qDebug("Loaded %i/%i rules from subscription %s", m_urlBlacklist.count() + m_urlWhitelist.count(), rules, qUtf8Printable(file));
return rules;
}
@@ -74,6 +86,16 @@ const QDateTime BlockerSubscription::expires()
return m_expires;
}
+const QList<BlockerRule*> BlockerSubscription::urlBlacklist()
+{
+ return m_urlBlacklist;
+}
+
+const QList<BlockerRule*> BlockerSubscription::urlWhitelist()
+{
+ return m_urlWhitelist;
+}
+
void BlockerSubscription::parseComment(const QString &line)
{
if(line.startsWith("! Title: ")) {