┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Fernández López <[email protected]>2007-10-12 15:36:29 +0000
committerRafael Fernández López <[email protected]>2007-10-12 15:36:29 +0000
commita4e558c546f69bad34fad06a6448c566ded74c37 (patch)
tree795e564242c102b17ad9b1e9827c54c3fc09aceb
parent8d4fb3608927960d9e45e672ce1cbe1fa3a548f9 (diff)
This makes the categorized view amazingly fast in directories with a huge number of files (tested with a folder with 10000 files here)
CCMAIL: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=724536
-rw-r--r--src/kcategorizedview.cpp40
-rw-r--r--src/kcategorizedview.h1
-rw-r--r--src/kcategorizedview_p.h3
3 files changed, 41 insertions, 3 deletions
diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp
index ec5ba36b7..897804cd1 100644
--- a/src/kcategorizedview.cpp
+++ b/src/kcategorizedview.cpp
@@ -477,6 +477,10 @@ void KCategorizedView::setModel(QAbstractItemModel *model)
if (d->proxyModel)
{
QObject::disconnect(d->proxyModel,
+ SIGNAL(layoutAboutToBeChanged()),
+ this, SLOT(slotLayoutAboutToBeChanged()));
+
+ QObject::disconnect(d->proxyModel,
SIGNAL(layoutChanged()),
this, SLOT(slotLayoutChanged()));
@@ -491,6 +495,14 @@ void KCategorizedView::setModel(QAbstractItemModel *model)
if (d->proxyModel)
{
+ d->modelSortRole = d->proxyModel->sortRole();
+ d->modelSortColumn = d->proxyModel->sortColumn();
+ d->modelSortOrder = d->proxyModel->sortOrder();
+
+ QObject::connect(d->proxyModel,
+ SIGNAL(layoutAboutToBeChanged()),
+ this, SLOT(slotLayoutAboutToBeChanged()));
+
QObject::connect(d->proxyModel,
SIGNAL(layoutChanged()),
this, SLOT(slotLayoutChanged()));
@@ -540,6 +552,10 @@ void KCategorizedView::setCategoryDrawer(KCategoryDrawer *categoryDrawer)
if (!categoryDrawer && d->proxyModel)
{
QObject::disconnect(d->proxyModel,
+ SIGNAL(layoutAboutToBeChanged()),
+ this, SLOT(slotLayoutAboutToBeChanged()));
+
+ QObject::disconnect(d->proxyModel,
SIGNAL(layoutChanged()),
this, SLOT(slotLayoutChanged()));
@@ -550,6 +566,10 @@ void KCategorizedView::setCategoryDrawer(KCategoryDrawer *categoryDrawer)
else if (categoryDrawer && d->proxyModel)
{
QObject::connect(d->proxyModel,
+ SIGNAL(layoutAboutToBeChanged()),
+ this, SLOT(slotLayoutAboutToBeChanged()));
+
+ QObject::connect(d->proxyModel,
SIGNAL(layoutChanged()),
this, SLOT(slotLayoutChanged()));
@@ -1176,8 +1196,8 @@ QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction,
}
void KCategorizedView::rowsInserted(const QModelIndex &parent,
- int start,
- int end)
+ int start,
+ int end)
{
QListView::rowsInserted(parent, start, end);
@@ -1304,11 +1324,25 @@ void KCategorizedView::updateGeometries()
QAbstractItemView::updateGeometries();
}
-void KCategorizedView::slotLayoutChanged()
+void KCategorizedView::slotLayoutAboutToBeChanged()
{
if ((viewMode() == KCategorizedView::IconMode) && d->proxyModel &&
d->categoryDrawer && d->proxyModel->isCategorizedModel())
{
+ d->modelSortRole = d->proxyModel->sortRole();
+ d->modelSortColumn = d->proxyModel->sortColumn();
+ d->modelSortOrder = d->proxyModel->sortOrder();
+ }
+}
+
+void KCategorizedView::slotLayoutChanged()
+{
+ if ((viewMode() == KCategorizedView::IconMode) && d->proxyModel &&
+ d->categoryDrawer && d->proxyModel->isCategorizedModel() &&
+ ((d->modelSortRole != d->proxyModel->sortRole()) ||
+ (d->modelSortColumn != d->proxyModel->sortColumn()) ||
+ (d->modelSortOrder != d->proxyModel->sortOrder())))
+ {
// Force the view to update all elements
rowsInsertedArtifficial(QModelIndex(), 0, d->proxyModel->rowCount() - 1);
}
diff --git a/src/kcategorizedview.h b/src/kcategorizedview.h
index 8544392d9..d5afb666c 100644
--- a/src/kcategorizedview.h
+++ b/src/kcategorizedview.h
@@ -103,6 +103,7 @@ protected Q_SLOTS:
virtual void updateGeometries();
+ virtual void slotLayoutAboutToBeChanged();
virtual void slotLayoutChanged();
diff --git a/src/kcategorizedview_p.h b/src/kcategorizedview_p.h
index b9587f4ab..bd2233ace 100644
--- a/src/kcategorizedview_p.h
+++ b/src/kcategorizedview_p.h
@@ -149,6 +149,9 @@ public:
QModelIndexList intersectedIndexes;
QRect lastDraggedItemsRect;
QRect lastSelectionRect;
+ int modelSortRole;
+ int modelSortColumn;
+ Qt::SortOrder modelSortOrder;
// Attributes for speed reasons
KCategorizedSortFilterProxyModel *proxyModel;