]> cloud.milkyroute.net Git - dolphin.git/commitdiff
update the header indicators corresponding to the current sort column and sort order
authorPeter Penz <peter.penz19@gmail.com>
Mon, 5 Feb 2007 23:18:22 +0000 (23:18 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 5 Feb 2007 23:18:22 +0000 (23:18 +0000)
svn path=/trunk/playground/utils/dolphin/; revision=630675

src/dolphindetailsview.cpp
src/dolphindetailsview.h

index e04ff76180f70496d3bd7245ce137d5b0b544b59..fc40d9585a4de15e8d7dc29ba17f4eb6c8cc86b7 100644 (file)
  ***************************************************************************/
 
 #include "dolphindetailsview.h"
+
+#include <assert.h>
 #include "dolphinmainwindow.h"
 #include "dolphinview.h"
-
+#include "viewproperties.h"
 #include <QHeaderView>
 
 DolphinDetailsView::DolphinDetailsView(DolphinView* parent) :
     QTreeView(parent),
     m_parentView(parent)
 {
+    assert(parent != 0);
+
     setAcceptDrops(true);
     setRootIsDecorated(false);
     setSortingEnabled(true);
     setUniformRowHeights(true);
+
+    const ViewProperties props(parent->url());
+    setSortIndicatorSection(props.sorting());
+    setSortIndicatorOrder(props.sortOrder());
+
+    connect(parent, SIGNAL(sortingChanged(DolphinView::Sorting)),
+            this, SLOT(setSortIndicatorSection(DolphinView::Sorting)));
+    connect(parent, SIGNAL(sortOrderChanged(Qt::SortOrder)),
+            this, SLOT(setSortIndicatorOrder(Qt::SortOrder)));
 }
 
 DolphinDetailsView::~DolphinDetailsView()
@@ -107,4 +120,16 @@ void DolphinDetailsView::dropEvent(QDropEvent* event)
     }
 }
 
+void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting)
+{
+    QHeaderView* headerView = header();
+    headerView->setSortIndicator(sorting, headerView->sortIndicatorOrder());
+}
+
+void DolphinDetailsView::setSortIndicatorOrder(Qt::SortOrder sortOrder)
+{
+    QHeaderView* headerView = header();
+    headerView->setSortIndicator(headerView->sortIndicatorSection(), sortOrder);
+}
+
 #include "dolphindetailsview.moc"
index b438b3a33527eb0a6d93d3bf368bd0f9f3e14105..e035d3c12b7a20027b1fa42ce257bceb4a5e54a0 100644 (file)
 #ifndef DOLPHINDETAILSVIEW_H
 #define DOLPHINDETAILSVIEW_H
 
+#include <dolphinview.h>
 #include <QTreeView>
 
-class DolphinView;
-
 /**
  * @brief Represents the details view which shows the name, size,
  *        date, permissions, owner and group of an item.
@@ -49,6 +48,19 @@ protected:
     virtual void dragEnterEvent(QDragEnterEvent* event);
     virtual void dropEvent(QDropEvent* event);
 
+private slots:
+    /**
+     * Sets the sort indicator section of the header view
+     * corresponding to \a sorting.
+     */
+    void setSortIndicatorSection(DolphinView::Sorting sorting);
+
+    /**
+     * Sets the sort indicator order of the header view
+     * corresponding to \a sortOrder.
+     */
+    void setSortIndicatorOrder(Qt::SortOrder sortOrder);
+
 private:
     DolphinView* m_parentView;
 };