From 9eb1cac4b7661ff154c782c9d2933e5a060b2542 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Mon, 5 Feb 2007 23:18:22 +0000 Subject: [PATCH] update the header indicators corresponding to the current sort column and sort order svn path=/trunk/playground/utils/dolphin/; revision=630675 --- src/dolphindetailsview.cpp | 27 ++++++++++++++++++++++++++- src/dolphindetailsview.h | 16 ++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index e04ff7618..fc40d9585 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -19,19 +19,32 @@ ***************************************************************************/ #include "dolphindetailsview.h" + +#include #include "dolphinmainwindow.h" #include "dolphinview.h" - +#include "viewproperties.h" #include 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" diff --git a/src/dolphindetailsview.h b/src/dolphindetailsview.h index b438b3a33..e035d3c12 100644 --- a/src/dolphindetailsview.h +++ b/src/dolphindetailsview.h @@ -21,10 +21,9 @@ #ifndef DOLPHINDETAILSVIEW_H #define DOLPHINDETAILSVIEW_H +#include #include -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; }; -- 2.47.3