From e7c4b29a9ed55a5e32f69885cd1b4ceaa0414100 Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 28 Sep 2017 10:26:37 +0300 Subject: [PATCH] refs #1331: profiles points sorting --- src/CurveCreator/CurveCreator_TableView.cxx | 16 ++++++++++++++-- src/CurveCreator/CurveCreator_TableView.h | 5 ++++- src/CurveCreator/CurveCreator_Widget.h | 5 +++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/CurveCreator/CurveCreator_TableView.cxx b/src/CurveCreator/CurveCreator_TableView.cxx index 6cd0b35ae..a6d819dcd 100644 --- a/src/CurveCreator/CurveCreator_TableView.cxx +++ b/src/CurveCreator/CurveCreator_TableView.cxx @@ -19,6 +19,7 @@ #include "CurveCreator_TableView.h" #include "CurveCreator_UtilsICurve.hxx" +#include "CurveCreator_Widget.h" #include @@ -98,9 +99,10 @@ void CurveCreator_TableItemDelegate::setModelData( QWidget* theEditor, CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve, - QWidget* theParent, + CurveCreator_Widget* theParent, const QStringList& theCoordTitles ) - : QTableWidget( theParent ), myCurve( theCurve ), myCurrentSortId( -1 ), myCurrentSortOrder( Qt::AscendingOrder ) + : QTableWidget( theParent ), myWidget( theParent ), + myCurve( theCurve ), myCurrentSortId( -1 ), myCurrentSortOrder( Qt::AscendingOrder ) { setItemDelegate( new CurveCreator_TableItemDelegate( this ) ); setVisible( false ); @@ -209,5 +211,15 @@ void CurveCreator_TableView::OnHeaderClick( int theLogicalId ) myCurrentSortOrder = Qt::AscendingOrder; sortByColumn( theLogicalId, myCurrentSortOrder ); + + CurveCreator_ICurve::SectionToPointList selected; + for( int r=0, n=rowCount(); rdata( Qt::UserRole ).toInt(); + int point = item( r, 1 )->data( Qt::UserRole ).toInt(); + selected.push_back( CurveCreator_ICurve::SectionToPoint( section, point ) ); + } + myWidget->setSelectedPoints( selected ); + myCurrentSortId = theLogicalId; } diff --git a/src/CurveCreator/CurveCreator_TableView.h b/src/CurveCreator/CurveCreator_TableView.h index 67d813c17..c293e8344 100644 --- a/src/CurveCreator/CurveCreator_TableView.h +++ b/src/CurveCreator/CurveCreator_TableView.h @@ -25,6 +25,8 @@ #include #include +class CurveCreator_Widget; + class CurveCreator_TableItemDelegate : public QItemDelegate { public: @@ -44,7 +46,7 @@ class CurveCreator_TableView : public QTableWidget Q_OBJECT public: - CurveCreator_TableView( CurveCreator_ICurve* theCurve, QWidget* theParent = 0, + CurveCreator_TableView( CurveCreator_ICurve* theCurve, CurveCreator_Widget* theParent, const QStringList& theCoordTitles = QStringList() ); ~CurveCreator_TableView() {}; @@ -67,6 +69,7 @@ private slots: void OnHeaderClick( int ); private: + CurveCreator_Widget* myWidget; CurveCreator_ICurve* myCurve; int myCurrentSortId; diff --git a/src/CurveCreator/CurveCreator_Widget.h b/src/CurveCreator/CurveCreator_Widget.h index da38404a6..bcde2f6d6 100644 --- a/src/CurveCreator/CurveCreator_Widget.h +++ b/src/CurveCreator/CurveCreator_Widget.h @@ -95,6 +95,9 @@ public: void SetViewer2DMode(const bool To2D); + void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& = + CurveCreator_ICurve::SectionToPointList() ); + signals: void selectionChanged(); void subOperationStarted( QWidget*, bool ); @@ -185,8 +188,6 @@ private: void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() ); void getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints ); - void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& = - CurveCreator_ICurve::SectionToPointList() ); void stopActionMode();