/src/gui/dialogs/qwizard.h

https://bitbucket.org/ultra_iter/qt-vtl · C Header · 268 lines · 184 code · 44 blank · 40 comment · 0 complexity · ec61148fdbf50b159639b1212e917b71 MD5 · raw file

  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
  4. ** All rights reserved.
  5. ** Contact: Nokia Corporation (qt-info@nokia.com)
  6. **
  7. ** This file is part of the QtGui module of the Qt Toolkit.
  8. **
  9. ** $QT_BEGIN_LICENSE:LGPL$
  10. ** GNU Lesser General Public License Usage
  11. ** This file may be used under the terms of the GNU Lesser General Public
  12. ** License version 2.1 as published by the Free Software Foundation and
  13. ** appearing in the file LICENSE.LGPL included in the packaging of this
  14. ** file. Please review the following information to ensure the GNU Lesser
  15. ** General Public License version 2.1 requirements will be met:
  16. ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  17. **
  18. ** In addition, as a special exception, Nokia gives you certain additional
  19. ** rights. These rights are described in the Nokia Qt LGPL Exception
  20. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  21. **
  22. ** GNU General Public License Usage
  23. ** Alternatively, this file may be used under the terms of the GNU General
  24. ** Public License version 3.0 as published by the Free Software Foundation
  25. ** and appearing in the file LICENSE.GPL included in the packaging of this
  26. ** file. Please review the following information to ensure the GNU General
  27. ** Public License version 3.0 requirements will be met:
  28. ** http://www.gnu.org/copyleft/gpl.html.
  29. **
  30. ** Other Usage
  31. ** Alternatively, this file may be used in accordance with the terms and
  32. ** conditions contained in a signed written agreement between you and Nokia.
  33. **
  34. **
  35. **
  36. **
  37. **
  38. ** $QT_END_LICENSE$
  39. **
  40. ****************************************************************************/
  41. #ifndef QWIZARD_H
  42. #define QWIZARD_H
  43. #include <QtGui/qdialog.h>
  44. QT_BEGIN_HEADER
  45. QT_BEGIN_NAMESPACE
  46. QT_MODULE(Gui)
  47. #ifndef QT_NO_WIZARD
  48. class QAbstractButton;
  49. class QWizardPage;
  50. class QWizardPrivate;
  51. class Q_GUI_EXPORT QWizard : public QDialog
  52. {
  53. Q_OBJECT
  54. Q_ENUMS(WizardStyle WizardOption)
  55. Q_FLAGS(WizardOptions)
  56. Q_PROPERTY(WizardStyle wizardStyle READ wizardStyle WRITE setWizardStyle)
  57. Q_PROPERTY(WizardOptions options READ options WRITE setOptions)
  58. Q_PROPERTY(Qt::TextFormat titleFormat READ titleFormat WRITE setTitleFormat)
  59. Q_PROPERTY(Qt::TextFormat subTitleFormat READ subTitleFormat WRITE setSubTitleFormat)
  60. Q_PROPERTY(int startId READ startId WRITE setStartId)
  61. Q_PROPERTY(int currentId READ currentId NOTIFY currentIdChanged)
  62. public:
  63. enum WizardButton {
  64. BackButton,
  65. NextButton,
  66. CommitButton,
  67. FinishButton,
  68. CancelButton,
  69. HelpButton,
  70. CustomButton1,
  71. CustomButton2,
  72. CustomButton3,
  73. Stretch,
  74. NoButton = -1,
  75. NStandardButtons = 6,
  76. NButtons = 9
  77. };
  78. enum WizardPixmap {
  79. WatermarkPixmap,
  80. LogoPixmap,
  81. BannerPixmap,
  82. BackgroundPixmap,
  83. NPixmaps
  84. };
  85. enum WizardStyle {
  86. ClassicStyle,
  87. ModernStyle,
  88. MacStyle,
  89. AeroStyle,
  90. NStyles
  91. };
  92. enum WizardOption {
  93. IndependentPages = 0x00000001,
  94. IgnoreSubTitles = 0x00000002,
  95. ExtendedWatermarkPixmap = 0x00000004,
  96. NoDefaultButton = 0x00000008,
  97. NoBackButtonOnStartPage = 0x00000010,
  98. NoBackButtonOnLastPage = 0x00000020,
  99. DisabledBackButtonOnLastPage = 0x00000040,
  100. HaveNextButtonOnLastPage = 0x00000080,
  101. HaveFinishButtonOnEarlyPages = 0x00000100,
  102. NoCancelButton = 0x00000200,
  103. CancelButtonOnLeft = 0x00000400,
  104. HaveHelpButton = 0x00000800,
  105. HelpButtonOnRight = 0x00001000,
  106. HaveCustomButton1 = 0x00002000,
  107. HaveCustomButton2 = 0x00004000,
  108. HaveCustomButton3 = 0x00008000
  109. };
  110. Q_DECLARE_FLAGS(WizardOptions, WizardOption)
  111. explicit QWizard(QWidget *parent = 0, Qt::WindowFlags flags = 0);
  112. ~QWizard();
  113. int addPage(QWizardPage *page);
  114. void setPage(int id, QWizardPage *page);
  115. void removePage(int id);
  116. QWizardPage *page(int id) const;
  117. bool hasVisitedPage(int id) const;
  118. QList<int> visitedPages() const; // ### visitedIds()?
  119. QList<int> pageIds() const;
  120. void setStartId(int id);
  121. int startId() const;
  122. QWizardPage *currentPage() const;
  123. int currentId() const;
  124. virtual bool validateCurrentPage();
  125. virtual int nextId() const;
  126. void setField(const QString &name, const QVariant &value);
  127. QVariant field(const QString &name) const;
  128. void setWizardStyle(WizardStyle style);
  129. WizardStyle wizardStyle() const;
  130. void setOption(WizardOption option, bool on = true);
  131. bool testOption(WizardOption option) const;
  132. void setOptions(WizardOptions options);
  133. WizardOptions options() const;
  134. void setButtonText(WizardButton which, const QString &text);
  135. QString buttonText(WizardButton which) const;
  136. void setButtonLayout(const QList<WizardButton> &layout);
  137. void setButton(WizardButton which, QAbstractButton *button);
  138. QAbstractButton *button(WizardButton which) const;
  139. void setTitleFormat(Qt::TextFormat format);
  140. Qt::TextFormat titleFormat() const;
  141. void setSubTitleFormat(Qt::TextFormat format);
  142. Qt::TextFormat subTitleFormat() const;
  143. void setPixmap(WizardPixmap which, const QPixmap &pixmap);
  144. QPixmap pixmap(WizardPixmap which) const;
  145. void setSideWidget(QWidget *widget);
  146. QWidget *sideWidget() const;
  147. void setDefaultProperty(const char *className, const char *property,
  148. const char *changedSignal);
  149. void setVisible(bool visible);
  150. QSize sizeHint() const;
  151. Q_SIGNALS:
  152. void currentIdChanged(int id);
  153. void helpRequested();
  154. void customButtonClicked(int which);
  155. void pageAdded(int id);
  156. void pageRemoved(int id);
  157. public Q_SLOTS:
  158. void back();
  159. void next();
  160. void restart();
  161. protected:
  162. bool event(QEvent *event);
  163. void resizeEvent(QResizeEvent *event);
  164. void paintEvent(QPaintEvent *event);
  165. #if defined(Q_WS_WIN)
  166. bool winEvent(MSG * message, long * result);
  167. #endif
  168. void done(int result);
  169. virtual void initializePage(int id);
  170. virtual void cleanupPage(int id);
  171. private:
  172. Q_DISABLE_COPY(QWizard)
  173. Q_DECLARE_PRIVATE(QWizard)
  174. Q_PRIVATE_SLOT(d_func(), void _q_emitCustomButtonClicked())
  175. Q_PRIVATE_SLOT(d_func(), void _q_updateButtonStates())
  176. Q_PRIVATE_SLOT(d_func(), void _q_handleFieldObjectDestroyed(QObject *))
  177. friend class QWizardPage;
  178. };
  179. Q_DECLARE_OPERATORS_FOR_FLAGS(QWizard::WizardOptions)
  180. class QWizardPagePrivate;
  181. class Q_GUI_EXPORT QWizardPage : public QWidget
  182. {
  183. Q_OBJECT
  184. Q_PROPERTY(QString title READ title WRITE setTitle)
  185. Q_PROPERTY(QString subTitle READ subTitle WRITE setSubTitle)
  186. public:
  187. QWizardPage(QWidget *parent = 0);
  188. void setTitle(const QString &title);
  189. QString title() const;
  190. void setSubTitle(const QString &subTitle);
  191. QString subTitle() const;
  192. void setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap);
  193. QPixmap pixmap(QWizard::WizardPixmap which) const;
  194. void setFinalPage(bool finalPage);
  195. bool isFinalPage() const;
  196. void setCommitPage(bool commitPage);
  197. bool isCommitPage() const;
  198. void setButtonText(QWizard::WizardButton which, const QString &text);
  199. QString buttonText(QWizard::WizardButton which) const;
  200. virtual void initializePage();
  201. virtual void cleanupPage();
  202. virtual bool validatePage();
  203. virtual bool isComplete() const;
  204. virtual int nextId() const;
  205. Q_SIGNALS:
  206. void completeChanged();
  207. protected:
  208. void setField(const QString &name, const QVariant &value);
  209. QVariant field(const QString &name) const;
  210. void registerField(const QString &name, QWidget *widget, const char *property = 0,
  211. const char *changedSignal = 0);
  212. QWizard *wizard() const;
  213. private:
  214. Q_DISABLE_COPY(QWizardPage)
  215. Q_DECLARE_PRIVATE(QWizardPage)
  216. Q_PRIVATE_SLOT(d_func(), void _q_maybeEmitCompleteChanged())
  217. Q_PRIVATE_SLOT(d_func(), void _q_updateCachedCompleteState())
  218. friend class QWizard;
  219. friend class QWizardPrivate;
  220. };
  221. QT_END_NAMESPACE
  222. QT_END_HEADER
  223. #endif // QT_NO_WIZARD
  224. #endif // QWIZARD_H