Commit 7e31b685 authored by Tobias Hunger's avatar Tobias Hunger

JsonFilePage: Take InitialPath and InitialFileName for initialization

... during initializePage. This allows the JsonWizard to change the default
file name based on secetions on earlier pages.

Change-Id: I8569c23958339782ea21d56b54208812f6fa608e
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 37f9cabf
......@@ -47,12 +47,12 @@ class QTCREATOR_UTILS_EXPORT FileWizardPage : public WizardPage
public:
explicit FileWizardPage(QWidget *parent = 0);
virtual ~FileWizardPage();
~FileWizardPage();
QString fileName() const;
QString path() const;
virtual bool isComplete() const;
bool isComplete() const;
void setFileNameLabel(const QString &label);
void setPathLabel(const QString &label);
......
......@@ -30,6 +30,8 @@
#include "jsonfilepage.h"
#include "jsonwizard.h"
#include <QFileInfo>
#include <QVariant>
......@@ -39,6 +41,18 @@ JsonFilePage::JsonFilePage(QWidget *parent) :
Utils::FileWizardPage(parent)
{ }
void JsonFilePage::initializePage()
{
JsonWizard *wiz = qobject_cast<JsonWizard *>(wizard());
if (!wiz)
return;
if (fileName().isEmpty())
setFileName(wiz->value(QLatin1String("InitialFileName")).toString());
if (path().isEmpty())
setPath(wiz->value(QLatin1String("InitialPath")).toString());
}
bool JsonFilePage::validatePage()
{
if (path().isEmpty() || fileName().isEmpty())
......
......@@ -43,6 +43,7 @@ class JsonFilePage : public Utils::FileWizardPage
public:
JsonFilePage(QWidget *parent = 0);
void initializePage();
bool validatePage();
};
......
......@@ -102,11 +102,11 @@ FilePageFactory::FilePageFactory()
Utils::WizardPage *FilePageFactory::create(JsonWizard *wizard, Core::Id typeId, const QVariant &data)
{
Q_UNUSED(wizard);
Q_UNUSED(data);
QTC_ASSERT(canCreate(typeId), return 0);
JsonFilePage *page = new JsonFilePage;
page->setPath(wizard->value(QStringLiteral("InitialPath")).toString());
return page;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment