1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

AdBlock: Option to delete rule with Del key

- fixed setting color of newly added rule according to its type
This commit is contained in:
nowrep 2012-07-01 14:44:42 +02:00
parent 1b000812b9
commit 066600ff10
2 changed files with 15 additions and 1 deletions

View File

@ -20,6 +20,7 @@
#include <QMenu>
#include <QTimer>
#include <QKeyEvent>
#include <QInputDialog>
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;

View File

@ -47,6 +47,7 @@ private slots:
private:
void adjustItemColor(QTreeWidgetItem* item, const AdBlockRule &rule);
void keyPressEvent(QKeyEvent* event);
AdBlockSubscription* m_subscription;
QTreeWidgetItem* m_topItem;