Salome HOME
Double editor in table
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_Widget.cxx
index edcdb68c76598678b3d883ca7b3ad6325f28996c..56ae6c123358bb31b87f131dac788d00fccb8e93 100644 (file)
@@ -25,6 +25,7 @@
 //#include "CurveCreator_NewPointDlg.h"
 #include "CurveCreator_NewSectionDlg.h"
 #include "CurveCreator_Utils.h"
+#include "CurveCreator_TableView.h"
 
 #include <SUIT_Session.h>
 #include <SUIT_Desktop.h>
@@ -96,6 +97,7 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
   connect( mySectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint)) );
 
   myLocalPointView = new QTableWidget();
+  myLocalPointView->setItemDelegate( new CurveCreator_TableItemDelegate( myLocalPointView ) );
   myLocalPointView->setVisible( false );
   myLocalPointView->setColumnCount( 4 );
   myLocalPointView->setColumnWidth( 0, SECTION_NAME_COLUMN_WIDTH );
@@ -571,9 +573,14 @@ void CurveCreator_Widget::onModifySection()
   bool isClosed = myNewSectionEditor->isClosed();
   CurveCreator::SectionType aSectType = myNewSectionEditor->getSectionType();
 //  myCurve->startOperation();
-  myCurve->setClosed( isClosed, mySection );
-  myCurve->setSectionName( mySection , aName.toStdString() );
-  myCurve->setSectionType( mySection, aSectType );
+  if( myCurve->getSectionName(mySection) != aName.toStdString() )
+    myCurve->setSectionName( mySection , aName.toStdString() );
+
+  if( myCurve->getSectionType(mySection) != aSectType )
+    myCurve->setSectionType( mySection, aSectType );
+
+  if( myCurve->isClosed(mySection) != isClosed )
+    myCurve->setClosed( mySection, isClosed );
 //  myCurve->finishOperation();
   mySectionView->sectionChanged(mySection);
   updateUndoRedo();
@@ -706,7 +713,7 @@ void CurveCreator_Widget::onCloseSections()
 //  myCurve->startOperation();
   QList<int> aSelSections = mySectionView->getSelectedSections();
   for( int i = 0 ; i < aSelSections.size() ; i++ ){
-    myCurve->setClosed(true, aSelSections[i]);
+    myCurve->setClosed(aSelSections[i], true);
     mySectionView->sectionChanged(aSelSections[i]);
   }
 //  myCurve->finishOperation();
@@ -720,7 +727,7 @@ void CurveCreator_Widget::onUncloseSections()
 //  myCurve->startOperation();
   QList<int> aSelSections = mySectionView->getSelectedSections();
   for( int i = 0 ; i < aSelSections.size() ; i++ ){
-    myCurve->setClosed(false, aSelSections[i]);
+    myCurve->setClosed(aSelSections[i], false);
     mySectionView->sectionChanged(aSelSections[i]);
   }
 //  myCurve->finishOperation();
@@ -969,8 +976,8 @@ void CurveCreator_Widget::onCellChanged( int theRow, int theColumn )
   SectionToPointList aSelPoints;
   startCurveModification( aSelPoints );
 
-  double aX  = myLocalPointView->item( theRow, 2 )->text().toDouble();
-  double anY = myLocalPointView->item( theRow, 3 )->text().toDouble();
+  double aX  = myLocalPointView->item( theRow, 2 )->data( Qt::UserRole ).toDouble();
+  double anY = myLocalPointView->item( theRow, 3 )->data( Qt::UserRole ).toDouble();
   std::deque<float> aChangedPos;
   aChangedPos.push_back( aX );
   aChangedPos.push_back( anY );