Salome HOME
Merge remote-tracking branch 'origin/BR_1321_ECW' into BR_DEMO
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Wizard.cxx
index fd393ae53870eab2bcc655a17e83c4ed76a3e878..7ad59940233f81c734ac11014124b0197d77cbe9 100644 (file)
@@ -69,8 +69,9 @@ int HYDROGUI_Wizard::addPage( QWizardPage* thePage )
 {
   if ( myWizard->count() > 0 )
   {
-    myNext->setVisible( true );
-    myFinish->setVisible( false );
+    SetButtonsState(false);
+    /*myNext->setVisible( true );
+    myFinish->setVisible( false );*/
   }
   return myWizard->addWidget( thePage );
 }
@@ -85,11 +86,12 @@ void HYDROGUI_Wizard::onNext()
 
   myBack->setEnabled( true );
   int aCurIdx = myWizard->currentIndex();
-  if ( aCurIdx == ( myWizard->count() - 2 ) )
+  if ( IsLastPage() )
   {
     // Go to the last page
-    myNext->setVisible( false );
-    myFinish->setVisible( true );
+    SetButtonsState( true );
+    /*myNext->setVisible( false );
+    myFinish->setVisible( true );*/
   }
   myWizard->setCurrentIndex( aCurIdx + 1 );
 
@@ -103,14 +105,16 @@ void HYDROGUI_Wizard::onBack()
 
   if ( myWizard->count() > 1 )
   {
-    myNext->setVisible( true );
-    myFinish->setVisible( false );
+    /*myNext->setVisible( true );
+    myFinish->setVisible( false );*/
+    SetButtonsState( false );
   }
   else
   {
     // Wizard has a single page - show finish
-    myNext->setVisible( false );
-    myFinish->setVisible( true );
+    SetButtonsState( true );
+    /*myNext->setVisible( false );
+    myFinish->setVisible( true );*/
   }
 
   int aCurIdx = myWizard->currentIndex();
@@ -129,8 +133,9 @@ void HYDROGUI_Wizard::onBack()
 void HYDROGUI_Wizard::onFirstPage()
 {
   if ( myWizard->count() > 1 ) {
-    myNext->setVisible( true );
-    myFinish->setVisible( false );
+    /*myNext->setVisible( true );
+    myFinish->setVisible( false );*/
+    SetButtonsState( false );
     myWizard->setCurrentIndex( 0 );
     myBack->setEnabled( false );
     emit Back( myWizard->currentIndex() );
@@ -163,4 +168,26 @@ QAbstractButton* HYDROGUI_Wizard::button( QWizard::WizardButton theBtnId ) const
       aRes = myHelp;
   }
   return aRes;
+}
+
+bool HYDROGUI_Wizard::IsLastPage()
+{
+  if ( myWizard->currentIndex() == ( myWizard->count() - 2 ))
+    return true;
+  else
+    return false;
+}
+
+void HYDROGUI_Wizard::SetButtonsState (bool IsLastPage)
+{
+  if (!IsLastPage)
+  {
+    myNext->setVisible( true );
+    myFinish->setVisible( false );
+  }
+  else
+  {
+    myNext->setVisible( false );
+    myFinish->setVisible( true );
+  }
 }
\ No newline at end of file