diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp index 716b843c3a35b632cb66c4c3df5532028a1818b6..9aa122e5602c744214a306a695195d1fe5ef71e7 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp @@ -31,6 +31,7 @@ #include "customwizardparameters.h" #include <utils/pathchooser.h> +#include <utils/qtcassert.h> #include <QtCore/QRegExp> #include <QtCore/QDebug> @@ -119,6 +120,7 @@ QWidget *CustomWizardFieldPage::registerControl(const CustomWizardField &field) } else { qWarning("Invalid custom wizard field validator regular expression %s.", qPrintable(validationRegExp)); } + m_validatorLineEdits.push_back(lineEdit); } lineEdit->setText(field.controlAttributes.value(QLatin1String("defaulttext"))); registerField(fieldName, lineEdit, "text", SIGNAL(textEdited(QString))); @@ -130,6 +132,22 @@ void CustomWizardFieldPage::addField(const CustomWizardField &field) addRow(field.description, registerControl(field)); } +bool CustomWizardFieldPage::validatePage() +{ + // Check line edits with validators + foreach(QLineEdit *le, m_validatorLineEdits) { + int pos = 0; + const QValidator *val = le->validator(); + QTC_ASSERT(val, return false); + QString text = le->text(); + if (val->validate(text, pos) != QValidator::Acceptable) { + le->setFocus(); + return false; + } + } + return true; +} + // --------------- CustomWizardPage CustomWizardPage::CustomWizardPage(const FieldList &f, diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.h b/src/plugins/projectexplorer/customwizard/customwizardpage.h index 26ec8e9910fcad2c2fcc4ba9636113a1abbe030b..ce1484ab0c31594a6db19efa55606e8638ea2001 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardpage.h +++ b/src/plugins/projectexplorer/customwizard/customwizardpage.h @@ -36,6 +36,7 @@ QT_BEGIN_NAMESPACE class QFormLayout; +class QLineEdit; QT_END_NAMESPACE namespace Utils { @@ -66,6 +67,8 @@ signals: // A simple custom wizard page presenting the fields to be used // as page 2 of a BaseProjectWizardDialog if there are any fields. // Uses the 'field' functionality of QWizard. +// Implements validatePage() as the field logic cannot be tied up +// with additional validation. class CustomWizardFieldPage : public QWizardPage { Q_OBJECT public: @@ -73,6 +76,8 @@ public: explicit CustomWizardFieldPage(const FieldList &f, QWidget *parent = 0); + virtual bool validatePage(); + protected: inline void addRow(const QString &name, QWidget *w); @@ -81,6 +86,7 @@ private: void addField(const CustomWizardField &f); QFormLayout *m_formLayout; + QList<QLineEdit*> m_validatorLineEdits; }; // A custom wizard page presenting the fields to be used and a path chooser