]> cloud.milkyroute.net Git - dolphin.git/commitdiff
One loop instead of two is enough
authorRafael Fernández López <ereslibre@kde.org>
Sat, 13 Oct 2007 02:54:11 +0000 (02:54 +0000)
committerRafael Fernández López <ereslibre@kde.org>
Sat, 13 Oct 2007 02:54:11 +0000 (02:54 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=724700

src/kcategorizedview.cpp

index d0d51ef2f44ec0d770d977ba54a14f1491796ad9..d88b170761e974b67646b44331f295c3bd4be18e 100644 (file)
@@ -589,7 +589,7 @@ void KCategorizedView::setCategoryDrawer(KCategoryDrawer *categoryDrawer)
     {
         if (d->proxyModel)
         {
     {
         if (d->proxyModel)
         {
-            rowsInserted(QModelIndex(), 0, d->proxyModel->rowCount() - 1);
+            rowsInsertedArtifficial(QModelIndex(), 0, d->proxyModel->rowCount() - 1);
         }
     }
     else
         }
     }
     else
@@ -1254,25 +1254,24 @@ void KCategorizedView::rowsInsertedArtifficial(const QModelIndex &parent,
         return;
     }
 
         return;
     }
 
-    // Add all elements mapped to the source model
-    for (int k = 0; k < d->proxyModel->rowCount(); k++)
-    {
-        d->biggestItemSize = QSize(qMax(sizeHintForIndex(d->proxyModel->index(k, 0)).width(),
-                                        d->biggestItemSize.width()),
-                                   qMax(sizeHintForIndex(d->proxyModel->index(k, 0)).height(),
-                                        d->biggestItemSize.height()));
-
-        d->modelIndexList << d->proxyModel->index(k, d->proxyModel->sortColumn());
-    }
-
-    // Explore categories
-    QString prevCategory = d->proxyModel->data(d->modelIndexList[0], KCategorizedSortFilterProxyModel::CategoryRole).toString();
+    // Add all elements mapped to the source model and explore categories
+    QString prevCategory = d->proxyModel->data(d->proxyModel->index(0, d->proxyModel->sortColumn()), KCategorizedSortFilterProxyModel::CategoryRole).toString();
     QString lastCategory = prevCategory;
     QModelIndexList modelIndexList;
     struct Private::ElementInfo elementInfo;
     int offset = -1;
     QString lastCategory = prevCategory;
     QModelIndexList modelIndexList;
     struct Private::ElementInfo elementInfo;
     int offset = -1;
-    foreach (const QModelIndex &index, d->modelIndexList)
+    for (int k = 0; k < d->proxyModel->rowCount(); ++k)
     {
     {
+        QModelIndex index = d->proxyModel->index(k, d->proxyModel->sortColumn());
+        QModelIndex indexSize = d->proxyModel->index(k, 0);
+
+        d->biggestItemSize = QSize(qMax(sizeHintForIndex(indexSize).width(),
+                                        d->biggestItemSize.width()),
+                                   qMax(sizeHintForIndex(indexSize).height(),
+                                        d->biggestItemSize.height()));
+
+        d->modelIndexList << index;
+
         lastCategory = d->proxyModel->data(index, KCategorizedSortFilterProxyModel::CategoryRole).toString();
 
         elementInfo.category = lastCategory;
         lastCategory = d->proxyModel->data(index, KCategorizedSortFilterProxyModel::CategoryRole).toString();
 
         elementInfo.category = lastCategory;