From b4377767c0a0a1fe8c7f191bfeb8f589f772409b Mon Sep 17 00:00:00 2001 From: nowrep Date: Sat, 25 Jan 2014 21:13:14 +0100 Subject: [PATCH] [AdBlockTreeWidget] Greatly speedup loading rules from subscriptions Don't use per-pixel scrolling. For some reason, it massively slows rendering of TreeWidget See #1169 --- src/lib/adblock/adblocktreewidget.cpp | 2 +- src/lib/adblock/adblocktreewidget.h | 2 -- src/lib/tools/treewidget.cpp | 3 +-- src/lib/tools/treewidget.h | 1 + 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib/adblock/adblocktreewidget.cpp b/src/lib/adblock/adblocktreewidget.cpp index 77ab1e706..14bfadf14 100644 --- a/src/lib/adblock/adblocktreewidget.cpp +++ b/src/lib/adblock/adblocktreewidget.cpp @@ -235,6 +235,7 @@ void AdBlockTreeWidget::refresh() m_topItem = new QTreeWidgetItem(this); m_topItem->setText(0, m_subscription->title()); m_topItem->setFont(0, boldFont); + m_topItem->setExpanded(true); addTopLevelItem(m_topItem); const QVector &allRules = m_subscription->allRules(); @@ -253,7 +254,6 @@ void AdBlockTreeWidget::refresh() ++index; } - expandAll(); showRule(0); m_itemChangingBlock = false; } diff --git a/src/lib/adblock/adblocktreewidget.h b/src/lib/adblock/adblocktreewidget.h index 46de53d98..35f85c94e 100644 --- a/src/lib/adblock/adblocktreewidget.h +++ b/src/lib/adblock/adblocktreewidget.h @@ -18,8 +18,6 @@ #ifndef ADBLOCKTREEWIDGET_H #define ADBLOCKTREEWIDGET_H -#include - #include "qz_namespace.h" #include "treewidget.h" diff --git a/src/lib/tools/treewidget.cpp b/src/lib/tools/treewidget.cpp index 083a160bf..90c4269a9 100644 --- a/src/lib/tools/treewidget.cpp +++ b/src/lib/tools/treewidget.cpp @@ -32,8 +32,6 @@ TreeWidget::TreeWidget(QWidget* parent) , m_refreshAllItemsNeeded(true) , m_showMode(ItemsCollapsed) { - setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); - connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(sheduleRefresh())); } @@ -325,6 +323,7 @@ QList TreeWidget::allItems() iterateAllItems(0); m_refreshAllItemsNeeded = false; } + return m_allTreeItems; } diff --git a/src/lib/tools/treewidget.h b/src/lib/tools/treewidget.h index 09fd08ec2..0dd3d6afd 100644 --- a/src/lib/tools/treewidget.h +++ b/src/lib/tools/treewidget.h @@ -31,6 +31,7 @@ public: ItemShowMode defaultItemShowMode() { return m_showMode; } void setDefaultItemShowMode(ItemShowMode mode) { m_showMode = mode; } QList allItems(); + bool appendToParentItem(const QString &parentText, QTreeWidgetItem* item); bool appendToParentItem(QTreeWidgetItem* parent, QTreeWidgetItem* item); bool prependToParentItem(const QString &parentText, QTreeWidgetItem* item);