From 21a4549eddab46fed5cceff05426fc6df373246a Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 8 Oct 2015 10:53:32 +0300 Subject: [PATCH] refs #587: sorting the point table by click on header --- src/CurveCreator/CurveCreator_TableView.cxx | 10 +++++++++- src/CurveCreator/CurveCreator_TableView.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/CurveCreator/CurveCreator_TableView.cxx b/src/CurveCreator/CurveCreator_TableView.cxx index b8fd0bf6e..fe4c2dd69 100644 --- a/src/CurveCreator/CurveCreator_TableView.cxx +++ b/src/CurveCreator/CurveCreator_TableView.cxx @@ -24,6 +24,7 @@ #include #include +#include #include @@ -109,6 +110,8 @@ CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve, //aLabels << tr( "SECTION_LABEL" ) << tr( "IDENTIFIER_LABEL" ) << aCoord1 << aCoord2; aLabels << tr( "TABLE_SECTION" ) << tr("TABLE_INDEX") << aCoord1 << aCoord2; setHorizontalHeaderLabels( aLabels ); + + connect( horizontalHeader(), SIGNAL( sectionClicked( int ) ), this, SLOT( OnHeaderClick( int ) ) ); } void CurveCreator_TableView::setCurve( CurveCreator_ICurve* theCurve ) @@ -131,7 +134,7 @@ void CurveCreator_TableView::setLocalPointsToTable( QTableWidgetItem* anItem; anItem = new QTableWidgetItem( myCurve->getSectionName( anISection ).c_str() ); - anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled ); + anItem->setFlags( anItem->flags() & ~Qt::ItemIsEditable ); anItem->setData( Qt::UserRole, anISection ); setItem( aRowId, 0, anItem ); @@ -176,3 +179,8 @@ int CurveCreator_TableView::getPointId( const int theRowId ) const { return item( theRowId, 1 )->data( Qt::UserRole ).toInt(); } + +void CurveCreator_TableView::OnHeaderClick( int theLogicalId ) +{ + sortByColumn( theLogicalId, Qt::AscendingOrder ); +} diff --git a/src/CurveCreator/CurveCreator_TableView.h b/src/CurveCreator/CurveCreator_TableView.h index e6e8d1cd6..6028e04dd 100644 --- a/src/CurveCreator/CurveCreator_TableView.h +++ b/src/CurveCreator/CurveCreator_TableView.h @@ -63,6 +63,9 @@ public: */ int getPointId( const int theRowId ) const; +private slots: + void OnHeaderClick( int ); + private: CurveCreator_ICurve* myCurve;