From 81f3aca1cb8465936e7cf352d48948deebf48622 Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 21 Sep 2017 16:34:35 +0300 Subject: [PATCH] refs #1331: sorting of profiles points by column --- src/CurveCreator/CurveCreator_TableView.cxx | 14 ++++++++++++-- src/CurveCreator/CurveCreator_TableView.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/CurveCreator/CurveCreator_TableView.cxx b/src/CurveCreator/CurveCreator_TableView.cxx index bda45103e..6cd0b35ae 100644 --- a/src/CurveCreator/CurveCreator_TableView.cxx +++ b/src/CurveCreator/CurveCreator_TableView.cxx @@ -94,10 +94,13 @@ void CurveCreator_TableItemDelegate::setModelData( QWidget* theEditor, QItemDelegate::setModelData( theEditor, theModel, theIndex ); } + + + CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve, QWidget* theParent, const QStringList& theCoordTitles ) -: QTableWidget( theParent ), myCurve( theCurve ) + : QTableWidget( theParent ), myCurve( theCurve ), myCurrentSortId( -1 ), myCurrentSortOrder( Qt::AscendingOrder ) { setItemDelegate( new CurveCreator_TableItemDelegate( this ) ); setVisible( false ); @@ -199,5 +202,12 @@ int CurveCreator_TableView::getPointId( const int theRowId ) const void CurveCreator_TableView::OnHeaderClick( int theLogicalId ) { - sortByColumn( theLogicalId, Qt::AscendingOrder ); + if( theLogicalId == myCurrentSortId ) + if( myCurrentSortOrder == Qt::AscendingOrder ) + myCurrentSortOrder = Qt::DescendingOrder; + else + myCurrentSortOrder = Qt::AscendingOrder; + + sortByColumn( theLogicalId, myCurrentSortOrder ); + myCurrentSortId = theLogicalId; } diff --git a/src/CurveCreator/CurveCreator_TableView.h b/src/CurveCreator/CurveCreator_TableView.h index bfc0e9b69..67d813c17 100644 --- a/src/CurveCreator/CurveCreator_TableView.h +++ b/src/CurveCreator/CurveCreator_TableView.h @@ -69,6 +69,8 @@ private slots: private: CurveCreator_ICurve* myCurve; + int myCurrentSortId; + Qt::SortOrder myCurrentSortOrder; }; #endif // CURVECREATOR_TABLEVIEW_H -- 2.39.2