]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
refs #1331: sorting of profiles points by column
authorasl <asl@opencascade.com>
Thu, 21 Sep 2017 13:34:35 +0000 (16:34 +0300)
committerasl <asl@opencascade.com>
Thu, 21 Sep 2017 13:34:35 +0000 (16:34 +0300)
src/CurveCreator/CurveCreator_TableView.cxx
src/CurveCreator/CurveCreator_TableView.h

index bda45103e5bb853f1bf6e54bea75ec9f47434ffb..6cd0b35ae4d2a4f331ccef53b748b9cc87b52f7c 100644 (file)
@@ -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;
 }
index bfc0e9b69b23db5c78d6bcd53c9e6eaae21f9f42..67d813c173058dd003cfba3d9fca99821c31ef2d 100644 (file)
@@ -69,6 +69,8 @@ private slots:
 private:
   CurveCreator_ICurve* myCurve;
 
+  int           myCurrentSortId;
+  Qt::SortOrder myCurrentSortOrder;
 };
 
 #endif // CURVECREATOR_TABLEVIEW_H