qwizard.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtGui module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QWIZARD_H
00043 #define QWIZARD_H
00044 
00045 #include <QtGui/qdialog.h>
00046 
00047 QT_BEGIN_HEADER
00048 
00049 QT_BEGIN_NAMESPACE
00050 
00051 QT_MODULE(Gui)
00052 
00053 #ifndef QT_NO_WIZARD
00054 
00055 class QAbstractButton;
00056 class QWizardPage;
00057 class QWizardPrivate;
00058 
00059 class Q_GUI_EXPORT QWizard : public QDialog
00060 {
00061     Q_OBJECT
00062     Q_ENUMS(WizardStyle WizardOption)
00063     Q_FLAGS(WizardOptions)
00064     Q_PROPERTY(WizardStyle wizardStyle READ wizardStyle WRITE setWizardStyle)
00065     Q_PROPERTY(WizardOptions options READ options WRITE setOptions)
00066     Q_PROPERTY(Qt::TextFormat titleFormat READ titleFormat WRITE setTitleFormat)
00067     Q_PROPERTY(Qt::TextFormat subTitleFormat READ subTitleFormat WRITE setSubTitleFormat)
00068     Q_PROPERTY(int startId READ startId WRITE setStartId)
00069     Q_PROPERTY(int currentId READ currentId NOTIFY currentIdChanged)
00070 
00071 public:
00072     enum WizardButton {
00073         BackButton,
00074         NextButton,
00075         CommitButton,
00076         FinishButton,
00077         CancelButton,
00078         HelpButton,
00079         CustomButton1,
00080         CustomButton2,
00081         CustomButton3,
00082         Stretch,
00083 
00084         NoButton = -1,
00085         NStandardButtons = 6,
00086         NButtons = 9
00087     };
00088 
00089     enum WizardPixmap {
00090         WatermarkPixmap,
00091         LogoPixmap,
00092         BannerPixmap,
00093         BackgroundPixmap,
00094         NPixmaps
00095     };
00096 
00097     enum WizardStyle {
00098         ClassicStyle,
00099         ModernStyle,
00100         MacStyle,
00101         AeroStyle,
00102         NStyles
00103     };
00104 
00105     enum WizardOption {
00106         IndependentPages                = 0x00000001,
00107         IgnoreSubTitles                 = 0x00000002,
00108         ExtendedWatermarkPixmap         = 0x00000004,
00109         NoDefaultButton                 = 0x00000008,
00110         NoBackButtonOnStartPage         = 0x00000010,
00111         NoBackButtonOnLastPage          = 0x00000020,
00112         DisabledBackButtonOnLastPage    = 0x00000040,
00113         HaveNextButtonOnLastPage        = 0x00000080,
00114         HaveFinishButtonOnEarlyPages    = 0x00000100,
00115         NoCancelButton                  = 0x00000200,
00116         CancelButtonOnLeft              = 0x00000400,
00117         HaveHelpButton                  = 0x00000800,
00118         HelpButtonOnRight               = 0x00001000,
00119         HaveCustomButton1               = 0x00002000,
00120         HaveCustomButton2               = 0x00004000,
00121         HaveCustomButton3               = 0x00008000
00122     };
00123 
00124     Q_DECLARE_FLAGS(WizardOptions, WizardOption)
00125 
00126     explicit QWizard(QWidget *parent = 0, Qt::WindowFlags flags = 0);
00127     ~QWizard();
00128 
00129     int addPage(QWizardPage *page);
00130     void setPage(int id, QWizardPage *page);
00131     void removePage(int id);
00132     QWizardPage *page(int id) const;
00133     bool hasVisitedPage(int id) const;
00134     QList<int> visitedPages() const;    // ### visitedIds()?
00135     QList<int> pageIds() const;
00136     void setStartId(int id);
00137     int startId() const;
00138     QWizardPage *currentPage() const;
00139     int currentId() const;
00140 
00141     virtual bool validateCurrentPage();
00142     virtual int nextId() const;
00143 
00144     void setField(const QString &name, const QVariant &value);
00145     QVariant field(const QString &name) const;
00146 
00147     void setWizardStyle(WizardStyle style);
00148     WizardStyle wizardStyle() const;
00149 
00150     void setOption(WizardOption option, bool on = true);
00151     bool testOption(WizardOption option) const;
00152     void setOptions(WizardOptions options);
00153     WizardOptions options() const;
00154 
00155     void setButtonText(WizardButton which, const QString &text);
00156     QString buttonText(WizardButton which) const;
00157     void setButtonLayout(const QList<WizardButton> &layout);
00158     void setButton(WizardButton which, QAbstractButton *button);
00159     QAbstractButton *button(WizardButton which) const;
00160 
00161     void setTitleFormat(Qt::TextFormat format);
00162     Qt::TextFormat titleFormat() const;
00163     void setSubTitleFormat(Qt::TextFormat format);
00164     Qt::TextFormat subTitleFormat() const;
00165     void setPixmap(WizardPixmap which, const QPixmap &pixmap);
00166     QPixmap pixmap(WizardPixmap which) const;
00167 
00168     void setSideWidget(QWidget *widget);
00169     QWidget *sideWidget() const;
00170 
00171     void setDefaultProperty(const char *className, const char *property,
00172                             const char *changedSignal);
00173 
00174     void setVisible(bool visible);
00175     QSize sizeHint() const;
00176 
00177 Q_SIGNALS:
00178     void currentIdChanged(int id);
00179     void helpRequested();
00180     void customButtonClicked(int which);
00181     void pageAdded(int id);
00182     void pageRemoved(int id);
00183 
00184 public Q_SLOTS:
00185     void back();
00186     void next();
00187     void restart();
00188 
00189 protected:
00190     bool event(QEvent *event);
00191     void resizeEvent(QResizeEvent *event);
00192     void paintEvent(QPaintEvent *event);
00193 #if defined(Q_WS_WIN)
00194     bool winEvent(MSG * message, long * result);
00195 #endif
00196     void done(int result);
00197     virtual void initializePage(int id);
00198     virtual void cleanupPage(int id);
00199 
00200 private:
00201     Q_DISABLE_COPY(QWizard)
00202     Q_DECLARE_PRIVATE(QWizard)
00203     Q_PRIVATE_SLOT(d_func(), void _q_emitCustomButtonClicked())
00204     Q_PRIVATE_SLOT(d_func(), void _q_updateButtonStates())
00205     Q_PRIVATE_SLOT(d_func(), void _q_handleFieldObjectDestroyed(QObject *))
00206 
00207     friend class QWizardPage;
00208 };
00209 
00210 Q_DECLARE_OPERATORS_FOR_FLAGS(QWizard::WizardOptions)
00211 
00212 class QWizardPagePrivate;
00213 
00214 class Q_GUI_EXPORT QWizardPage : public QWidget
00215 {
00216     Q_OBJECT
00217     Q_PROPERTY(QString title READ title WRITE setTitle)
00218     Q_PROPERTY(QString subTitle READ subTitle WRITE setSubTitle)
00219 
00220 public:
00221     QWizardPage(QWidget *parent = 0);
00222 
00223     void setTitle(const QString &title);
00224     QString title() const;
00225     void setSubTitle(const QString &subTitle);
00226     QString subTitle() const;
00227     void setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap);
00228     QPixmap pixmap(QWizard::WizardPixmap which) const;
00229     void setFinalPage(bool finalPage);
00230     bool isFinalPage() const;
00231     void setCommitPage(bool commitPage);
00232     bool isCommitPage() const;
00233     void setButtonText(QWizard::WizardButton which, const QString &text);
00234     QString buttonText(QWizard::WizardButton which) const;
00235 
00236     virtual void initializePage();
00237     virtual void cleanupPage();
00238     virtual bool validatePage();
00239     virtual bool isComplete() const;
00240     virtual int nextId() const;
00241 
00242 Q_SIGNALS:
00243     void completeChanged();
00244 
00245 protected:
00246     void setField(const QString &name, const QVariant &value);
00247     QVariant field(const QString &name) const;
00248     void registerField(const QString &name, QWidget *widget, const char *property = 0,
00249                        const char *changedSignal = 0);
00250     QWizard *wizard() const;
00251 
00252 private:
00253     Q_DISABLE_COPY(QWizardPage)
00254     Q_DECLARE_PRIVATE(QWizardPage)
00255     Q_PRIVATE_SLOT(d_func(), void _q_maybeEmitCompleteChanged())
00256     Q_PRIVATE_SLOT(d_func(), void _q_updateCachedCompleteState())
00257 
00258     friend class QWizard;
00259     friend class QWizardPrivate;
00260 };
00261 
00262 QT_END_NAMESPACE
00263 
00264 QT_END_HEADER
00265 
00266 #endif // QT_NO_WIZARD
00267 
00268 #endif // QWIZARD_H