]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kcategorizedview.cpp
Fixed 'Select All' and 'Invert Selection' for the column view (only the items of...
[dolphin.git] / src / kcategorizedview.cpp
index b42d066b53e13d5b8c7270d02f63787f91aae681..e178760ee4f1b7812657aec050a12e01411c1b08 100644 (file)
@@ -83,7 +83,6 @@ KCategorizedView::Private::Private(KCategorizedView *listView)
     , isDragging(false)
     , dragLeftViewport(false)
     , proxyModel(0)
-    , lastIndex(QModelIndex())
 {
 }
 
@@ -388,6 +387,9 @@ void KCategorizedView::Private::drawNewCategory(const QModelIndex &index,
 
 void KCategorizedView::Private::updateScrollbars()
 {
+    // find the last index in the last category 
+    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();
 
@@ -998,8 +1000,11 @@ void KCategorizedView::dragLeaveEvent(QDragLeaveEvent *event)
 QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction,
                                   Qt::KeyboardModifiers modifiers)
 {
-    if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
-        !d->itemCategorizer)
+    if (    (viewMode() != KCategorizedView::IconMode) || 
+            !d->proxyModel ||
+            !d->itemCategorizer || 
+            d->categories.isEmpty()     
+       )
     {
         return QListView::moveCursor(cursorAction, modifiers);
     }
@@ -1021,9 +1026,10 @@ QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction,
     int itemWidthPlusSeparation = spacing() + itemWidth;
     int elementsPerRow = viewportWidth / itemWidthPlusSeparation;
 
-    QString lastCategory = d->categories[0];
-    QString theCategory = d->categories[0];
-    QString afterCategory = d->categories[0];
+    QString lastCategory = d->categories.first();
+    QString theCategory = d->categories.first();
+    QString afterCategory = d->categories.first();
+
     bool hasToBreak = false;
     foreach (const QString &category, d->categories)
     {
@@ -1243,8 +1249,6 @@ void KCategorizedView::rowsInsertedArtifficial(const QModelIndex &parent,
         qStableSort(indexList.begin(), indexList.end(), categoryLessThan);
     }
 
-    d->lastIndex = d->categoriesIndexes[d->categories[d->categories.count() - 1]][d->categoriesIndexes[d->categories[d->categories.count() - 1]].count() - 1];
-
     // Finally, fill data information of items situation. This will help when
     // trying to compute an item place in the viewport
     int i = 0; // position relative to the category beginning