Commit 8b2eeb9c authored by Jarek Kobus's avatar Jarek Kobus
Browse files

Get rid of virtual generatedProjectFilePath()

parent f80c1512
......@@ -530,7 +530,7 @@ QStringList BaseFileWizard::runWizard(const QString &path, QWidget *parent)
}
if (firstExtensionPageHit)
foreach (IFileWizardExtension *ex, extensions)
ex->firstExtensionPageShown(files, generatedProjectFilePath(wizard.data()));
ex->firstExtensionPageShown(files);
if (accepted)
break;
}
......@@ -561,7 +561,7 @@ QStringList BaseFileWizard::runWizard(const QString &path, QWidget *parent)
// Run the extensions
foreach (IFileWizardExtension *ex, extensions) {
bool remove;
if (!ex->process(files, generatedProjectFilePath(wizard.data()), &remove, &errorMessage)) {
if (!ex->process(files, &remove, &errorMessage)) {
QMessageBox::critical(parent, tr("File Generation Failure"), errorMessage);
return QStringList();
}
......@@ -617,12 +617,6 @@ void BaseFileWizard::applyExtensionPageShortTitle(Utils::Wizard *wizard, int pag
item->setTitle(shortTitle);
}
QString BaseFileWizard::generatedProjectFilePath(const QWizard *wizard) const
{
Q_UNUSED(wizard)
return QString();
}
bool BaseFileWizard::postGenerateFiles(const QWizard *, const GeneratedFiles &l, QString *errorMessage)
{
return BaseFileWizard::postGenerateOpenEditors(l, errorMessage);
......
......@@ -211,9 +211,6 @@ protected:
* to create files with CustomGeneratorAttribute set. */
virtual bool writeFiles(const GeneratedFiles &files, QString *errorMessage);
// Overwrite for ProjectWizard kind and return the path to the generated project file
virtual QString generatedProjectFilePath(const QWizard *wizard) const;
/* Overwrite to perform steps to be done after files are actually created.
* The default implementation opens editors with the newly generated files. */
virtual bool postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage);
......
......@@ -58,16 +58,13 @@ public:
/* Process the files using the extension parameters */
virtual bool process(const QList<GeneratedFile> &files,
const QString &generatedProjectFilePath,
bool *removeOpenProjectAttribute,
QString *errorMessage) = 0;
public slots:
/* Notification about the first extension page being shown. */
virtual void firstExtensionPageShown(const QList<GeneratedFile> &files,
const QString &generatedProjectFilePath) {
virtual void firstExtensionPageShown(const QList<GeneratedFile> &files) {
Q_UNUSED(files)
Q_UNUSED(generatedProjectFilePath)
}
};
......
......@@ -231,17 +231,6 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w,
return files;
}
QString GenericProjectWizard::generatedProjectFilePath(const QWizard *w) const
{
const GenericProjectWizardDialog *wizard = qobject_cast<const GenericProjectWizardDialog *>(w);
const QString projectPath = wizard->path();
const QDir dir(projectPath);
const QString projectName = wizard->projectName();
const QString creatorFileName = QFileInfo(dir, projectName + QLatin1String(".creator")).absoluteFilePath();
return creatorFileName;
}
bool GenericProjectWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage)
{
Q_UNUSED(w);
......
......@@ -81,8 +81,6 @@ protected:
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
QString *errorMessage) const;
virtual QString generatedProjectFilePath(const QWizard *w) const;
virtual bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
bool isValidDir(const QFileInfo &fileInfo) const;
......
......@@ -521,13 +521,6 @@ bool CustomProjectWizard::postGenerateOpen(const Core::GeneratedFiles &l, QStrin
return BaseFileWizard::postGenerateOpenEditors(l, errorMessage);
}
QString CustomProjectWizard::generatedProjectFilePath(const QWizard *) const
{
if (CustomWizardPrivate::verbose)
qDebug("CustomProjectWizard::generatedProjectFilePath: '%s'", qPrintable(context()->projectFilePath));
return context()->projectFilePath;
}
bool CustomProjectWizard::postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage)
{
if (CustomWizardPrivate::verbose)
......
......@@ -164,7 +164,6 @@ signals:
void projectLocationChanged(const QString &path);
protected:
QString generatedProjectFilePath(const QWizard *wizard) const;
virtual bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
void initProjectWizardDialog(BaseProjectWizardDialog *w, const QString &defaultPath,
......
......@@ -224,11 +224,18 @@ static int findMatchingProject(const QList<ProjectEntry> &projects,
return bestMatch;
}
static QString generatedProjectFilePath(const QList<Core::GeneratedFile> &files)
{
foreach (const Core::GeneratedFile file, files)
if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute)
return file.path();
return QString();
}
void ProjectFileWizardExtension::firstExtensionPageShown(
const QList<Core::GeneratedFile> &files,
const QString &generatedProjectFilePath)
const QList<Core::GeneratedFile> &files)
{
initProjectChoices(generatedProjectFilePath);
initProjectChoices(generatedProjectFilePath(files));
if (debugExtension)
qDebug() << Q_FUNC_INFO << files.size();
......@@ -357,33 +364,32 @@ void ProjectFileWizardExtension::initProjectChoices(const QString &generatedProj
bool ProjectFileWizardExtension::process(
const QList<Core::GeneratedFile> &files,
const QString &generatedProjectFilePath,
bool *removeOpenProjectAttribute, QString *errorMessage)
{
return processProject(files, generatedProjectFilePath,
removeOpenProjectAttribute, errorMessage) &&
return processProject(files, removeOpenProjectAttribute, errorMessage) &&
processVersionControl(files, errorMessage);
}
// Add files to project && version control
bool ProjectFileWizardExtension::processProject(
const QList<Core::GeneratedFile> &files,
const QString &generatedProjectFilePath,
bool *removeOpenProjectAttribute, QString *errorMessage)
{
typedef QMultiMap<FileType, QString> TypeFileMap;
*removeOpenProjectAttribute = false;
QString generatedProject = generatedProjectFilePath(files);
// Add files to project (Entry at 0 is 'None').
const int projectIndex = m_context->page->currentProjectIndex() - 1;
if (projectIndex < 0 || projectIndex >= m_context->projects.size())
return true;
ProjectNode *project = m_context->projects.at(projectIndex).node;
if (m_context->wizard->kind() == Core::IWizard::ProjectWizard) {
if (!project->addSubProjects(QStringList(generatedProjectFilePath))) {
if (!project->addSubProjects(QStringList(generatedProject))) {
*errorMessage = tr("Failed to add subproject '%1'\nto project '%2'.")
.arg(generatedProjectFilePath).arg(project->path());
.arg(generatedProject).arg(project->path());
return false;
}
*removeOpenProjectAttribute = true;
......
......@@ -51,18 +51,15 @@ public:
virtual QList<QWizardPage *> extensionPages(const Core::IWizard *wizard);
virtual bool process(const QList<Core::GeneratedFile> &files,
const QString &generatedProjectFilePath,
bool *removeOpenProjectAttribute, QString *errorMessage);
public slots:
virtual void firstExtensionPageShown(const QList<Core::GeneratedFile> &files,
const QString &generatedProjectFilePath);
virtual void firstExtensionPageShown(const QList<Core::GeneratedFile> &files);
private:
void initProjectChoices(const QString &generatedProjectFilePath);
void initializeVersionControlChoices();
bool processProject(const QList<Core::GeneratedFile> &files,
const QString &generatedProjectFilePath,
bool *removeOpenProjectAttribute, QString *errorMessage);
bool processVersionControl(const QList<Core::GeneratedFile> &files, QString *errorMessage);
......
......@@ -75,16 +75,5 @@ Core::GeneratedFiles CustomWidgetWizard::generateFiles(const QWizard *w,
return PluginGenerator::generatePlugin(p, *(cw->pluginOptions()), errorMessage);
}
QString CustomWidgetWizard::generatedProjectFilePath(const QWizard *w) const
{
const CustomWidgetWizardDialog *cw = qobject_cast<const CustomWidgetWizardDialog *>(w);
const QChar slash = QLatin1Char('/');
QString baseDir = cw->path();
baseDir += slash;
baseDir += cw->projectName();
baseDir += slash;
return baseDir + cw->projectName() + QLatin1String(".pro");
}
} // namespace Internal
} // namespace Qt4ProjectManager
......@@ -50,7 +50,6 @@ protected:
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
QString *errorMessage) const;
virtual QString generatedProjectFilePath(const QWizard *w) const;
};
} // namespace Internal
......
......@@ -104,14 +104,5 @@ Core::GeneratedFiles
return Core::GeneratedFiles() << source << profile;
}
QString ConsoleAppWizard::generatedProjectFilePath(const QWizard *w) const
{
const ConsoleAppWizardDialog *wizard = qobject_cast< const ConsoleAppWizardDialog *>(w);
const QtProjectParameters params = wizard->parameters();
const QString projectPath = params.projectPath();
return Core::BaseFileWizard::buildFileName(projectPath, params.fileName, profileSuffix());
}
} // namespace Internal
} // namespace Qt4ProjectManager
......@@ -51,8 +51,6 @@ protected:
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
QString *errorMessage) const;
QString generatedProjectFilePath(const QWizard *w) const;
};
} // namespace Internal
......
......@@ -74,13 +74,5 @@ Core::GeneratedFiles
return Core::GeneratedFiles() << profile;
}
QString EmptyProjectWizard::generatedProjectFilePath(const QWizard *w) const
{
const EmptyProjectWizardDialog *wizard = qobject_cast< const EmptyProjectWizardDialog *>(w);
const QtProjectParameters params = wizard->parameters();
const QString projectPath = params.projectPath();
return Core::BaseFileWizard::buildFileName(projectPath, params.fileName, profileSuffix());
}
} // namespace Internal
} // namespace Qt4ProjectManager
......@@ -49,8 +49,6 @@ protected:
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
QString *errorMessage) const;
QString generatedProjectFilePath(const QWizard *w) const;
};
} // namespace Internal
......
......@@ -237,15 +237,6 @@ Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w,
return rc;
}
QString GuiAppWizard::generatedProjectFilePath(const QWizard *w) const
{
const GuiAppWizardDialog *dialog = qobject_cast<const GuiAppWizardDialog *>(w);
const QtProjectParameters projectParams = dialog->projectParameters();
const QString projectPath = projectParams.projectPath();
return buildFileName(projectPath, projectParams.fileName, profileSuffix());
}
bool GuiAppWizard::parametrizeTemplate(const QString &templatePath, const QString &templateName,
const GuiAppParameters &params,
QString *target, QString *errorMessage)
......
......@@ -61,8 +61,6 @@ protected:
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
QString *errorMessage) const;
QString generatedProjectFilePath(const QWizard *w) const;
private:
static bool parametrizeTemplate(const QString &templatePath, const QString &templateName,
const GuiAppParameters &params,
......
......@@ -137,15 +137,5 @@ Core::GeneratedFiles LibraryWizard::generateFiles(const QWizard *w,
return rc;
}
QString LibraryWizard::generatedProjectFilePath(const QWizard *w) const
{
const LibraryWizardDialog *dialog = qobject_cast<const LibraryWizardDialog *>(w);
const QtProjectParameters projectParams = dialog->parameters();
const QString projectPath = projectParams.projectPath();
return buildFileName(projectPath, projectParams.fileName, profileSuffix());
}
} // namespace Internal
} // namespace Qt4ProjectManager
......@@ -53,9 +53,6 @@ protected:
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
QString *errorMessage) const;
QString generatedProjectFilePath(const QWizard *w) const;
};
} // namespace Internal
......
......@@ -184,14 +184,5 @@ Core::GeneratedFiles TestWizard::generateFiles(const QWizard *w, QString *errorM
return Core::GeneratedFiles() << source << profile;
}
QString TestWizard::generatedProjectFilePath(const QWizard *w) const
{
const TestWizardDialog *wizardDialog = qobject_cast<const TestWizardDialog *>(w);
const QtProjectParameters projectParams = wizardDialog->projectParameters();
const QString projectPath = projectParams.projectPath();
return buildFileName(projectPath, projectParams.fileName, profileSuffix());
}
} // namespace Internal
} // namespace Qt4ProjectManager
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