From 85f20f97d458a4d2a8905baaf4a5977345599726 Mon Sep 17 00:00:00 2001 From: mzn Date: Fri, 13 Dec 2013 13:01:14 +0000 Subject: [PATCH] Bug #157: "Tab" button doesn't switch active spinboxes in Modification mode. --- .../CurveCreator_TableView.cxx | 79 +++++++++++-------- .../CurveCreator_TableView.h | 2 +- src/HYDROCurveCreator/CurveCreator_Widget.cxx | 7 +- 3 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/HYDROCurveCreator/CurveCreator_TableView.cxx b/src/HYDROCurveCreator/CurveCreator_TableView.cxx index b0c4d527..56d3a507 100644 --- a/src/HYDROCurveCreator/CurveCreator_TableView.cxx +++ b/src/HYDROCurveCreator/CurveCreator_TableView.cxx @@ -112,42 +112,51 @@ void CurveCreator_TableView::setCurve( CurveCreator_ICurve* theCurve ) myCurve = theCurve; } -void CurveCreator_TableView::addLocalPointToTable( - const CurveCreator_ICurve::SectionToPoint& theSToPoint ) +void CurveCreator_TableView::setLocalPointsToTable( + const CurveCreator_ICurve::SectionToPointList& thePoints ) { - int aRowId = rowCount(); - int anISection = theSToPoint.first; - int anIPoint = theSToPoint.second; - bool isFoundPoint = false; - for ( int i = 0; i < aRowId && !isFoundPoint; i++ ) - isFoundPoint = getSectionId( i ) == anISection && - getPointId( i ) == anIPoint; - if ( isFoundPoint ) - return; - - setRowCount( aRowId+1 ); - - QTableWidgetItem* anItem; - anItem = new QTableWidgetItem( myCurve->getSectionName( anISection ).c_str() ); - anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled ); - anItem->setData( Qt::UserRole, anISection ); - setItem( aRowId, 0, anItem ); - - anItem = new QTableWidgetItem( QString::number( anIPoint + 1 ) ); - anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled ); - anItem->setData( Qt::UserRole, anIPoint ); - setItem( aRowId, 1, anItem ); - - gp_Pnt aPoint; - CurveCreator_UtilsICurve::getPoint( myCurve, anISection, anIPoint, aPoint ); - - anItem = new QTableWidgetItem( QString::number( aPoint.X(), 'f', 2 ) ); - anItem->setData( Qt::UserRole, aPoint.X() ); - setItem( aRowId, 2, anItem ); - - anItem = new QTableWidgetItem( QString::number( aPoint.Y(), 'f', 2 ) ); - anItem->setData( Qt::UserRole, aPoint.Y() ); - setItem( aRowId, 3, anItem ); + setRowCount( thePoints.size() ); + + int aRowId = 0; + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(), + aLast = thePoints.end(); + for ( ; anIt != aLast; anIt++ ) { + CurveCreator_ICurve::SectionToPoint aSPoint = *anIt; + int anISection = aSPoint.first; + int anIPoint = aSPoint.second; + + QTableWidgetItem* anItem; + anItem = new QTableWidgetItem( myCurve->getSectionName( anISection ).c_str() ); + anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled ); + anItem->setData( Qt::UserRole, anISection ); + setItem( aRowId, 0, anItem ); + + anItem = new QTableWidgetItem( QString::number( anIPoint + 1 ) ); + anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled ); + anItem->setData( Qt::UserRole, anIPoint ); + setItem( aRowId, 1, anItem ); + + gp_Pnt aPoint; + CurveCreator_UtilsICurve::getPoint( myCurve, anISection, anIPoint, aPoint ); + + anItem = item( aRowId, 2 ); + if ( !anItem ) { + anItem = new QTableWidgetItem(); + setItem( aRowId, 2, anItem ); + } + anItem->setData( Qt::UserRole, aPoint.X() ); + anItem->setData( Qt::DisplayRole, QString::number( aPoint.X(), 'f', 2 ) ); + + anItem = item( aRowId, 3 ); + if ( !anItem ) { + anItem = new QTableWidgetItem(); + setItem( aRowId, 3, anItem ); + } + anItem->setData( Qt::UserRole, aPoint.Y() ); + anItem->setData( Qt::DisplayRole, QString::number( aPoint.Y(), 'f', 2 ) ); + + aRowId++; + } } int CurveCreator_TableView::getSectionId( const int theRowId ) const diff --git a/src/HYDROCurveCreator/CurveCreator_TableView.h b/src/HYDROCurveCreator/CurveCreator_TableView.h index bb8f7324..4cf381ba 100644 --- a/src/HYDROCurveCreator/CurveCreator_TableView.h +++ b/src/HYDROCurveCreator/CurveCreator_TableView.h @@ -47,7 +47,7 @@ public: void setCurve( CurveCreator_ICurve* theCurve ); - void addLocalPointToTable( const CurveCreator_ICurve::SectionToPoint& thePoint ); + void setLocalPointsToTable( const CurveCreator_ICurve::SectionToPointList& thePoints ); /** * Returns a section index from the table diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index 5fdb921d..72d7ffa7 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -1307,11 +1307,8 @@ void CurveCreator_Widget::updateLocalPointView() if ( !isRowLimit ) { bool isBlocked = myLocalPointView->blockSignals(true); - myLocalPointView->setRowCount( 0 ); - CurveCreator_ICurve::SectionToPointList::const_iterator anIt = myLocalPoints.begin(), - aLast = myLocalPoints.end(); - for ( ; anIt != aLast; anIt++ ) - myLocalPointView->addLocalPointToTable( *anIt ); + + myLocalPointView->setLocalPointsToTable( myLocalPoints ); myLocalPointView->blockSignals( isBlocked ); } -- 2.39.2