X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/919d20115f9f3f085b1719ce51b2bd04240662bb..1ce2fb199db7bdf5baf05b61e4e58c549404b4df:/src/kcategorizedview.cpp diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp index 20fbdc757..4f542f9c7 100644 --- a/src/kcategorizedview.cpp +++ b/src/kcategorizedview.cpp @@ -390,6 +390,8 @@ void KCategorizedView::Private::updateScrollbars() int lastItemBottom = cachedRectIndex(lastIndex).top() + listView->spacing() + (listView->gridSize().isEmpty() ? 0 : listView->gridSize().height()) - listView->viewport()->height(); + listView->horizontalScrollBar()->setRange(0, 0); + listView->verticalScrollBar()->setSingleStep(listView->viewport()->height() / 10); listView->verticalScrollBar()->setPageStep(listView->viewport()->height()); listView->verticalScrollBar()->setRange(0, lastItemBottom); @@ -418,18 +420,24 @@ void KCategorizedView::Private::layoutChanged(bool forceItemReload) { if ((listView->viewMode() == KCategorizedView::IconMode) && proxyModel && categoryDrawer && proxyModel->isCategorizedModel() && - (((modelSortRole != proxyModel->sortRole()) || + ((forceItemReload || + (modelSortRole != proxyModel->sortRole()) || (modelSortColumn != proxyModel->sortColumn()) || (modelSortOrder != proxyModel->sortOrder()) || - (modelCategorized != proxyModel->isCategorizedModel())) || forceItemReload)) + (modelLastRowCount != proxyModel->rowCount()) || + (modelCategorized != proxyModel->isCategorizedModel())))) { // Force the view to update all elements listView->rowsInsertedArtifficial(QModelIndex(), 0, proxyModel->rowCount() - 1); - modelSortRole = proxyModel->sortRole(); - modelSortColumn = proxyModel->sortColumn(); - modelCategorized = proxyModel->isCategorizedModel(); - modelSortOrder = proxyModel->sortOrder(); + if (!forceItemReload) + { + modelSortRole = proxyModel->sortRole(); + modelSortColumn = proxyModel->sortColumn(); + modelSortOrder = proxyModel->sortOrder(); + modelLastRowCount = proxyModel->rowCount(); + modelCategorized = proxyModel->isCategorizedModel(); + } } else if ((listView->viewMode() == KCategorizedView::IconMode) && proxyModel && categoryDrawer && proxyModel->isCategorizedModel()) @@ -521,8 +529,9 @@ void KCategorizedView::setModel(QAbstractItemModel *model) { d->modelSortRole = d->proxyModel->sortRole(); d->modelSortColumn = d->proxyModel->sortColumn(); - d->modelCategorized = true; d->modelSortOrder = d->proxyModel->sortOrder(); + d->modelLastRowCount = d->proxyModel->rowCount(); + d->modelCategorized = d->proxyModel->isCategorizedModel(); QObject::connect(d->proxyModel, SIGNAL(layoutChanged()), @@ -538,7 +547,7 @@ void KCategorizedView::setModel(QAbstractItemModel *model) if (d->proxyModel->rowCount()) { - rowsInsertedArtifficial(QModelIndex(), 0, d->proxyModel->rowCount() - 1); + d->layoutChanged(true); } } else @@ -618,7 +627,10 @@ void KCategorizedView::setCategoryDrawer(KCategoryDrawer *categoryDrawer) { if (d->proxyModel) { - rowsInsertedArtifficial(QModelIndex(), 0, d->proxyModel->rowCount() - 1); + if (d->proxyModel->rowCount()) + { + d->layoutChanged(true); + } } } else @@ -736,6 +748,7 @@ void KCategorizedView::paintEvent(QPaintEvent *event) // Redraw categories QStyleOptionViewItem otherOption; + bool intersectedInThePast = false; foreach (const QString &category, d->categories) { otherOption = option; @@ -744,11 +757,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)