Salome HOME
Fix a bug of config file for RedHat 9 - correct binaries distribution path
[tools/install.git] / src / InstallWizard.cpp
index 84a80d8b955fb51808e366cf746db02691ffca53..e1beb403c012478ad72e663b09c537a7568f07a6 100644 (file)
@@ -1,29 +1,72 @@
-//  File      : InstallWizard.cpp
-//  Created   : Thu Mar 27 12:01:00 2003
-//  Author    : Vadim SANDLER
-//  Project   : PAL/SALOME
-//  Module    : InstallWizard
-//  Copyright : 2004 CEA
-//  $Header$ 
+/****************************************************************************
+** $Id$
+**
+** Definition of the QWizard class.
+**
+** Created : 990101
+**
+** Copyright (C) 1999 by Trolltech AS.  All rights reserved.
+**
+** This file is part of the dialogs module of the Qt GUI Toolkit.
+**
+** This file may be distributed under the terms of the Q Public License
+** as defined by Trolltech AS of Norway and appearing in the file
+** LICENSE.QPL included in the packaging of this file.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
+** licenses may use this file in accordance with the Qt Commercial License
+** Agreement provided with the Software.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
+**   information about Qt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
 
 #include "InstallWizard.h"
 
-#include "qlayout.h"
-#include "qpushbutton.h"
-#include "qcursor.h"
-#include "qlabel.h"
-#include "qwidgetstack.h"
-#include "qapplication.h"
-#include "qptrlist.h"
-#include "qpainter.h"
-#include "qaccel.h"
-#include "qhbox.h"
-#include "qobjectlist.h"
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qcursor.h>
+#include <qlabel.h>
+#include <qwidgetstack.h>
+#include <qapplication.h>
+#include <qptrlist.h>
+#include <qpainter.h>
+#include <qaccel.h>
+#include <qhbox.h>
+#include <qobjectlist.h>
+#include <qthread.h>
+
+#define PROCESS_EVENT QEvent::User+100
+
+class ProcessEvent : public QCustomEvent
+{
+public:
+  ProcessEvent( int retValue = 0, void* data = 0 ): QCustomEvent( PROCESS_EVENT ), myReturnValue( retValue ), myData( data ) {} 
+  const int  returnValue() const { return myReturnValue; }
+  void*      data()        const { return myData; }
+private:
+  int   myReturnValue;
+  void* myData;
+};
 
 class InstallWizardPrivate
 {
 public:
-  struct Page {
+   struct Page {
     Page( QWidget * widget, const QString & title ):
           w( widget ), t( title ),
     backEnabled( TRUE ), nextEnabled( TRUE ), finishEnabled( FALSE ),
@@ -327,9 +370,21 @@ void InstallWizard::next()
   while ( i > 0 && (i >= (int)d->pages.count() || !d->pages.at( i ) ) )
     i--;
   if ( d->pages.at( i ) ) {
-    if ( d->current && !acceptData( d->current->t ) )
-      return;
-    showPage( d->pages.at( i )->w );
+    if ( d->current ) {
+      setNextEnabled( false );
+      setBackEnabled( false );
+      if ( !acceptData( d->current->t ) ) {
+        setNextEnabled( true );
+        setBackEnabled( true );
+        return;
+      }
+    }
+    // VSR : commented 10/02/05 --->
+    // Next page will be shown later in processValidateEvent() method
+    // this allows custom validation, for instance by using external processing threads.
+    // See SALOME_InstallWizard.cxx for details where it is used.
+    //showPage( d->pages.at( i )->w );
+    // VSR : commented 10/02/05 <---
   }
 }
 
@@ -715,6 +770,7 @@ Should return true in success
 */
 bool InstallWizard::acceptData( const QString& )
 {
+  postValidateEvent( this );
   return TRUE;
 }
 
@@ -853,3 +909,46 @@ void InstallWizard::removeLogos()
   }
   delete children;
 }
+
+/*!
+Posts validation event
+*/
+void InstallWizard::postValidateEvent( InstallWizard* iw, const int val, void* data )
+{
+  QThread::postEvent( iw, new ProcessEvent( val, data ) );
+}
+
+/*!
+Processes validation event: default implementation just to show next page
+*/
+void InstallWizard::processValidateEvent( const int /* val */, void* /* data */ )
+{
+  int i = 0;
+  while( i < (int)d->pages.count() && d->pages.at( i ) &&
+    d->current && d->pages.at( i )->w != d->current->w )
+    i++;
+  i++;
+  while( i <= (int)d->pages.count()-1 &&
+    ( !d->pages.at( i ) || !appropriate( d->pages.at( i )->w ) ) )
+     i++;
+  // if we fell of the end of the world, step back
+  while ( i > 0 && (i >= (int)d->pages.count() || !d->pages.at( i ) ) )
+    i--;
+  if ( d->pages.at( i ) ) {
+    showPage( d->pages.at( i )->w );
+  }
+  setNextEnabled( true );
+  setBackEnabled( true );
+}
+
+/*!
+Process events received
+*/
+bool InstallWizard::event ( QEvent* e )
+{
+  if ( e->type() == PROCESS_EVENT ) {
+    ProcessEvent* pe = (ProcessEvent*)e;
+    processValidateEvent( pe->returnValue(), pe->data() );
+  }
+  return QDialog::event( e );
+}