summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-05-04 13:57:43 +0200
committerMontel Laurent <[email protected]>2016-05-04 13:57:43 +0200
commit4ee8cb19b9cf46eadcbb77fe43e0387acb683beb (patch)
treefa71a358dd96f54c26df171dc22b8c54909bd189
parent3589471609c2ecb8d13ae14c1e5aef0c6bb038d9 (diff)
Create list
-rw-r--r--plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemswidget.cpp48
1 files changed, 20 insertions, 28 deletions
diff --git a/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemswidget.cpp b/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemswidget.cpp
index 6dd6bff..547508e 100644
--- a/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemswidget.cpp
+++ b/plugins/webengineurlinterceptor/adblock/lib/widgets/adblockblockableitemswidget.cpp
@@ -32,6 +32,7 @@
#include <QClipboard>
#include <QApplication>
#include <QPointer>
+#include <adblockblockableitemsjob.h>
#include <KIOWidgets/KRun>
using namespace AdBlock;
@@ -69,7 +70,25 @@ AdBlockBlockableItemsWidget::~AdBlockBlockableItemsWidget()
void AdBlockBlockableItemsWidget::setAdblockResult(const QVector<AdBlockResult> &result)
{
- //TODO add list
+ Q_FOREACH(const AdBlockResult &res, result) {
+ QTreeWidgetItem *item = new QTreeWidgetItem(mListItems);
+ item->setText(Url, res.src);
+ switch (res.type) {
+ case AdBlock::AdBlockBlockableItemsJob::UnKnown:
+ //TODO ?
+ break;
+ case AdBlock::AdBlockBlockableItemsJob::Image:
+ item->setText(Type, elementTypeToI18n(AdBlockBlockableItemsWidget::Image));
+ item->setData(Type, Element, Image);
+ break;
+ case AdBlock::AdBlockBlockableItemsJob::Script:
+ item->setText(Type, elementTypeToI18n(AdBlockBlockableItemsWidget::Script));
+ item->setData(Type, Element, Script);
+ break;
+ }
+ item->setTextColor(FilterValue, Qt::red);
+ }
+ mListItems->setShowDefaultText(mListItems->model()->rowCount() == 0);
}
void AdBlockBlockableItemsWidget::customContextMenuRequested(const QPoint &)
@@ -107,33 +126,6 @@ void AdBlockBlockableItemsWidget::readConfig()
mListItems->header()->restoreState(config.readEntry("HeaderState", QByteArray()));
}
-#if 0
-void AdBlockBlockableItemsWidget::handleSearchBlockableImageItems(const QVariant &result)
-{
- qDebug() << " AdBlockBlockableItemsWidget::handleSearchBlockableImageItems " << result;
- const QList<QVariant> lst = result.toList();
- const QUrl url = mWebEngineView->url();
- const QString host = url.host();
- Q_FOREACH (const QVariant &var, lst) {
- QMap<QString, QVariant> mapVariant = var.toMap();
- QString src = mapVariant.value(QStringLiteral("src")).toString();
- if (!src.isEmpty()) {
- adaptSrc(src, host);
- if (src.isEmpty()) {
- continue;
- }
- QTreeWidgetItem *item = new QTreeWidgetItem(mListItems);
- item->setText(Url, src);
- item->setText(Type, elementTypeToI18n(AdBlockBlockableItemsWidget::Image));
- item->setTextColor(FilterValue, Qt::red);
- item->setData(Type, Element, Image);
- }
- }
- mListItems->setShowDefaultText(mListItems->model()->rowCount() == 0);
- mWebEngineView->page()->runJavaScript(WebEngineViewer::WebEngineScript::findAllScripts(), invoke(this, &AdBlockBlockableItemsWidget::handleSearchBlockableScriptsItems));
-}
-#endif
-
void AdBlockBlockableItemsWidget::slotCopyFilterItem()
{
QTreeWidgetItem *item = mListItems->currentItem();