From: Rafael Fernández López Date: Sat, 13 Oct 2007 02:54:11 +0000 (+0000) Subject: One loop instead of two is enough X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/eb69606279b9f3fde744bd6d0b96f6b8611b730c One loop instead of two is enough svn path=/trunk/KDE/kdebase/apps/; revision=724700 --- diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp index d0d51ef2f..d88b17076 100644 --- a/src/kcategorizedview.cpp +++ b/src/kcategorizedview.cpp @@ -589,7 +589,7 @@ void KCategorizedView::setCategoryDrawer(KCategoryDrawer *categoryDrawer) { if (d->proxyModel) { - rowsInserted(QModelIndex(), 0, d->proxyModel->rowCount() - 1); + rowsInsertedArtifficial(QModelIndex(), 0, d->proxyModel->rowCount() - 1); } } else @@ -1254,25 +1254,24 @@ void KCategorizedView::rowsInsertedArtifficial(const QModelIndex &parent, 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; - 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;