Skip to content
Snippets Groups Projects
Commit 4300ebcd authored by Roberto Raggi's avatar Roberto Raggi
Browse files

load the generated project.

parent 79169238
No related branches found
No related tags found
No related merge requests found
#include "genericprojectwizard.h"
#include <projectexplorer/projectexplorer.h>
#include <utils/pathchooser.h>
#include <QtGui/QWizard>
#include <QtGui/QFormLayout>
#include <QtCore/QDir>
#include <QtCore/QtDebug>
using namespace GenericProjectManager::Internal;
......@@ -20,10 +23,11 @@ GenericProjectWizard::~GenericProjectWizard()
Core::BaseFileWizardParameters GenericProjectWizard::parameters()
{
static Core::BaseFileWizardParameters parameters(ProjectWizard);
parameters.setIcon(QIcon(":/wizards/images/console.png"));
parameters.setName(tr("Existing Project"));
parameters.setDescription(tr("Import Existing Project"));
parameters.setCategory(QLatin1String("Import"));
parameters.setTrCategory(tr("Import"));
parameters.setCategory(QLatin1String("Projects"));
parameters.setTrCategory(tr("Projects"));
return parameters;
}
......@@ -36,7 +40,7 @@ QWizard *GenericProjectWizard::createWizardDialog(QWidget *parent,
setupWizard(wizard);
QWizardPage *firstPage = new QWizardPage;
firstPage->setTitle(tr(""));
firstPage->setTitle(tr("Project"));
QFormLayout *layout = new QFormLayout(firstPage);
......@@ -56,7 +60,35 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w,
QString *errorMessage) const
{
PathChooser *pathChooser = w->findChild<PathChooser *>("pathChooser");
const QString projectName = QFileInfo(pathChooser->path()).baseName() + QLatin1String(".creator");
const QDir dir(pathChooser->path());
// ### FIXME: use the mimetype database.
// ### FIXME: import nested folders.
const QStringList sources = dir.entryList(QStringList() << "Makefile" << "*.c" << "*.cpp" << "*.h", QDir::Files);
QString projectContents;
QTextStream stream(&projectContents);
stream << "files=" << sources.join(",");
stream << endl;
Core::GeneratedFile file(QFileInfo(dir, projectName).absoluteFilePath()); // ### fixme
file.setContents(projectContents);
return Core::GeneratedFiles();
Core::GeneratedFiles files;
files.append(file);
return files;
}
bool GenericProjectWizard::postGenerateFiles(const Core::GeneratedFiles &l, QString *errorMessage)
{
// Post-Generate: Open the project
const QString proFileName = l.back().path();
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName)) {
*errorMessage = tr("The project %1 could not be opened.").arg(proFileName);
return false;
}
return true;
}
......@@ -23,6 +23,8 @@ protected:
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
QString *errorMessage) const;
virtual bool postGenerateFiles(const Core::GeneratedFiles &l, QString *errorMessage);
};
} // end of namespace Internal
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment