]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.cpp
Allow custom sorting of details-view columns
[dolphin.git] / src / kitemviews / kitemlistview.cpp
index 3d8224adb6bfd99d9c753f03b661f3036515297f..a54e06ddca22151fb243c6a935b05fc565414dad 100644 (file)
@@ -619,6 +619,8 @@ void KItemListView::setHeaderShown(bool show)
 
         connect(m_header, SIGNAL(visibleRoleWidthChanged(QByteArray,qreal,qreal)),
                 this, SLOT(slotVisibleRoleWidthChanged(QByteArray,qreal,qreal)));
+        connect(m_header, SIGNAL(visibleRoleMoved(QByteArray,int,int)),
+                this, SLOT(slotVisibleRoleMoved(QByteArray,int,int)));
         connect(m_header, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
                 this, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
         connect(m_header, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
@@ -1237,6 +1239,23 @@ void KItemListView::slotVisibleRoleWidthChanged(const QByteArray& role,
     }
 }
 
+void KItemListView::slotVisibleRoleMoved(const QByteArray& role,
+                                         int currentIndex,
+                                         int previousIndex)
+{
+    Q_ASSERT(m_visibleRoles[previousIndex] == role);
+
+    const QList<QByteArray> previous = m_visibleRoles;
+
+    QList<QByteArray> current = m_visibleRoles;
+    current.removeAt(previousIndex);
+    current.insert(currentIndex, role);
+
+    setVisibleRoles(current);
+
+    emit visibleRolesChanged(current, previous);
+}
+
 void KItemListView::triggerAutoScrolling()
 {
     if (!m_autoScrollTimer) {