]> cloud.milkyroute.net Git - dolphin.git/commitdiff
This makes the categorized view amazingly fast in directories with a huge number...
authorRafael Fernández López <ereslibre@kde.org>
Fri, 12 Oct 2007 15:36:29 +0000 (15:36 +0000)
committerRafael Fernández López <ereslibre@kde.org>
Fri, 12 Oct 2007 15:36:29 +0000 (15:36 +0000)
CCMAIL: peter.penz@gmx.at

svn path=/trunk/KDE/kdebase/apps/; revision=724536

src/kcategorizedview.cpp
src/kcategorizedview.h
src/kcategorizedview_p.h

index ec5ba36b7bf13556ddfff60e6a622677188781f8..897804cd16de66100aa8c7bd86fdbc797161d338 100644 (file)
@@ -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);
index 8544392d99e64d921bf321e37ccf6cce1e5b31e4..d5afb666cc80c627f1a306e40ca53af2a2ad2f3c 100644 (file)
@@ -103,6 +103,7 @@ protected Q_SLOTS:
 
     virtual void updateGeometries();
 
+    virtual void slotLayoutAboutToBeChanged();
     virtual void slotLayoutChanged();
 
 
index b9587f4ab176a1f24b600c4ca56ab8de07f18cfa..bd2233acea7ee0e78e5555376fdddbc4e825177a 100644 (file)
@@ -149,6 +149,9 @@ public:
     QModelIndexList intersectedIndexes;
     QRect lastDraggedItemsRect;
     QRect lastSelectionRect;
+    int modelSortRole;
+    int modelSortColumn;
+    Qt::SortOrder modelSortOrder;
 
     // Attributes for speed reasons
     KCategorizedSortFilterProxyModel *proxyModel;