summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-12-18 22:57:33 +0100
committerMontel Laurent <[email protected]>2017-12-18 22:57:33 +0100
commit7dd137f7b3d6206395db480f7739b1a600c4e157 (patch)
tree59a9c664272699fd90f629515708568b33d3e894
parent54637866284fb81db283bed790907dd18dcdbd28 (diff)
continue to fix adblock support
-rw-r--r--plugins/webengineurlinterceptor/adblock/adblockinterceptorinterface.cpp1
-rw-r--r--plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemsdialog.cpp6
-rw-r--r--plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemsdialog.h1
-rw-r--r--plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemswidget.cpp20
4 files changed, 26 insertions, 2 deletions
diff --git a/plugins/webengineurlinterceptor/adblock/adblockinterceptorinterface.cpp b/plugins/webengineurlinterceptor/adblock/adblockinterceptorinterface.cpp
index f3038a9..7b6b6f5 100644
--- a/plugins/webengineurlinterceptor/adblock/adblockinterceptorinterface.cpp
+++ b/plugins/webengineurlinterceptor/adblock/adblockinterceptorinterface.cpp
@@ -92,6 +92,7 @@ void AdblockInterceptorInterface::setWebEngineView(QWebEngineView *webEngineView
void AdblockInterceptorInterface::slotBlockImage()
{
+ qDebug() << " void AdblockInterceptorInterface::slotBlockImage()";
if (mCurrentWebHitTest.imageUrl().isValid()) {
qDebug() << " mCurrentWebHitTest.imageUrl()"<<mCurrentWebHitTest.imageUrl();
//TODO block it.
diff --git a/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemsdialog.cpp b/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemsdialog.cpp
index defa2d8..4d92407 100644
--- a/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemsdialog.cpp
+++ b/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemsdialog.cpp
@@ -57,6 +57,12 @@ AdBlockBlockableItemsDialog::~AdBlockBlockableItemsDialog()
writeConfig();
}
+void AdBlockBlockableItemsDialog::accept()
+{
+ saveFilters();
+ QDialog::accept();
+}
+
void AdBlockBlockableItemsDialog::saveFilters()
{
mBlockableItems->saveFilters();
diff --git a/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemsdialog.h b/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemsdialog.h
index 7206de9..59a4307 100644
--- a/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemsdialog.h
+++ b/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemsdialog.h
@@ -35,6 +35,7 @@ public:
void saveFilters();
void setAdblockResult(const QVector<AdBlock::AdBlockResult> &result);
+ void accept() override;
private:
void writeConfig();
void readConfig();
diff --git a/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemswidget.cpp b/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemswidget.cpp
index 2de5860..b78ecd9 100644
--- a/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemswidget.cpp
+++ b/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemswidget.cpp
@@ -20,6 +20,7 @@
#include "adblockblockableitemswidget.h"
#include "adblockcreatefilterdialog.h"
#include "adblockinterceptor_debug.h"
+#include "adblockutil.h"
#include <WebEngineViewer/WebEngineScript>
#include <QVBoxLayout>
@@ -34,6 +35,7 @@
#include <QApplication>
#include <QPointer>
#include <adblockblockableitemsjob.h>
+#include <qfile.h>
#include <KIOWidgets/KRun>
using namespace AdBlock;
@@ -74,6 +76,7 @@ void AdBlockBlockableItemsWidget::setAdblockResult(const QVector<AdBlockResult>
item->setText(Url, res.src);
switch (res.type) {
case AdBlock::AdBlockBlockableItemsJob::UnKnown:
+ qCDebug(ADBLOCKINTERCEPTOR_LOG) << " unknown ablock type : " << res.src;
//TODO ?
break;
case AdBlock::AdBlockBlockableItemsJob::Image:
@@ -94,10 +97,22 @@ void AdBlockBlockableItemsWidget::setAdblockResult(const QVector<AdBlockResult>
void AdBlockBlockableItemsWidget::saveFilters()
{
qWarning() << " void AdBlockBlockableItemsWidget::saveFilters() unimplemented yet";
- for (int i = 0; i < mListItems->model()->rowCount(); ++i) {
+ // local filters
+ const QString localRulesFilePath = AdBlock::AdBlockUtil::localFilterPath();
+
+ QFile ruleFile(localRulesFilePath);
+ if (!ruleFile.open(QFile::WriteOnly | QFile::Text | QFile::Append)) {
+ qCDebug(ADBLOCKINTERCEPTOR_LOG) << "Unable to open rule file" << localRulesFilePath;
+ return;
+ }
+ for (int i = 0; i < mListItems->topLevelItemCount(); ++i) {
+ QTreeWidgetItem *item = mListItems->topLevelItem(i);
+ const QString itemStr = item->text(FilterValue);
+ if (!itemStr.isEmpty()) {
+ qDebug() << " item !:" << item->text(FilterValue);
+ }
//TODO
}
- //TODO
}
void AdBlockBlockableItemsWidget::customContextMenuRequested(const QPoint &)
@@ -168,6 +183,7 @@ void AdBlockBlockableItemsWidget::slotBlockItem()
if (dlg->exec()) {
const QString filter = dlg->filter();
item->setText(FilterValue, filter);
+ item->setToolTip(FilterValue, filter);
}
delete dlg;
}