Salome HOME
PR: quadtree
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Wizard.cxx
index 8acc5641fbba099e2ad46ea6f6bf95fa790e7e47..35707867c75380e4f0d562cda2427f3f40e26a4d 100644 (file)
@@ -81,28 +81,30 @@ int HYDROGUI_Wizard::addPage( QWizardPage* thePage )
 
 void HYDROGUI_Wizard::onNext()
 {
-  if ( myWizard->count() > 0 )
+  if ( !acceptCurrent() )
+    return;
+
+  if ( myWizard->count() <= 0 )
+    return;
+
+  myBack->setEnabled( true );
+  int aCurIdx = myWizard->currentIndex();
+  if ( aCurIdx == ( myWizard->count() - 2 ) )
   {
-    myBack->setEnabled( true );
-    int aCurIdx = myWizard->currentIndex();
-    if ( aCurIdx == ( myWizard->count() - 2 ) )
-    {
-      // Go to the last page
-      myNext->setVisible( false );
-      myFinish->setVisible( true );
-    }
-    myWizard->setCurrentIndex( aCurIdx + 1 );
+    // Go to the last page
+    myNext->setVisible( false );
+    myFinish->setVisible( true );
   }
+  myWizard->setCurrentIndex( aCurIdx + 1 );
+
+  emit Next( myWizard->currentIndex() );
 }
 
 void HYDROGUI_Wizard::onBack()
 {
-  int aCurIdx = myWizard->currentIndex();
-  if ( aCurIdx <= 1 )
-  {
-    // Disable back if go to the first page
-    myBack->setEnabled( false );
-  }
+  if ( myWizard->count() <= 0 )
+    return;
+
   if ( myWizard->count() > 1 )
   {
     myNext->setVisible( true );
@@ -114,7 +116,23 @@ void HYDROGUI_Wizard::onBack()
     myNext->setVisible( false );
     myFinish->setVisible( true );
   }
+
+  int aCurIdx = myWizard->currentIndex();
   myWizard->setCurrentIndex( aCurIdx - 1 );
+
+  aCurIdx = myWizard->currentIndex();
+  if ( aCurIdx <= 0 )
+  {
+    // Disable back if go to the first page
+    myBack->setEnabled( false );
+  }
+
+  emit Back( aCurIdx );
+}
+
+bool HYDROGUI_Wizard::acceptCurrent() const
+{
+  return true;
 }
 
 QAbstractButton* HYDROGUI_Wizard::button( QWizard::WizardButton theBtnId ) const