summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-11-21 02:12:25 +0100
committerAndrea Diamantini <adjam7@gmail.com>2009-11-21 02:12:25 +0100
commit4f5ac89ad5afdc6aa57e655b33ebed8ef87c1f23 (patch)
tree9063926929f11b472176540b1266f9cd85515173
parentA new kcmshell named "webkit adblock" to set... (guess what?!) (diff)
downloadrekonq-4f5ac89ad5afdc6aa57e655b33ebed8ef87c1f23.tar.xz
Ok, same other bits on the adblock manager.
Now it's really time to go to bed :)
-rw-r--r--src/adblock/adblockmanager.cpp25
-rw-r--r--src/adblock/adblockmanager.h10
-rw-r--r--src/adblock/kcmwebkitadblock.cpp16
-rw-r--r--src/adblock/kcmwebkitadblock.h6
4 files changed, 34 insertions, 23 deletions
diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp
index 2d3feff7..6b2f9616 100644
--- a/src/adblock/adblockmanager.cpp
+++ b/src/adblock/adblockmanager.cpp
@@ -32,7 +32,9 @@
AdBlockManager::AdBlockManager(QObject *parent)
: QObject(parent)
+ , _isAdblockEnabled(false)
{
+ loadSettings();
}
@@ -41,7 +43,28 @@ AdBlockManager::~AdBlockManager()
}
+void AdBlockManager::loadSettings()
+{
+// KConfigGroup cg(_config, _group);
+// groupBox->setChecked( cg.readEntry("Enabled", false) );
+//
+// int num = cg.readEntry("Count", 0);
+// for (int i = 0; i < num; ++i)
+// {
+// QString key = "Filter-" + QString::number(i);
+// QString filter = cg.readEntry( key, QString() );
+// listWidget->addItem(filter);
+// }
+}
+
+
bool AdBlockManager::isUrlAllowed(const QUrl &url)
{
+ if (url.scheme() == QLatin1String("data"))
+ return false;
+
+ if (!_isAdblockEnabled)
+ return false;
+
return true;
-} \ No newline at end of file
+}
diff --git a/src/adblock/adblockmanager.h b/src/adblock/adblockmanager.h
index 12e897c1..c782ee0d 100644
--- a/src/adblock/adblockmanager.h
+++ b/src/adblock/adblockmanager.h
@@ -29,8 +29,11 @@
#define ADBLOCK_MANAGER_H
+// Qt Includes
#include <QObject>
+#include <QStringList>
+// Forward Includes
class QUrl;
@@ -41,8 +44,13 @@ Q_OBJECT
public:
AdBlockManager(QObject *parent = 0);
~AdBlockManager();
-
+
+ void loadSettings();
bool isUrlAllowed(const QUrl &url);
+
+private:
+ bool _isAdblockEnabled;
+ QStringList _blocks;
};
#endif
diff --git a/src/adblock/kcmwebkitadblock.cpp b/src/adblock/kcmwebkitadblock.cpp
index d114b30a..f6383788 100644
--- a/src/adblock/kcmwebkitadblock.cpp
+++ b/src/adblock/kcmwebkitadblock.cpp
@@ -51,7 +51,6 @@ K_EXPORT_PLUGIN(RekonqPluginFactory("kcmrekonqfactory"))
KCMWebkitAdblock::KCMWebkitAdblock(QWidget *parent, const QVariantList &args)
: KCModule(KGlobal::mainComponent(), parent, args)
- , _isAdblockEnabled(false)
, _group("adblock")
{
KAboutData *about = new KAboutData( I18N_NOOP("kcmrekonqfactory"), 0,
@@ -64,7 +63,6 @@ KCMWebkitAdblock::KCMWebkitAdblock(QWidget *parent, const QVariantList &args)
setupUi(this);
connect(label, SIGNAL(linkActivated(const QString &)), SLOT(infoLinkActivated(const QString &)) );
- connect(groupBox,SIGNAL(clicked(bool)), this, SLOT(stateChanged(bool)));
searchLine->setListWidget(listWidget);
connect(addButton,SIGNAL(clicked()),this,SLOT(addExpr()));
@@ -85,7 +83,7 @@ void KCMWebkitAdblock::defaults()
searchLine->clear();
lineEdit->clear();
listWidget->clear();
- groupBox->setChecked(false); // set also _isAdblockEnabled
+ groupBox->setChecked(false);
}
@@ -137,18 +135,6 @@ void KCMWebkitAdblock::infoLinkActivated(const QString &url)
}
-void KCMWebkitAdblock::stateChanged(bool state)
-{
- _isAdblockEnabled = state;
-}
-
-
-bool KCMWebkitAdblock::isAdblockEnabled()
-{
- return _isAdblockEnabled;
-}
-
-
void KCMWebkitAdblock::addExpr()
{
listWidget->addItem( lineEdit->text() );
diff --git a/src/adblock/kcmwebkitadblock.h b/src/adblock/kcmwebkitadblock.h
index 15442ac7..37130613 100644
--- a/src/adblock/kcmwebkitadblock.h
+++ b/src/adblock/kcmwebkitadblock.h
@@ -42,26 +42,20 @@ Q_OBJECT
public:
KCMWebkitAdblock(QWidget *parent, const QVariantList &args);
-
~KCMWebkitAdblock();
void defaults();
void load();
void save();
- bool isAdblockEnabled();
-
private slots:
void infoLinkActivated(const QString &url);
- void stateChanged(bool state);
void addExpr();
void removeSelected();
void importExpr();
private:
- bool _isAdblockEnabled;
-
KSharedConfig::Ptr _config;
QString _group;
};