Salome HOME
Ref #250 - Fatal error after Join all selections operation
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_TreeView.cxx
index 800546cfd50cfc41395cea92e9a9a95d1f528ad8..ce580d5357ee720a045f3b2ceed086832bba7add 100755 (executable)
@@ -249,43 +249,9 @@ QList<int> CurveCreator_TreeView::getSelectedSections() const
       aSect << aModel->getSection( anIndxs[i] );
     }
   }
-  qSort(aSect.begin(), aSect.end());
   return aSect;
 }
 
-void CurveCreator_TreeView::pointsAdded( int theSection, int thePoint, int thePointsCnt )
-{
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
-  if( aModel ){
-    QModelIndex aSectIndx = aModel->sectionIndex( theSection );
-    rowsInserted(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
-//    expand( aSectIndx );
-    update( aModel->nbPointsIndex( theSection ) );
-  }
-}
-
-void CurveCreator_TreeView::pointDataChanged( int theSection, int thePoint )
-{
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
-  if( aModel ){
-    QModelIndex aPointIndx = aModel->pointIndex( theSection, thePoint );
-    dataChanged( aPointIndx, aPointIndx );
-  }
-}
-
-void CurveCreator_TreeView::pointsRemoved( int theSection, int thePoint, int thePointsCnt )
-{
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
-  if( aModel ){
-    for( int i = 0 ; i < thePointsCnt ; i++ ){
-      QModelIndex aSectIndx = aModel->pointIndex(theSection, thePoint + i);
-      selectionModel()->select(aSectIndx,QItemSelectionModel::Deselect);
-    }
-    QModelIndex aSectIndx = aModel->sectionIndex( theSection );
-    rowsRemoved(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
-  }
-}
-
 void CurveCreator_TreeView::sectionAdded( int theSection )
 {
   CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
@@ -365,16 +331,6 @@ void CurveCreator_TreeView::sectionsSwapped( int theSection, int theOffset )
   }
 }
 
-void CurveCreator_TreeView::pointsSwapped( int theSection, int thePointNum, int theOffset )
-{
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
-  if( aModel ){
-    QModelIndex aFirstIndex = aModel->pointIndex( theSection, thePointNum );
-    QModelIndex aSecondIndex = aModel->pointIndex( theSection, thePointNum + theOffset );
-    swapIndexes( aFirstIndex, aSecondIndex );
-  }
-}
-
 void CurveCreator_TreeView::setSelectedSections( const QList<int>& theList )
 {
   CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
@@ -382,19 +338,7 @@ void CurveCreator_TreeView::setSelectedSections( const QList<int>& theList )
     selectionModel()->clearSelection();
     for( int i = 0 ; i < theList.size() ; i++ ){
       QModelIndex aSectIndx = aModel->sectionIndex(theList[i]);
-      selectionModel()->select(aSectIndx, QItemSelectionModel::Select );
-    }
-  }
-}
-
-void CurveCreator_TreeView::setSelectedPoints( const QList< QPair<int, int> >& thePointsList )
-{
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
-  if( aModel ){
-    selectionModel()->clearSelection();
-    for( int i = 0 ; i < thePointsList.size() ; i++ ){
-      QModelIndex aSectIndx = aModel->pointIndex( thePointsList[i].first, thePointsList[i].second );
-      selectionModel()->select(aSectIndx, QItemSelectionModel::Select );
+      selectionModel()->select(aSectIndx, QItemSelectionModel::Select | QItemSelectionModel::Rows );
     }
   }
 }
@@ -408,25 +352,6 @@ bool pointLessThan(const QPair<int,int> &s1, const QPair<int,int> &s2)
   return s1.second < s2.second;
 }
 
-QList< QPair< int, int > > CurveCreator_TreeView::getSelectedPoints() const
-{
-  QList< QPair< int, int > > aPoints;
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
-  if( !aModel )
-    return aPoints;
-  QModelIndexList anIndxs = selectionModel()->selectedIndexes();
-  for( int i = 0 ; i < anIndxs.size() ; i++ ){
-    if( !aModel->isSection( anIndxs[i] ) ){
-      int aSect = aModel->getSection(anIndxs[i]);
-      int aPointNum = aModel->getPoint(anIndxs[i]);
-      QPair< int, int > aPoint = QPair<int,int>( aSect, aPointNum );
-      aPoints.push_back( aPoint );
-    }
-  }
-  qSort( aPoints.begin(), aPoints.end(), pointLessThan );
-  return aPoints;
-}
-
 CurveCreator_TreeView::SelectionType CurveCreator_TreeView::getSelectionType() const
 {
   CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
@@ -474,10 +399,7 @@ void CurveCreator_TreeView::onActivated( QModelIndex theIndx )
   int aSect = aModel->getSection(theIndx);
   if( aModel->isSection(theIndx) ){
     emit sectionEntered( aSect );
-    return;
   }
-  int aPointNum = aModel->getPoint( theIndx );
-  emit pointEntered( aSect, aPointNum );
 }
 
 void CurveCreator_TreeView::setCurve( CurveCreator_ICurve* theCurve )
@@ -487,3 +409,10 @@ void CurveCreator_TreeView::setCurve( CurveCreator_ICurve* theCurve )
     aModel->setCurve(theCurve);
   reset();
 }
+
+void CurveCreator_TreeView::reset()
+{
+  QList<int> aSelSections = getSelectedSections();
+  QTreeView::reset();
+  setSelectedSections(aSelSections);
+}