forked from qt-creator/qt-creator
Implement adding new project into opened subdirs project
Reviewed-by: dt <qtc-committer@nokia.com>
This commit is contained in:
@@ -49,6 +49,12 @@ QList<ProjectExplorer::ProjectNode::ProjectAction> CMakeProjectNode::supportedAc
|
|||||||
return QList<ProjectAction>();
|
return QList<ProjectAction>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CMakeProjectNode::canAddSubProject(const QString &proFilePath) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(proFilePath)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool CMakeProjectNode::addSubProjects(const QStringList &proFilePaths)
|
bool CMakeProjectNode::addSubProjects(const QStringList &proFilePaths)
|
||||||
{
|
{
|
||||||
Q_UNUSED(proFilePaths)
|
Q_UNUSED(proFilePaths)
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ public:
|
|||||||
CMakeProjectNode(const QString &fileName);
|
CMakeProjectNode(const QString &fileName);
|
||||||
virtual bool hasBuildTargets() const;
|
virtual bool hasBuildTargets() const;
|
||||||
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions(Node *node) const;
|
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions(Node *node) const;
|
||||||
|
|
||||||
|
virtual bool canAddSubProject(const QString &proFilePath) const;
|
||||||
|
|
||||||
virtual bool addSubProjects(const QStringList &proFilePaths);
|
virtual bool addSubProjects(const QStringList &proFilePaths);
|
||||||
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
||||||
virtual bool addFiles(const ProjectExplorer::FileType fileType,
|
virtual bool addFiles(const ProjectExplorer::FileType fileType,
|
||||||
|
|||||||
@@ -530,7 +530,7 @@ QStringList BaseFileWizard::runWizard(const QString &path, QWidget *parent)
|
|||||||
}
|
}
|
||||||
if (firstExtensionPageHit)
|
if (firstExtensionPageHit)
|
||||||
foreach (IFileWizardExtension *ex, extensions)
|
foreach (IFileWizardExtension *ex, extensions)
|
||||||
ex->firstExtensionPageShown(files);
|
ex->firstExtensionPageShown(files, generatedProjectFilePath(wizard.data()));
|
||||||
if (accepted)
|
if (accepted)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -558,12 +558,23 @@ QStringList BaseFileWizard::runWizard(const QString &path, QWidget *parent)
|
|||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool removeOpenProjectAttribute = false;
|
||||||
// Run the extensions
|
// Run the extensions
|
||||||
foreach (IFileWizardExtension *ex, extensions)
|
foreach (IFileWizardExtension *ex, extensions) {
|
||||||
if (!ex->process(files, &errorMessage)) {
|
bool remove;
|
||||||
|
if (!ex->process(files, generatedProjectFilePath(wizard.data()), &remove, &errorMessage)) {
|
||||||
QMessageBox::critical(parent, tr("File Generation Failure"), errorMessage);
|
QMessageBox::critical(parent, tr("File Generation Failure"), errorMessage);
|
||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
|
removeOpenProjectAttribute |= remove;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removeOpenProjectAttribute) {
|
||||||
|
for (int i = 0; i < files.count(); i++) {
|
||||||
|
if (files[i].attributes() & Core::GeneratedFile::OpenProjectAttribute)
|
||||||
|
files[i].setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Post generation handler
|
// Post generation handler
|
||||||
if (!postGenerateFiles(wizard.data(), files, &errorMessage)) {
|
if (!postGenerateFiles(wizard.data(), files, &errorMessage)) {
|
||||||
@@ -596,6 +607,12 @@ void BaseFileWizard::applyExtensionPageShortTitle(Utils::Wizard *wizard, int pag
|
|||||||
item->setTitle(shortTitle);
|
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)
|
bool BaseFileWizard::postGenerateFiles(const QWizard *, const GeneratedFiles &l, QString *errorMessage)
|
||||||
{
|
{
|
||||||
return BaseFileWizard::postGenerateOpenEditors(l, errorMessage);
|
return BaseFileWizard::postGenerateOpenEditors(l, errorMessage);
|
||||||
|
|||||||
@@ -200,6 +200,9 @@ protected:
|
|||||||
virtual GeneratedFiles generateFiles(const QWizard *w,
|
virtual GeneratedFiles generateFiles(const QWizard *w,
|
||||||
QString *errorMessage) const = 0;
|
QString *errorMessage) const = 0;
|
||||||
|
|
||||||
|
// 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.
|
/* Overwrite to perform steps to be done after files are actually created.
|
||||||
* The default implementation opens editors with the newly generated files. */
|
* The default implementation opens editors with the newly generated files. */
|
||||||
virtual bool postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage);
|
virtual bool postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage);
|
||||||
|
|||||||
@@ -57,11 +57,18 @@ public:
|
|||||||
virtual QList<QWizardPage *> extensionPages(const IWizard *wizard) = 0;
|
virtual QList<QWizardPage *> extensionPages(const IWizard *wizard) = 0;
|
||||||
|
|
||||||
/* Process the files using the extension parameters */
|
/* Process the files using the extension parameters */
|
||||||
virtual bool process(const QList<GeneratedFile> &files, QString *errorMessage) = 0;
|
virtual bool process(const QList<GeneratedFile> &files,
|
||||||
|
const QString &generatedProjectFilePath,
|
||||||
|
bool *removeOpenProjectAttribute,
|
||||||
|
QString *errorMessage) = 0;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/* Notification about the first extension page being shown. */
|
/* Notification about the first extension page being shown. */
|
||||||
virtual void firstExtensionPageShown(const QList<GeneratedFile> &) {}
|
virtual void firstExtensionPageShown(const QList<GeneratedFile> &files,
|
||||||
|
const QString &generatedProjectFilePath) {
|
||||||
|
Q_UNUSED(files)
|
||||||
|
Q_UNUSED(generatedProjectFilePath)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
@@ -179,6 +179,12 @@ QList<ProjectExplorer::ProjectNode::ProjectAction> GenericProjectNode::supported
|
|||||||
<< RemoveFile;
|
<< RemoveFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GenericProjectNode::canAddSubProject(const QString &proFilePath) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(proFilePath)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool GenericProjectNode::addSubProjects(const QStringList &proFilePaths)
|
bool GenericProjectNode::addSubProjects(const QStringList &proFilePaths)
|
||||||
{
|
{
|
||||||
Q_UNUSED(proFilePaths)
|
Q_UNUSED(proFilePaths)
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ public:
|
|||||||
|
|
||||||
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions(Node *node) const;
|
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions(Node *node) const;
|
||||||
|
|
||||||
|
virtual bool canAddSubProject(const QString &proFilePath) const;
|
||||||
|
|
||||||
virtual bool addSubProjects(const QStringList &proFilePaths);
|
virtual bool addSubProjects(const QStringList &proFilePaths);
|
||||||
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
||||||
|
|
||||||
|
|||||||
@@ -231,6 +231,17 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w,
|
|||||||
return files;
|
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)
|
bool GenericProjectWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage)
|
||||||
{
|
{
|
||||||
Q_UNUSED(w);
|
Q_UNUSED(w);
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ protected:
|
|||||||
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
||||||
QString *errorMessage) const;
|
QString *errorMessage) const;
|
||||||
|
|
||||||
|
virtual QString generatedProjectFilePath(const QWizard *w) const;
|
||||||
|
|
||||||
virtual bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
|
virtual bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
|
||||||
|
|
||||||
bool isValidDir(const QFileInfo &fileInfo) const;
|
bool isValidDir(const QFileInfo &fileInfo) const;
|
||||||
|
|||||||
@@ -451,6 +451,25 @@ bool CustomProjectWizard::postGenerateOpen(const Core::GeneratedFiles &l, QStrin
|
|||||||
return BaseFileWizard::postGenerateOpenEditors(l, errorMessage);
|
return BaseFileWizard::postGenerateOpenEditors(l, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CustomProjectWizard::generatedProjectFilePath(const QWizard *wizard) const
|
||||||
|
{
|
||||||
|
const BaseProjectWizardDialog *dialog = qobject_cast<const BaseProjectWizardDialog *>(wizard);
|
||||||
|
QTC_ASSERT(dialog, return QString())
|
||||||
|
const QString targetPath = dialog->path() + QLatin1Char('/') + dialog->projectName();
|
||||||
|
const QChar slash = QLatin1Char('/');
|
||||||
|
// take the first from parameters()->files list which have cwFile.openProject set
|
||||||
|
foreach(const Internal::CustomWizardFile &file, parameters()->files) {
|
||||||
|
if (file.openProject) {
|
||||||
|
FieldReplacementMap fieldReplacementMap = replacementMap(dialog);
|
||||||
|
fieldReplacementMap.insert(QLatin1String("ProjectName"), dialog->projectName());
|
||||||
|
QString target = file.target;
|
||||||
|
Internal::CustomWizardContext::replaceFields(fieldReplacementMap, &target);
|
||||||
|
return QDir::toNativeSeparators(targetPath + slash + target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
bool CustomProjectWizard::postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage)
|
bool CustomProjectWizard::postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage)
|
||||||
{
|
{
|
||||||
if (CustomWizardPrivate::verbose)
|
if (CustomWizardPrivate::verbose)
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ signals:
|
|||||||
void projectLocationChanged(const QString &path);
|
void projectLocationChanged(const QString &path);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
QString generatedProjectFilePath(const QWizard *wizard) const;
|
||||||
virtual bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
|
virtual bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
|
||||||
|
|
||||||
void initProjectWizardDialog(BaseProjectWizardDialog *w, const QString &defaultPath,
|
void initProjectWizardDialog(BaseProjectWizardDialog *w, const QString &defaultPath,
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
#include <coreplugin/basefilewizard.h>
|
#include <coreplugin/basefilewizard.h>
|
||||||
#include <coreplugin/dialogs/iwizard.h>
|
|
||||||
#include <coreplugin/filemanager.h>
|
#include <coreplugin/filemanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/iversioncontrol.h>
|
#include <coreplugin/iversioncontrol.h>
|
||||||
@@ -156,11 +155,13 @@ struct ProjectWizardContext
|
|||||||
ProjectWizardPage *page;
|
ProjectWizardPage *page;
|
||||||
bool repositoryExists; // Is VCS 'add' sufficient, or should a repository be created?
|
bool repositoryExists; // Is VCS 'add' sufficient, or should a repository be created?
|
||||||
QString commonDirectory;
|
QString commonDirectory;
|
||||||
|
const Core::IWizard *wizard;
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectWizardContext::ProjectWizardContext() :
|
ProjectWizardContext::ProjectWizardContext() :
|
||||||
page(0),
|
page(0),
|
||||||
repositoryExists(false)
|
repositoryExists(false),
|
||||||
|
wizard(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +172,7 @@ void ProjectWizardContext::clear()
|
|||||||
commonDirectory.clear();
|
commonDirectory.clear();
|
||||||
page = 0;
|
page = 0;
|
||||||
repositoryExists = false;
|
repositoryExists = false;
|
||||||
|
wizard = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- ProjectFileWizardExtension
|
// ---- ProjectFileWizardExtension
|
||||||
@@ -222,8 +224,12 @@ static int findMatchingProject(const QList<ProjectEntry> &projects,
|
|||||||
return bestMatch;
|
return bestMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectFileWizardExtension::firstExtensionPageShown(const QList<Core::GeneratedFile> &files)
|
void ProjectFileWizardExtension::firstExtensionPageShown(
|
||||||
|
const QList<Core::GeneratedFile> &files,
|
||||||
|
const QString &generatedProjectFilePath)
|
||||||
{
|
{
|
||||||
|
initProjectChoices(generatedProjectFilePath);
|
||||||
|
|
||||||
if (debugExtension)
|
if (debugExtension)
|
||||||
qDebug() << Q_FUNC_INFO << files.size();
|
qDebug() << Q_FUNC_INFO << files.size();
|
||||||
// Parametrize wizard page: find best project to add to, set up files display and
|
// Parametrize wizard page: find best project to add to, set up files display and
|
||||||
@@ -307,13 +313,11 @@ QList<QWizardPage *> ProjectFileWizardExtension::extensionPages(const Core::IWiz
|
|||||||
}
|
}
|
||||||
// Init context with page and projects
|
// Init context with page and projects
|
||||||
m_context->page = new ProjectWizardPage;
|
m_context->page = new ProjectWizardPage;
|
||||||
// Project list remains the same over duration of wizard execution
|
m_context->wizard = wizard;
|
||||||
// Note that projects cannot be added to projects.
|
|
||||||
initProjectChoices(wizard->kind() != Core::IWizard::ProjectWizard);
|
|
||||||
return QList<QWizardPage *>() << m_context->page;
|
return QList<QWizardPage *>() << m_context->page;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectFileWizardExtension::initProjectChoices(bool enabled)
|
void ProjectFileWizardExtension::initProjectChoices(const QString &generatedProjectFilePath)
|
||||||
{
|
{
|
||||||
// Set up project list which remains the same over duration of wizard execution
|
// Set up project list which remains the same over duration of wizard execution
|
||||||
// As tooltip, set the directory for disambiguation (should someone have
|
// As tooltip, set the directory for disambiguation (should someone have
|
||||||
@@ -321,14 +325,24 @@ void ProjectFileWizardExtension::initProjectChoices(bool enabled)
|
|||||||
//: No project selected
|
//: No project selected
|
||||||
QStringList projectChoices(tr("<None>"));
|
QStringList projectChoices(tr("<None>"));
|
||||||
QStringList projectToolTips((QString()));
|
QStringList projectToolTips((QString()));
|
||||||
if (enabled) {
|
|
||||||
typedef QMap<ProjectEntry, bool> ProjectEntryMap;
|
typedef QMap<ProjectEntry, bool> ProjectEntryMap;
|
||||||
// Sort by base name and purge duplicated entries (resulting from dependencies)
|
// Sort by base name and purge duplicated entries (resulting from dependencies)
|
||||||
// via Map.
|
// via Map.
|
||||||
ProjectEntryMap entryMap;
|
ProjectEntryMap entryMap;
|
||||||
|
|
||||||
foreach(ProjectNode *n, AllProjectNodesVisitor::allProjects(ProjectNode::AddNewFile))
|
ProjectNode::ProjectAction projectAction =
|
||||||
|
m_context->wizard->kind() == Core::IWizard::ProjectWizard
|
||||||
|
? ProjectNode::AddSubProject : ProjectNode::AddNewFile;
|
||||||
|
foreach(ProjectNode *n, AllProjectNodesVisitor::allProjects(projectAction)) {
|
||||||
|
if (projectAction == ProjectNode::AddNewFile
|
||||||
|
|| (projectAction == ProjectNode::AddSubProject
|
||||||
|
&& n->canAddSubProject(generatedProjectFilePath)))
|
||||||
entryMap.insert(ProjectEntry(n), true);
|
entryMap.insert(ProjectEntry(n), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_context->projects.clear();
|
||||||
|
|
||||||
// Collect names
|
// Collect names
|
||||||
const ProjectEntryMap::const_iterator cend = entryMap.constEnd();
|
const ProjectEntryMap::const_iterator cend = entryMap.constEnd();
|
||||||
for (ProjectEntryMap::const_iterator it = entryMap.constBegin(); it != cend; ++it) {
|
for (ProjectEntryMap::const_iterator it = entryMap.constBegin(); it != cend; ++it) {
|
||||||
@@ -336,27 +350,44 @@ void ProjectFileWizardExtension::initProjectChoices(bool enabled)
|
|||||||
projectChoices.push_back(it.key().fileName);
|
projectChoices.push_back(it.key().fileName);
|
||||||
projectToolTips.push_back(it.key().nativeDirectory);
|
projectToolTips.push_back(it.key().nativeDirectory);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
m_context->page->setProjects(projectChoices);
|
m_context->page->setProjects(projectChoices);
|
||||||
m_context->page->setProjectToolTips(projectToolTips);
|
m_context->page->setProjectToolTips(projectToolTips);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProjectFileWizardExtension::process(const QList<Core::GeneratedFile> &files, QString *errorMessage)
|
bool ProjectFileWizardExtension::process(
|
||||||
|
const QList<Core::GeneratedFile> &files,
|
||||||
|
const QString &generatedProjectFilePath,
|
||||||
|
bool *removeOpenProjectAttribute, QString *errorMessage)
|
||||||
{
|
{
|
||||||
return processProject(files, errorMessage) &&
|
return processProject(files, generatedProjectFilePath,
|
||||||
|
removeOpenProjectAttribute, errorMessage) &&
|
||||||
processVersionControl(files, errorMessage);
|
processVersionControl(files, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add files to project && version control
|
// Add files to project && version control
|
||||||
bool ProjectFileWizardExtension::processProject(const QList<Core::GeneratedFile> &files, QString *errorMessage)
|
bool ProjectFileWizardExtension::processProject(
|
||||||
|
const QList<Core::GeneratedFile> &files,
|
||||||
|
const QString &generatedProjectFilePath,
|
||||||
|
bool *removeOpenProjectAttribute, QString *errorMessage)
|
||||||
{
|
{
|
||||||
typedef QMultiMap<FileType, QString> TypeFileMap;
|
typedef QMultiMap<FileType, QString> TypeFileMap;
|
||||||
|
|
||||||
|
*removeOpenProjectAttribute = false;
|
||||||
|
|
||||||
// Add files to project (Entry at 0 is 'None').
|
// Add files to project (Entry at 0 is 'None').
|
||||||
const int projectIndex = m_context->page->currentProjectIndex() - 1;
|
const int projectIndex = m_context->page->currentProjectIndex() - 1;
|
||||||
if (projectIndex < 0 || projectIndex >= m_context->projects.size())
|
if (projectIndex < 0 || projectIndex >= m_context->projects.size())
|
||||||
return true;
|
return true;
|
||||||
ProjectNode *project = m_context->projects.at(projectIndex).node;
|
ProjectNode *project = m_context->projects.at(projectIndex).node;
|
||||||
|
if (m_context->wizard->kind() == Core::IWizard::ProjectWizard) {
|
||||||
|
if (!project->addSubProjects(QStringList(generatedProjectFilePath))) {
|
||||||
|
*errorMessage = tr("Failed to add subproject '%1'\nto project '%2'.")
|
||||||
|
.arg(generatedProjectFilePath).arg(project->path());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*removeOpenProjectAttribute = true;
|
||||||
|
} else {
|
||||||
// Split into lists by file type and bulk-add them.
|
// Split into lists by file type and bulk-add them.
|
||||||
TypeFileMap typeFileMap;
|
TypeFileMap typeFileMap;
|
||||||
const Core::MimeDatabase *mdb = Core::ICore::instance()->mimeDatabase();
|
const Core::MimeDatabase *mdb = Core::ICore::instance()->mimeDatabase();
|
||||||
@@ -372,6 +403,7 @@ bool ProjectFileWizardExtension::processProject(const QList<Core::GeneratedFile>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,15 +50,20 @@ public:
|
|||||||
virtual ~ProjectFileWizardExtension();
|
virtual ~ProjectFileWizardExtension();
|
||||||
|
|
||||||
virtual QList<QWizardPage *> extensionPages(const Core::IWizard *wizard);
|
virtual QList<QWizardPage *> extensionPages(const Core::IWizard *wizard);
|
||||||
virtual bool process(const QList<Core::GeneratedFile> &files, QString *errorMessage);
|
virtual bool process(const QList<Core::GeneratedFile> &files,
|
||||||
|
const QString &generatedProjectFilePath,
|
||||||
|
bool *removeOpenProjectAttribute, QString *errorMessage);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void firstExtensionPageShown(const QList<Core::GeneratedFile> &);
|
virtual void firstExtensionPageShown(const QList<Core::GeneratedFile> &files,
|
||||||
|
const QString &generatedProjectFilePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initProjectChoices(bool enabled);
|
void initProjectChoices(const QString &generatedProjectFilePath);
|
||||||
void initializeVersionControlChoices();
|
void initializeVersionControlChoices();
|
||||||
bool processProject(const QList<Core::GeneratedFile> &files, QString *errorMessage);
|
bool processProject(const QList<Core::GeneratedFile> &files,
|
||||||
|
const QString &generatedProjectFilePath,
|
||||||
|
bool *removeOpenProjectAttribute, QString *errorMessage);
|
||||||
bool processVersionControl(const QList<Core::GeneratedFile> &files, QString *errorMessage);
|
bool processVersionControl(const QList<Core::GeneratedFile> &files, QString *errorMessage);
|
||||||
|
|
||||||
ProjectWizardContext *m_context;
|
ProjectWizardContext *m_context;
|
||||||
|
|||||||
@@ -182,6 +182,8 @@ public:
|
|||||||
|
|
||||||
virtual QList<ProjectAction> supportedActions(Node *node) const = 0;
|
virtual QList<ProjectAction> supportedActions(Node *node) const = 0;
|
||||||
|
|
||||||
|
virtual bool canAddSubProject(const QString &proFilePath) const = 0;
|
||||||
|
|
||||||
virtual bool addSubProjects(const QStringList &proFilePaths) = 0;
|
virtual bool addSubProjects(const QStringList &proFilePaths) = 0;
|
||||||
|
|
||||||
virtual bool removeSubProjects(const QStringList &proFilePaths) = 0;
|
virtual bool removeSubProjects(const QStringList &proFilePaths) = 0;
|
||||||
|
|||||||
@@ -180,6 +180,12 @@ QList<ProjectExplorer::ProjectNode::ProjectAction> QmlProjectNode::supportedActi
|
|||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QmlProjectNode::canAddSubProject(const QString &proFilePath) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(proFilePath)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool QmlProjectNode::addSubProjects(const QStringList &proFilePaths)
|
bool QmlProjectNode::addSubProjects(const QStringList &proFilePaths)
|
||||||
{
|
{
|
||||||
Q_UNUSED(proFilePaths)
|
Q_UNUSED(proFilePaths)
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ public:
|
|||||||
|
|
||||||
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions(Node *node) const;
|
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions(Node *node) const;
|
||||||
|
|
||||||
|
virtual bool canAddSubProject(const QString &proFilePath) const;
|
||||||
|
|
||||||
virtual bool addSubProjects(const QStringList &proFilePaths);
|
virtual bool addSubProjects(const QStringList &proFilePaths);
|
||||||
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
||||||
|
|
||||||
|
|||||||
@@ -75,5 +75,16 @@ Core::GeneratedFiles CustomWidgetWizard::generateFiles(const QWizard *w,
|
|||||||
return PluginGenerator::generatePlugin(p, *(cw->pluginOptions()), errorMessage);
|
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 Internal
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ protected:
|
|||||||
|
|
||||||
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
||||||
QString *errorMessage) const;
|
QString *errorMessage) const;
|
||||||
|
|
||||||
|
virtual QString generatedProjectFilePath(const QWizard *w) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -771,10 +771,39 @@ QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions(Node *node) c
|
|||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Qt4PriFileNode::canAddSubProject(const QString &proFilePath) const
|
||||||
|
{
|
||||||
|
QFileInfo fi(proFilePath);
|
||||||
|
if (fi.suffix() == QLatin1String("pro")
|
||||||
|
|| fi.suffix() == QLatin1String("pri"))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Qt4PriFileNode::addSubProjects(const QStringList &proFilePaths)
|
bool Qt4PriFileNode::addSubProjects(const QStringList &proFilePaths)
|
||||||
{
|
{
|
||||||
Q_UNUSED(proFilePaths)
|
ProjectExplorer::FindAllFilesVisitor visitor;
|
||||||
return false; //changeIncludes(m_includeFile, proFilePaths, AddToProFile);
|
accept(&visitor);
|
||||||
|
const QStringList &allFiles = visitor.filePaths();
|
||||||
|
|
||||||
|
QStringList uniqueProFilePaths;
|
||||||
|
foreach (const QString &proFile, proFilePaths) {
|
||||||
|
if (!allFiles.contains(proFile)) {
|
||||||
|
// if proFilePath is like: _path_/projectName/projectName.pro
|
||||||
|
// we simplify it to: _path_/projectName
|
||||||
|
QString proFilePath = proFile;
|
||||||
|
QFileInfo fi(proFile);
|
||||||
|
QFileInfo parentFi(fi.absolutePath());
|
||||||
|
if (parentFi.fileName() == fi.baseName())
|
||||||
|
proFilePath = parentFi.absoluteFilePath();
|
||||||
|
uniqueProFilePaths.append(proFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList failedFiles;
|
||||||
|
changeFiles(ProjectExplorer::ProjectFileType, uniqueProFilePaths, &failedFiles, AddToProFile);
|
||||||
|
|
||||||
|
return failedFiles.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Qt4PriFileNode::removeSubProjects(const QStringList &proFilePaths)
|
bool Qt4PriFileNode::removeSubProjects(const QStringList &proFilePaths)
|
||||||
@@ -1085,6 +1114,9 @@ QStringList Qt4PriFileNode::varNames(ProjectExplorer::FileType type)
|
|||||||
case ProjectExplorer::FormType:
|
case ProjectExplorer::FormType:
|
||||||
vars << QLatin1String("FORMS");
|
vars << QLatin1String("FORMS");
|
||||||
break;
|
break;
|
||||||
|
case ProjectExplorer::ProjectFileType:
|
||||||
|
vars << QLatin1String("SUBDIRS");
|
||||||
|
break;
|
||||||
case ProjectExplorer::QMLType:
|
case ProjectExplorer::QMLType:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -140,6 +140,8 @@ public:
|
|||||||
|
|
||||||
bool hasBuildTargets() const { return false; }
|
bool hasBuildTargets() const { return false; }
|
||||||
|
|
||||||
|
bool canAddSubProject(const QString &proFilePath) const;
|
||||||
|
|
||||||
bool addSubProjects(const QStringList &proFilePaths);
|
bool addSubProjects(const QStringList &proFilePaths);
|
||||||
bool removeSubProjects(const QStringList &proFilePaths);
|
bool removeSubProjects(const QStringList &proFilePaths);
|
||||||
|
|
||||||
|
|||||||
@@ -104,5 +104,14 @@ Core::GeneratedFiles
|
|||||||
return Core::GeneratedFiles() << source << profile;
|
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 Internal
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ protected:
|
|||||||
|
|
||||||
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
||||||
QString *errorMessage) const;
|
QString *errorMessage) const;
|
||||||
|
|
||||||
|
QString generatedProjectFilePath(const QWizard *w) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -74,5 +74,13 @@ Core::GeneratedFiles
|
|||||||
return Core::GeneratedFiles() << profile;
|
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 Internal
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ protected:
|
|||||||
|
|
||||||
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
||||||
QString *errorMessage) const;
|
QString *errorMessage) const;
|
||||||
|
|
||||||
|
QString generatedProjectFilePath(const QWizard *w) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -237,6 +237,15 @@ Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w,
|
|||||||
return rc;
|
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,
|
bool GuiAppWizard::parametrizeTemplate(const QString &templatePath, const QString &templateName,
|
||||||
const GuiAppParameters ¶ms,
|
const GuiAppParameters ¶ms,
|
||||||
QString *target, QString *errorMessage)
|
QString *target, QString *errorMessage)
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ protected:
|
|||||||
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
||||||
QString *errorMessage) const;
|
QString *errorMessage) const;
|
||||||
|
|
||||||
|
QString generatedProjectFilePath(const QWizard *w) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool parametrizeTemplate(const QString &templatePath, const QString &templateName,
|
static bool parametrizeTemplate(const QString &templatePath, const QString &templateName,
|
||||||
const GuiAppParameters ¶ms,
|
const GuiAppParameters ¶ms,
|
||||||
|
|||||||
@@ -137,5 +137,15 @@ Core::GeneratedFiles LibraryWizard::generateFiles(const QWizard *w,
|
|||||||
return rc;
|
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 Internal
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ protected:
|
|||||||
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
||||||
QString *errorMessage) const;
|
QString *errorMessage) const;
|
||||||
|
|
||||||
|
|
||||||
|
QString generatedProjectFilePath(const QWizard *w) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -184,5 +184,14 @@ Core::GeneratedFiles TestWizard::generateFiles(const QWizard *w, QString *errorM
|
|||||||
return Core::GeneratedFiles() << source << profile;
|
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 Internal
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ protected:
|
|||||||
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
virtual Core::GeneratedFiles generateFiles(const QWizard *w,
|
||||||
QString *errorMessage) const;
|
QString *errorMessage) const;
|
||||||
|
|
||||||
|
QString generatedProjectFilePath(const QWizard *w) const;
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
Reference in New Issue
Block a user