diff --git a/src/lib/adblock/adblocktreewidget.cpp b/src/lib/adblock/adblocktreewidget.cpp index 762ed3bc6..e762e5877 100644 --- a/src/lib/adblock/adblocktreewidget.cpp +++ b/src/lib/adblock/adblocktreewidget.cpp @@ -20,6 +20,7 @@ #include #include +#include #include AdBlockTreeWidget::AdBlockTreeWidget(AdBlockSubscription* subscription, QWidget* parent) @@ -114,7 +115,8 @@ void AdBlockTreeWidget::addRule() return; } - int offset = m_subscription->addRule(AdBlockRule(newRule)); + AdBlockRule rule(newRule); + int offset = m_subscription->addRule(rule); QTreeWidgetItem* item = new QTreeWidgetItem(); item->setText(0, newRule); @@ -126,6 +128,8 @@ void AdBlockTreeWidget::addRule() m_itemChangingBlock = true; m_topItem->addChild(item); m_itemChangingBlock = false; + + adjustItemColor(item, rule); } void AdBlockTreeWidget::removeRule() @@ -172,6 +176,15 @@ void AdBlockTreeWidget::adjustItemColor(QTreeWidgetItem* item, const AdBlockRule } } +void AdBlockTreeWidget::keyPressEvent(QKeyEvent* event) +{ + if (event->key() == Qt::Key_Delete) { + removeRule(); + } + + TreeWidget::keyPressEvent(event); +} + void AdBlockTreeWidget::refresh() { m_itemChangingBlock = true; diff --git a/src/lib/adblock/adblocktreewidget.h b/src/lib/adblock/adblocktreewidget.h index 674eaa535..fa91d7fc8 100644 --- a/src/lib/adblock/adblocktreewidget.h +++ b/src/lib/adblock/adblocktreewidget.h @@ -47,6 +47,7 @@ private slots: private: void adjustItemColor(QTreeWidgetItem* item, const AdBlockRule &rule); + void keyPressEvent(QKeyEvent* event); AdBlockSubscription* m_subscription; QTreeWidgetItem* m_topItem;