┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kcategorizedview.cpp
diff options
context:
space:
mode:
authorRafael Fernández López <[email protected]>2007-12-26 20:50:33 +0000
committerRafael Fernández López <[email protected]>2007-12-26 20:50:33 +0000
commit3cd333e663a58b5780925f4443b1a77e018893d4 (patch)
tree95ec9fa11568ee8bd731093ab23eb7862a5d7105 /src/kcategorizedview.cpp
parente4170c1910ad91fd31bc64edfab17ddc814411d5 (diff)
When there is no grid, we need to recalculate correctly the vertical scrollbar size
svn path=/trunk/KDE/kdebase/apps/; revision=753192
Diffstat (limited to 'src/kcategorizedview.cpp')
-rw-r--r--src/kcategorizedview.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp
index 8a0b3c8c5..125316cbc 100644
--- a/src/kcategorizedview.cpp
+++ b/src/kcategorizedview.cpp
@@ -396,7 +396,7 @@ void KCategorizedView::Private::updateScrollbars()
QModelIndex lastIndex = categoriesIndexes.isEmpty() ? QModelIndex() : categoriesIndexes[categories.last()].last();
int lastItemBottom = cachedRectIndex(lastIndex).top() +
- listView->spacing() + (listView->gridSize().isEmpty() ? 0 : listView->gridSize().height()) - listView->viewport()->height();
+ listView->spacing() + (listView->gridSize().isEmpty() ? cachedRectIndex(lastIndex).height() : listView->gridSize().height()) - listView->viewport()->height();
listView->horizontalScrollBar()->setRange(0, 0);
@@ -1242,17 +1242,6 @@ QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction,
return QListView::moveCursor(cursorAction, modifiers);
}
- QModelIndex current = selectionModel()->currentIndex();
-
- if (!current.isValid())
- {
- current = model()->index(0, 0, QModelIndex());
- selectionModel()->select(current, QItemSelectionModel::NoUpdate);
- d->forcedSelectionPosition = 0;
-
- return current;
- }
-
int viewportWidth = viewport()->width() - spacing();
int itemWidth;
@@ -1270,6 +1259,28 @@ QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction,
if (!elementsPerRow)
elementsPerRow++;
+ QModelIndex current = selectionModel()->currentIndex();
+
+ if (!current.isValid())
+ {
+ if (cursorAction == MoveEnd)
+ {
+ current = model()->index(model()->rowCount() - 1, 0, QModelIndex());
+ d->forcedSelectionPosition = d->elementsInfo[current.row()].relativeOffsetToCategory % elementsPerRow;
+ }
+ else
+ {
+ current = model()->index(0, 0, QModelIndex());
+ d->forcedSelectionPosition = 0;
+ }
+
+ return current;
+ }
+ else if (!current.isValid())
+ {
+ return QModelIndex();
+ }
+
QString lastCategory = d->categories.first();
QString theCategory = d->categories.first();
QString afterCategory = d->categories.first();