Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
0f3d8b65
Commit
0f3d8b65
authored
Mar 17, 2010
by
Friedemann Kleint
Browse files
CustomWizard: Implement validatePage() for CustomWizardPage
checking the validation line edits as a last resort.
parent
292db7a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/projectexplorer/customwizard/customwizardpage.cpp
View file @
0f3d8b65
...
...
@@ -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
,
...
...
src/plugins/projectexplorer/customwizard/customwizardpage.h
View file @
0f3d8b65
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment