From 6d10e57f88d9215e7d0bd810fef6c302b73e08ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Fern=C3=A1ndez=20L=C3=B3pez?= Date: Sun, 14 Oct 2007 23:01:35 +0000 Subject: [PATCH] If we are out of the screen and we will be, why keep asking when we know that no category will intersect from now with the viewport svn path=/trunk/KDE/kdebase/apps/; revision=725213 --- src/kcategorizedview.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp index a3e60f1c47..24603b98bd 100644 --- a/src/kcategorizedview.cpp +++ b/src/kcategorizedview.cpp @@ -743,6 +743,7 @@ void KCategorizedView::paintEvent(QPaintEvent *event) // Redraw categories QStyleOptionViewItem otherOption; + bool intersectedInThePast = false; foreach (const QString &category, d->categories) { otherOption = option; @@ -751,11 +752,18 @@ void KCategorizedView::paintEvent(QPaintEvent *event) if (otherOption.rect.intersects(area)) { + intersectedInThePast = true; + QModelIndex indexToDraw = d->proxyModel->index(d->categoriesIndexes[category][0].row(), d->proxyModel->sortColumn()); d->drawNewCategory(indexToDraw, d->proxyModel->sortRole(), otherOption, &painter); } + else if (intersectedInThePast) + { + break; // the visible area has been finished, we don't need to keep asking, the rest won't intersect + // this is doable because we know that categories are correctly ordered on the list + } } if (d->mouseButtonPressed && !d->isDragging)