X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/aa69bcdc64d4cc335da9ab853ace2fbf54157d82..6c64d1ca6b37c24b8e6f79f02923aeca9de2616d:/src/kcategorizedview.cpp diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp index 72909e836..3255de9a4 100644 --- a/src/kcategorizedview.cpp +++ b/src/kcategorizedview.cpp @@ -151,8 +151,20 @@ QRect KCategorizedView::Private::visualRectInViewport(const QModelIndex &index) int viewportWidth = listView->viewport()->width() - listView->spacing(); - int itemHeight = biggestItemSize.height(); - int itemWidth = biggestItemSize.width(); + int itemHeight; + int itemWidth; + + if (listView->gridSize().isEmpty()) + { + itemHeight = biggestItemSize.height(); + itemWidth = biggestItemSize.width(); + } + else + { + itemHeight = listView->gridSize().height(); + itemWidth = listView->gridSize().width(); + } + int itemWidthPlusSeparation = listView->spacing() + itemWidth; int elementsPerRow = viewportWidth / itemWidthPlusSeparation; if (!elementsPerRow) @@ -186,7 +198,16 @@ QRect KCategorizedView::Private::visualRectInViewport(const QModelIndex &index) row * itemHeight); retRect.setWidth(itemWidth); - retRect.setHeight(itemHeight); + + if (listView->gridSize().isEmpty()) + { + retRect.setHeight(listView->sizeHintForIndex(proxyModel->mapFromSource(index)).height()); + } + else + { + retRect.setHeight(qMin(listView->sizeHintForIndex(proxyModel->mapFromSource(index)).height(), + listView->gridSize().height())); + } return retRect; } @@ -206,8 +227,20 @@ QRect KCategorizedView::Private::visualCategoryRectInViewport(const QString &cat int viewportWidth = listView->viewport()->width() - listView->spacing(); - int itemHeight = biggestItemSize.height(); - int itemWidth = biggestItemSize.width(); + int itemHeight; + int itemWidth; + + if (listView->gridSize().isEmpty()) + { + itemHeight = biggestItemSize.height(); + itemWidth = biggestItemSize.width(); + } + else + { + itemHeight = listView->gridSize().height(); + itemWidth = listView->gridSize().width(); + } + int itemWidthPlusSeparation = listView->spacing() + itemWidth; int elementsPerRow = viewportWidth / itemWidthPlusSeparation; @@ -323,8 +356,8 @@ void KCategorizedView::Private::drawNewCategory(const QModelIndex &index, void KCategorizedView::Private::updateScrollbars() { - int lastItemBottom = cachedRectIndex(lastIndex).bottom() + - listView->spacing() - listView->viewport()->height(); + int lastItemBottom = cachedRectIndex(lastIndex).top() + + listView->spacing() + (listView->gridSize().isEmpty() ? 0 : listView->gridSize().height()) - listView->viewport()->height(); listView->verticalScrollBar()->setSingleStep(listView->viewport()->height() / 10); listView->verticalScrollBar()->setPageStep(listView->viewport()->height()); @@ -608,7 +641,6 @@ void KCategorizedView::paintEvent(QPaintEvent *event) } // Redraw categories - int i = 0; QStyleOptionViewItem otherOption; foreach (const QString &category, d->categories) { @@ -938,8 +970,17 @@ QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction, const QModelIndex current = selectionModel()->currentIndex(); int viewportWidth = viewport()->width() - spacing(); - int itemHeight = d->biggestItemSize.height(); - int itemWidth = d->biggestItemSize.width(); + int itemWidth; + + if (gridSize().isEmpty()) + { + itemWidth = d->biggestItemSize.width(); + } + else + { + itemWidth = gridSize().width(); + } + int itemWidthPlusSeparation = spacing() + itemWidth; int elementsPerRow = viewportWidth / itemWidthPlusSeparation;