Commit 89602419 authored by Tobias Hunger's avatar Tobias Hunger

JsonWizard: Make sure to open files as the last thing

Make sure to open files only after last touches were applied by
the wizard.

Change-Id: I0da8b49ebe58b0516fa44ef7b0472cce20a5936f
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent c2fb25fd
......@@ -181,6 +181,13 @@ void JsonWizard::accept()
return;
}
emit filesReady(m_files);
if (!JsonWizardGenerator::allDone(this, &list, &errorMessage)) {
if (!errorMessage.isEmpty())
QMessageBox::warning(this, tr("Failed to Open Files"), errorMessage);
return;
}
emit allDone(m_files);
}
} // namespace ProjectExplorer
......@@ -91,6 +91,7 @@ signals:
void preWriteFiles(const JsonWizard::GeneratorFiles &files); // emitted before files are written to disk.
void postProcessFiles(const JsonWizard::GeneratorFiles &files); // emitted before files are post-processed.
void filesReady(const JsonWizard::GeneratorFiles &files); // emitted just after files are in final state on disk.
void allDone(const JsonWizard::GeneratorFiles &files); // emitted just after the wizard is done with the files. They are ready to be opened.
public slots:
void accept();
......
......@@ -192,6 +192,14 @@ bool JsonWizardFileGenerator::writeFile(const JsonWizard *wizard, Core::Generate
}
bool JsonWizardFileGenerator::postWrite(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage)
{
Q_UNUSED(wizard);
Q_UNUSED(file);
Q_UNUSED(errorMessage);
return true;
}
bool JsonWizardFileGenerator::allDone(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage)
{
Q_UNUSED(wizard);
if (file->attributes() & Core::GeneratedFile::OpenProjectAttribute) {
......
......@@ -50,6 +50,7 @@ public:
bool writeFile(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage);
bool postWrite(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage);
bool allDone(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage);
private:
class File {
......
......@@ -227,6 +227,15 @@ bool JsonWizardGenerator::postWrite(const JsonWizard *wizard, JsonWizard::Genera
return true;
}
bool JsonWizardGenerator::allDone(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage)
{
for (auto i = files->begin(); i != files->end(); ++i) {
if (!i->generator->allDone(wizard, &(i->file), errorMessage))
return false;
}
return true;
}
// --------------------------------------------------------------------
// JsonWizardGeneratorFactory:
// --------------------------------------------------------------------
......
......@@ -55,6 +55,7 @@ public:
virtual bool formatFile(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage);
virtual bool writeFile(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) = 0;
virtual bool postWrite(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) = 0;
virtual bool allDone(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) = 0;
virtual bool canKeepExistingFiles() const { return true; }
......@@ -64,6 +65,7 @@ public:
static bool formatFiles(const JsonWizard *wizard, QList<JsonWizard::GeneratorFile> *files, QString *errorMessage);
static bool writeFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage);
static bool postWrite(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage);
static bool allDone(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage);
};
class JsonWizardGeneratorFactory : public QObject
......
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