]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.cpp
Merge remote-tracking branch 'upstream/master' into work/zakharafoniam/useful-groups
[dolphin.git] / src / kitemviews / kitemlistview.cpp
index e291ee5ecd5122af06c15087a3a6d32f29c6a4e5..45f5851bf5d6c2e06bd592c09350058fea35a2a8 100644 (file)
@@ -551,7 +551,7 @@ void KItemListView::scrollToItem(int index, ViewItemPosition viewItemPosition)
     QRectF currentRect = itemRect(index);
 
     if (layoutDirection() == Qt::RightToLeft && scrollOrientation() == Qt::Horizontal) {
-        currentRect.moveTo(m_layouter->size().width() - currentRect.right(), 0);
+        currentRect.moveLeft(m_layouter->size().width() - currentRect.right());
     }
 
     // Fix for Bug 311099 - View the underscore when using Ctrl + PageDown
@@ -1481,6 +1481,26 @@ void KItemListView::slotSortRoleChanged(const QByteArray &current, const QByteAr
     }
 }
 
+void KItemListView::slotGroupOrderChanged(Qt::SortOrder current, Qt::SortOrder previous)
+{
+    Q_UNUSED(current)
+    Q_UNUSED(previous)
+    if (m_grouped) {
+        updateVisibleGroupHeaders();
+        doLayout(NoAnimation);
+    }
+}
+
+void KItemListView::slotGroupRoleChanged(const QByteArray &current, const QByteArray &previous)
+{
+    Q_UNUSED(current)
+    Q_UNUSED(previous)
+    if (m_grouped) {
+        updateVisibleGroupHeaders();
+        doLayout(NoAnimation);
+    }
+}
+
 void KItemListView::slotCurrentChanged(int current, int previous)
 {
     Q_UNUSED(previous)
@@ -1743,6 +1763,8 @@ void KItemListView::setModel(KItemModelBase *model)
         disconnect(m_model, &KItemModelBase::groupedSortingChanged, this, &KItemListView::slotGroupedSortingChanged);
         disconnect(m_model, &KItemModelBase::sortOrderChanged, this, &KItemListView::slotSortOrderChanged);
         disconnect(m_model, &KItemModelBase::sortRoleChanged, this, &KItemListView::slotSortRoleChanged);
+        disconnect(m_model, &KItemModelBase::groupOrderChanged, this, &KItemListView::slotGroupOrderChanged);
+        disconnect(m_model, &KItemModelBase::groupRoleChanged, this, &KItemListView::slotGroupRoleChanged);
 
         m_sizeHintResolver->itemsRemoved(KItemRangeList() << KItemRange(0, m_model->count()));
     }
@@ -2185,7 +2207,7 @@ void KItemListView::updateGroupHeaderForWidget(KItemListWidget *widget)
     const int groupIndex = groupIndexForItem(index);
     Q_ASSERT(groupIndex >= 0);
     groupHeader->setData(groups.at(groupIndex).second);
-    groupHeader->setRole(model()->sortRole());
+    groupHeader->setRole(model()->groupRole());
     groupHeader->setStyleOption(m_styleOption);
     groupHeader->setScrollOrientation(scrollOrientation());
     groupHeader->setItemIndex(index);