-// 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 <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 ),
QWidgetStack * ws;
QPtrList<Page> pages;
QLabel * title;
+ QHBox * titleBox;
+ QHBox * logoBox;
QPushButton * backButton;
QPushButton * nextButton;
QPushButton * finishButton;
d->current = 0; // not quite true, but...
d->ws = new QWidgetStack( this, "qt_widgetstack" );
d->pages.setAutoDelete( TRUE );
- d->title = new QLabel( this, "title label" );
+ d->titleBox = new QHBox( this, "title box" );
+ d->title = new QLabel( d->titleBox, "title label" );
+ d->logoBox = new QHBox( d->titleBox, "logo box" );
+ d->logoBox->setSpacing( 2 );
+ d->titleBox->setStretchFactor( d->title, 10 );
// create in nice tab order
d->nextButton = new QPushButton( this, "next" );
d->nextButton->setDefault( TRUE );
connect( d->backButton, SIGNAL(clicked()),
+ this, SIGNAL(backClicked()) );
+ connect( this, SIGNAL(backClicked()),
this, SLOT(back()) );
connect( d->nextButton, SIGNAL(clicked()),
+ this, SIGNAL(nextClicked()) );
+ connect( this, SIGNAL(nextClicked()),
this, SLOT(next()) );
connect( d->finishButton, SIGNAL(clicked()),
this, SLOT(accept()) );
#ifndef QT_NO_ACCEL
d->accel = new QAccel( this, "arrow-key accel" );
d->backAccel = d->accel->insertItem( Qt::ALT + Qt::Key_Left );
- d->accel->connectItem( d->backAccel, this, SLOT(back()) );
+ d->accel->connectItem( d->backAccel, this, SIGNAL(backClicked()) );
d->nextAccel = d->accel->insertItem( Qt::ALT + Qt::Key_Right );
- d->accel->connectItem( d->nextAccel, this, SLOT(next()) );
+ d->accel->connectItem( d->nextAccel, this, SIGNAL(nextClicked()) );
#endif
}
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 <---
}
}
void InstallWizard::layOutTitleRow( QHBoxLayout * layout, const QString & title )
{
d->title->setText( title );
- layout->addWidget( d->title, 10 );
+ layout->addWidget( d->titleBox, 10 );
}
/*!
*/
bool InstallWizard::acceptData( const QString& )
{
+ postValidateEvent( this );
return TRUE;
}
}
return 0;
}
+
+/*!
+Adds logo to be shown at the right of the page title
+*/
+void InstallWizard::addLogo( const QPixmap& pm )
+{
+ QLabel* logo = new QLabel( d->logoBox, "logo" );
+ logo->setPixmap( pm );
+ logo->setAlignment( AlignCenter );
+ logo->setScaledContents( false );
+ logo->show();
+}
+
+/*!
+Remove all logos
+*/
+void InstallWizard::removeLogos()
+{
+ QObjectList* children = d->logoBox->queryList( "QLabel" );
+ if ( children ) {
+ QObjectListIt it( *children );
+ QObject *obj;
+ while ( (obj = it.current()) != 0 ) {
+ ++it;
+ delete obj;
+ }
+ }
+ 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 );
+}