From: Rafael Fernández López Date: Fri, 12 Oct 2007 15:36:29 +0000 (+0000) Subject: This makes the categorized view amazingly fast in directories with a huge number... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/a4e558c546f69bad34fad06a6448c566ded74c37 This makes the categorized view amazingly fast in directories with a huge number of files (tested with a folder with 10000 files here) CCMAIL: peter.penz@gmx.at svn path=/trunk/KDE/kdebase/apps/; revision=724536 --- diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp index ec5ba36b7..897804cd1 100644 --- a/src/kcategorizedview.cpp +++ b/src/kcategorizedview.cpp @@ -476,6 +476,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())); @@ -539,6 +551,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())); @@ -549,6 +565,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,10 +1324,24 @@ 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;