]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kcategorizedview.cpp
Optimize PNG files again.
[dolphin.git] / src / kcategorizedview.cpp
index 8a0b3c8c570eca766407409f1e657c17ca7acbd7..b2504a14bdb2411ee2422ff26fda00992d14dfde 100644 (file)
@@ -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() ? biggestItemSize.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();