diff options
| author | Rafael Fernández López <[email protected]> | 2007-10-13 02:54:11 +0000 |
|---|---|---|
| committer | Rafael Fernández López <[email protected]> | 2007-10-13 02:54:11 +0000 |
| commit | eb69606279b9f3fde744bd6d0b96f6b8611b730c (patch) | |
| tree | fbc7f88849a7a915bab4c40e01ef3994a1a7f906 /src | |
| parent | e907e75abf2167417d2fa45c668df35b6dfdd094 (diff) | |
One loop instead of two is enough
svn path=/trunk/KDE/kdebase/apps/; revision=724700
Diffstat (limited to 'src')
| -rw-r--r-- | src/kcategorizedview.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
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; |
