]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fixes the problem with the keyboard navigation when a selection with the right-click...
authorRafael Fernández López <ereslibre@kde.org>
Wed, 12 Dec 2007 00:04:13 +0000 (00:04 +0000)
committerRafael Fernández López <ereslibre@kde.org>
Wed, 12 Dec 2007 00:04:13 +0000 (00:04 +0000)
BUG: 153875

svn path=/trunk/KDE/kdebase/apps/; revision=747421

src/kcategorizedview.cpp

index c062b12b3212cd3e78de39c7d134f2209304ba2e..72936113c5b3dbd999c3d3a5e05195e095862a3a 100644 (file)
@@ -870,12 +870,29 @@ void KCategorizedView::setSelection(const QRect &rect,
         return;
     }
 
+    int viewportWidth = viewport()->width() - spacing();
+    int itemWidth;
+
+    if (gridSize().isEmpty())
+    {
+        itemWidth = d->biggestItemSize.width();
+    }
+    else
+    {
+        itemWidth = gridSize().width();
+    }
+
+    int itemWidthPlusSeparation = spacing() + itemWidth;
+    int elementsPerRow = viewportWidth / itemWidthPlusSeparation;
+
     QItemSelection selection;
 
     if (!d->mouseButtonPressed)
     {
         selection = QItemSelection(dirtyIndexes[0], dirtyIndexes[0]);
         d->currentViewIndex = dirtyIndexes[0];
+        selectionModel()->setCurrentIndex(d->currentViewIndex, flags);
+        d->forcedSelectionPosition = d->elementsInfo[d->currentViewIndex.row()].relativeOffsetToCategory % elementsPerRow;
     }
     else
     {
@@ -897,6 +914,12 @@ void KCategorizedView::setSelection(const QRect &rect,
 
         if (last.isValid())
             selection << QItemSelectionRange(first, last);
+
+        if (first == last)
+        {
+            selectionModel()->setCurrentIndex(first, QItemSelectionModel::SelectCurrent);
+            d->forcedSelectionPosition = d->elementsInfo[first.row()].relativeOffsetToCategory % elementsPerRow;
+        }
     }
 
     if (d->lastSelection.count())