Custom wizard: Add setting for PathChooser's expectedKind.

Change-Id: Iff8955d0db20c5c00f8a1745ab1f4310482254cb
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Martin T. H. Sandsmark
2013-02-19 15:59:04 +01:00
committed by Friedemann Kleint
parent e255f15ac3
commit 23bb4ff631
2 changed files with 33 additions and 1 deletions

View File

@@ -431,13 +431,31 @@
\code
<field mandatory="true" name="QtCreatorSources">
<fieldcontrol class="Utils::PathChooser" defaulttext="" />
<fieldcontrol class="Utils::PathChooser" defaulttext="" expectedkind="existingdirectory"/>
<fielddescription>Qt Creator sources:</fielddescription>
</field>
\endcode
The \c defaulttext attribute specifies text that appears in the field by default.
The text attribute \c expectedkind specifies which type of path is expected:
\list
\li \c any accepts any kind of path.
\li \c file expects a file.
\li \c directory expects a directory.
\li \c existingdirectory expects an existing directory.
\li \c command expects an executable file.
\li \c existingcommand expects an existing, executable file.
\endlist
\section2 Check Boxes
To make check boxes appear selected by default, set the \c fieldcontrol attribute

View File

@@ -315,6 +315,20 @@ QWidget *CustomWizardFieldPage::registerPathChooser(const QString &fieldName,
const CustomWizardField &field)
{
Utils::PathChooser *pathChooser = new Utils::PathChooser;
const QString expectedKind = field.controlAttributes.value(QLatin1String("expectedkind")).toLower();
if (expectedKind == QLatin1String("existingdirectory"))
pathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
else if (expectedKind == QLatin1String("directory"))
pathChooser->setExpectedKind(Utils::PathChooser::Directory);
else if (expectedKind == QLatin1String("file"))
pathChooser->setExpectedKind(Utils::PathChooser::File);
else if (expectedKind == QLatin1String("existingcommand"))
pathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
else if (expectedKind == QLatin1String("command"))
pathChooser->setExpectedKind(Utils::PathChooser::Command);
else if (expectedKind == QLatin1String("any"))
pathChooser->setExpectedKind(Utils::PathChooser::Any);
registerField(fieldName, pathChooser, "path", SIGNAL(changed(QString)));
const QString defaultText = field.controlAttributes.value(QLatin1String("defaulttext"));
m_pathChoosers.push_back(PathChooserData(pathChooser, defaultText));