1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef CUSTOMPROJECTWIZARDDIALOG_H
34 #define CUSTOMPROJECTWIZARDDIALOG_H
36 #include <QtGui/QComboBox>
37 #include <QtGui/QCheckBox>
38 #include <QtGui/QWizardPage>
39 #include <QtCore/QSharedPointer>
52 namespace ProjectExplorer {
55 struct CustomWizardField;
56 struct CustomWizardParameters;
57 struct CustomWizardContext;
59 // A non-editable combo for text editing purposes that plays
60 // with QWizard::registerField (providing a settable 'text' property).
61 // Allows for a separation of values to be used for wizard fields replacement
63 class TextFieldComboBox : public QComboBox {
64 Q_PROPERTY(QString text READ text WRITE setText)
67 explicit TextFieldComboBox(QWidget *parent = 0);
70 void setText(const QString &s);
72 void setItems(const QStringList &displayTexts, const QStringList &values);
75 void text4Changed(const QString &); // Do not conflict with Qt 3 compat signal.
78 void slotCurrentIndexChanged(int);
81 inline QString valueAt(int) const;
84 // A Checkbox that plays with QWizard::registerField (providing a settable
85 // 'text' property containing predefined strings for 'true'/'false').
86 class TextFieldCheckBox : public QCheckBox {
87 Q_PROPERTY(QString text READ text WRITE setText)
88 Q_PROPERTY(QString trueText READ trueText WRITE setTrueText)
89 Q_PROPERTY(QString falseText READ falseText WRITE setFalseText)
92 explicit TextFieldCheckBox(const QString &text, QWidget *parent = 0);
95 void setText(const QString &s);
97 void setTrueText(const QString &t) { m_trueText = t; }
98 QString trueText() const { return m_trueText; }
99 void setFalseText(const QString &t) { m_falseText = t; }
100 QString falseText() const { return m_falseText; }
103 void textChanged(const QString &);
106 void slotStateChanged(int);
113 // A simple custom wizard page presenting the fields to be used
114 // as page 2 of a BaseProjectWizardDialog if there are any fields.
115 // Uses the 'field' functionality of QWizard.
116 // Implements validatePage() as the field logic cannot be tied up
117 // with additional validation. Performs checking of the Javascript-based
118 // validation rules of the parameters and displays error messages in a red
120 class CustomWizardFieldPage : public QWizardPage {
123 typedef QList<CustomWizardField> FieldList;
125 explicit CustomWizardFieldPage(const QSharedPointer<CustomWizardContext> &ctx,
126 const QSharedPointer<CustomWizardParameters> ¶meters,
127 QWidget *parent = 0);
128 virtual ~CustomWizardFieldPage();
130 virtual bool validatePage();
131 virtual void initializePage();
133 static QMap<QString, QString> replacementMap(const QWizard *w,
134 const QSharedPointer<CustomWizardContext> &ctx,
138 inline void addRow(const QString &name, QWidget *w);
139 void showError(const QString &);
142 struct LineEditData {
143 explicit LineEditData(QLineEdit* le = 0, const QString &defText = QString());
147 struct TextEditData {
148 explicit TextEditData(QTextEdit* le = 0, const QString &defText = QString());
152 typedef QList<LineEditData> LineEditDataList;
153 typedef QList<TextEditData> TextEditDataList;
155 QWidget *registerLineEdit(const QString &fieldName, const CustomWizardField &field);
156 QWidget *registerComboBox(const QString &fieldName, const CustomWizardField &field);
157 QWidget *registerTextEdit(const QString &fieldName, const CustomWizardField &field);
158 QWidget *registerPathChooser(const QString &fieldName, const CustomWizardField &field);
159 QWidget *registerCheckBox(const QString &fieldName,
160 const QString &fieldDescription,
161 const CustomWizardField &field);
162 void addField(const CustomWizardField &f);
164 const QSharedPointer<CustomWizardParameters> m_parameters;
165 const QSharedPointer<CustomWizardContext> m_context;
166 QFormLayout *m_formLayout;
167 LineEditDataList m_lineEdits;
168 TextEditDataList m_textEdits;
169 QLabel *m_errorLabel;
172 // A custom wizard page presenting the fields to be used and a path chooser
173 // at the bottom (for use by "class"/"file" wizards). Does validation on
174 // the Path chooser only (as the other fields can by validated by regexps).
176 class CustomWizardPage : public CustomWizardFieldPage {
179 explicit CustomWizardPage(const QSharedPointer<CustomWizardContext> &ctx,
180 const QSharedPointer<CustomWizardParameters> ¶meters,
181 QWidget *parent = 0);
183 QString path() const;
184 void setPath(const QString &path);
186 virtual bool isComplete() const;
189 Utils::PathChooser *m_pathChooser;
192 } // namespace Internal
193 } // namespace ProjectExplorer
195 #endif // CUSTOMPROJECTWIZARDDIALOG_H