]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.cpp
Merge branch 'master' into frameworks
[dolphin.git] / src / kitemviews / kitemlistview.cpp
index 0090f8620c90fa34cb90c092d06208ebcfb129f6..d35dd896e52a64fa403600038be63dc6a2593ead 100644 (file)
@@ -464,9 +464,9 @@ int KItemListView::lastVisibleIndex() const
     return m_layouter->lastVisibleIndex();
 }
 
-void KItemListView::calculateItemSizeHints(QVector<QSizeF>& sizeHints) const
+void KItemListView::calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint) const
 {
-    widgetCreator()->calculateItemSizeHints(sizeHints, this);
+    widgetCreator()->calculateItemSizeHints(logicalHeightHints, logicalWidthHint, this);
 }
 
 void KItemListView::setSupportsItemExpanding(bool supportsExpanding)
@@ -1053,11 +1053,17 @@ void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges)
                                               (!verticalScrollOrientation && maximumScrollOffset() > size().width());
             if (decreaseLayouterSize) {
                 const int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
+
+                int scrollbarSpacing = 0;
+                if (style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents)) {
+                    scrollbarSpacing = style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing);
+                }
+
                 QSizeF layouterSize = m_layouter->size();
                 if (verticalScrollOrientation) {
-                    layouterSize.rwidth() -= scrollBarExtent;
+                    layouterSize.rwidth() -= scrollBarExtent + scrollbarSpacing;
                 } else {
-                    layouterSize.rheight() -= scrollBarExtent;
+                    layouterSize.rheight() -= scrollBarExtent + scrollbarSpacing;
                 }
                 m_layouter->setSize(layouterSize);
             }
@@ -1332,14 +1338,18 @@ void KItemListView::slotCurrentChanged(int current, int previous)
 {
     Q_UNUSED(previous);
 
-    KItemListWidget* previousWidget = m_visibleItems.value(previous, 0);
-    if (previousWidget) {
-        previousWidget->setCurrent(false);
-    }
+    // In SingleSelection mode (e.g., in the Places Panel), the current item is
+    // always the selected item. It is not necessary to highlight the current item then.
+    if (m_controller->selectionBehavior() != KItemListController::SingleSelection) {
+        KItemListWidget* previousWidget = m_visibleItems.value(previous, 0);
+        if (previousWidget) {
+            previousWidget->setCurrent(false);
+        }
 
-    KItemListWidget* currentWidget = m_visibleItems.value(current, 0);
-    if (currentWidget) {
-        currentWidget->setCurrent(true);
+        KItemListWidget* currentWidget = m_visibleItems.value(current, 0);
+        if (currentWidget) {
+            currentWidget->setCurrent(true);
+        }
     }
 #pragma message("TODO: port accessibility otherwise the following line asserts")
     //QAccessible::updateAccessibility(this, current+1, QAccessible::Focus);
@@ -1979,7 +1989,12 @@ void KItemListView::updateWidgetProperties(KItemListWidget* widget, int index)
     widget->setStyleOption(m_styleOption);
 
     const KItemListSelectionManager* selectionManager = m_controller->selectionManager();
-    widget->setCurrent(index == selectionManager->currentItem());
+
+    // In SingleSelection mode (e.g., in the Places Panel), the current item is
+    // always the selected item. It is not necessary to highlight the current item then.
+    if (m_controller->selectionBehavior() != KItemListController::SingleSelection) {
+        widget->setCurrent(index == selectionManager->currentItem());
+    }
     widget->setSelected(selectionManager->isSelected(index));
     widget->setHovered(false);
     widget->setEnabledSelectionToggle(enabledSelectionToggles());
@@ -2711,4 +2726,3 @@ void KItemListGroupHeaderCreatorBase::recycle(KItemListGroupHeader* header)
     pushRecycleableWidget(header);
 }
 
-#include "kitemlistview.moc"