forked from qt-creator/qt-creator
load the generated project.
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
#include "genericprojectwizard.h"
|
#include "genericprojectwizard.h"
|
||||||
|
#include <projectexplorer/projectexplorer.h>
|
||||||
|
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
|
|
||||||
#include <QtGui/QWizard>
|
#include <QtGui/QWizard>
|
||||||
#include <QtGui/QFormLayout>
|
#include <QtGui/QFormLayout>
|
||||||
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QtDebug>
|
#include <QtCore/QtDebug>
|
||||||
|
|
||||||
using namespace GenericProjectManager::Internal;
|
using namespace GenericProjectManager::Internal;
|
||||||
@@ -20,10 +23,11 @@ GenericProjectWizard::~GenericProjectWizard()
|
|||||||
Core::BaseFileWizardParameters GenericProjectWizard::parameters()
|
Core::BaseFileWizardParameters GenericProjectWizard::parameters()
|
||||||
{
|
{
|
||||||
static Core::BaseFileWizardParameters parameters(ProjectWizard);
|
static Core::BaseFileWizardParameters parameters(ProjectWizard);
|
||||||
|
parameters.setIcon(QIcon(":/wizards/images/console.png"));
|
||||||
parameters.setName(tr("Existing Project"));
|
parameters.setName(tr("Existing Project"));
|
||||||
parameters.setDescription(tr("Import Existing Project"));
|
parameters.setDescription(tr("Import Existing Project"));
|
||||||
parameters.setCategory(QLatin1String("Import"));
|
parameters.setCategory(QLatin1String("Projects"));
|
||||||
parameters.setTrCategory(tr("Import"));
|
parameters.setTrCategory(tr("Projects"));
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +40,7 @@ QWizard *GenericProjectWizard::createWizardDialog(QWidget *parent,
|
|||||||
setupWizard(wizard);
|
setupWizard(wizard);
|
||||||
|
|
||||||
QWizardPage *firstPage = new QWizardPage;
|
QWizardPage *firstPage = new QWizardPage;
|
||||||
firstPage->setTitle(tr(""));
|
firstPage->setTitle(tr("Project"));
|
||||||
|
|
||||||
QFormLayout *layout = new QFormLayout(firstPage);
|
QFormLayout *layout = new QFormLayout(firstPage);
|
||||||
|
|
||||||
@@ -56,7 +60,35 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w,
|
|||||||
QString *errorMessage) const
|
QString *errorMessage) const
|
||||||
{
|
{
|
||||||
PathChooser *pathChooser = w->findChild<PathChooser *>("pathChooser");
|
PathChooser *pathChooser = w->findChild<PathChooser *>("pathChooser");
|
||||||
|
const QString projectName = QFileInfo(pathChooser->path()).baseName() + QLatin1String(".creator");
|
||||||
|
const QDir dir(pathChooser->path());
|
||||||
|
|
||||||
return Core::GeneratedFiles();
|
// ### 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);
|
||||||
|
|
||||||
|
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,
|
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
||||||
QString *errorMessage) const;
|
QString *errorMessage) const;
|
||||||
|
|
||||||
|
virtual bool postGenerateFiles(const Core::GeneratedFiles &l, QString *errorMessage);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace Internal
|
} // end of namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user