Commit 013441d5 authored by Roberto Raggi's avatar Roberto Raggi

Generic project manager.

parent 5b683c84
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="text/x-generic-project">
<sub-class-of type="text/plain"/>
<comment>Generic Project file</comment>
<glob pattern="*.files"/>
</mime-type>
</mime-info>
<plugin name="GenericProjectManager" version="1.0.80" compatVersion="1.0.80">
<vendor>Nokia Corporation</vendor>
<copyright>(C) 2008-2009 Nokia Corporation</copyright>
<license>
Commercial Usage
Licensees holding valid Qt Commercial licenses may use this plugin in
accordance with the Qt Commercial License Agreement provided with the
Software or, alternatively, in accordance with the terms contained in
a written agreement between you and Nokia.
GNU Lesser General Public License Usage
Alternatively, this plugin may be used under the terms of the GNU Lesser
General Public License version 2.1 as published by the Free Software
Foundation. Please review the following information to
ensure the GNU Lesser General Public License version 2.1 requirements
will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license>
<description>Generic support</description>
<url>http://www.qtsoftware.com</url>
<dependencyList>
<dependency name="TextEditor" version="1.0.80"/>
<dependency name="ProjectExplorer" version="1.0.80"/>
<dependency name="CppTools" version="1.0.80"/>
<dependency name="CppEditor" version="1.0.80"/>
<dependency name="Help" version="1.0.80"/>
</dependencyList>
</plugin>
This diff is collapsed.
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef GENERICPROJECT_H
#define GENERICPROJECT_H
#include "genericprojectmanager.h"
#include "genericprojectnodes.h"
#include "makestep.h"
#include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
#include <projectexplorer/buildstep.h>
#include <projectexplorer/toolchain.h>
#include <coreplugin/ifile.h>
#include <utils/pathchooser.h>
namespace GenericProjectManager {
namespace Internal{
class GenericProjectFile;
class GenericProject : public ProjectExplorer::Project
{
Q_OBJECT
public:
GenericProject(Manager *manager, const QString &filename);
virtual ~GenericProject();
virtual QString name() const;
virtual Core::IFile *file() const;
virtual ProjectExplorer::IProjectManager *projectManager() const;
virtual QList<ProjectExplorer::Project *> dependsOn();
virtual bool isApplication() const;
virtual ProjectExplorer::Environment environment(const QString &buildConfiguration) const;
virtual QString buildDirectory(const QString &buildConfiguration) const;
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
virtual QList<ProjectExplorer::BuildStepConfigWidget*> subConfigWidgets();
virtual void newBuildConfiguration(const QString &buildConfiguration);
virtual ProjectExplorer::ProjectNode *rootProjectNode() const;
virtual QStringList files(FilesMode fileMode) const;
void setToolChain(const QString &toolChainId);
QStringList targets() const;
MakeStep *makeStep() const;
QString buildParser(const QString &buildConfiguration) const;
private:
void refresh();
protected:
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
virtual void restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader);
private:
Manager *_manager;
QString _fileName;
GenericProjectFile *_file;
QString _projectName;
GenericProjectNode* _rootNode;
ProjectExplorer::ToolChain *_toolChain;
};
class GenericProjectFile : public Core::IFile
{
Q_OBJECT
public:
GenericProjectFile(GenericProject *parent, QString fileName);
virtual ~GenericProjectFile();
virtual bool save(const QString &fileName = QString());
virtual QString fileName() const;
virtual QString defaultPath() const;
virtual QString suggestedFileName() const;
virtual QString mimeType() const;
virtual bool isModified() const;
virtual bool isReadOnly() const;
virtual bool isSaveAsAllowed() const;
virtual void modified(ReloadBehavior *behavior);
private:
GenericProject *_project;
QString _fileName;
};
class GenericBuildSettingsWidget : public ProjectExplorer::BuildStepConfigWidget
{
Q_OBJECT
public:
GenericBuildSettingsWidget(GenericProject *project);
virtual ~GenericBuildSettingsWidget();
virtual QString displayName() const;
virtual void init(const QString &buildConfiguration);
private Q_SLOTS:
void buildDirectoryChanged();
private:
GenericProject *_project;
Core::Utils::PathChooser *_pathChooser;
QString _buildConfiguration;
};
} // namespace Internal
} // namespace GenericProjectManager
#endif // GENERICPROJECT_H
<RCC>
<qresource prefix="/genericproject" >
<file>GenericProject.mimetypes.xml</file>
</qresource>
</RCC>
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef GENERICPROJECTCONSTANTS_H
#define GENERICPROJECTCONSTANTS_H
namespace GenericProjectManager {
namespace Constants {
const char *const PROJECTCONTEXT = "GenericProject.ProjectContext";
const char *const GENERICMIMETYPE = "text/x-generic-project";
const char *const MAKESTEP = "GenericProjectManager.MakeStep";
} // namespace Constants
} // namespace GenericProjectManager
#endif // GENERICPROJECTCONSTANTS_H
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "genericprojectmanager.h"
#include "genericprojectconstants.h"
#include "genericproject.h"
#include <coreplugin/icore.h>
#include <coreplugin/uniqueidmanager.h>
#include <projectexplorer/projectexplorerconstants.h>
using namespace GenericProjectManager::Internal;
Manager::Manager()
{
Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
_projectContext = uidm->uniqueIdentifier(GenericProjectManager::Constants::PROJECTCONTEXT);
_projectLanguage = uidm->uniqueIdentifier(ProjectExplorer::Constants::LANG_CXX);
}
Manager::~Manager()
{ }
int Manager::projectContext() const
{ return _projectContext; }
int Manager::projectLanguage() const
{ return _projectLanguage; }
QString Manager::mimeType() const
{ return QLatin1String(Constants::GENERICMIMETYPE); }
ProjectExplorer::Project *Manager::openProject(const QString &fileName)
{
QFileInfo fileInfo(fileName);
if (fileInfo.isFile())
return new GenericProject(this, fileName);
return 0;
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef GENERICPROJECTMANAGER_H
#define GENERICPROJECTMANAGER_H
#include <projectexplorer/iprojectmanager.h>
namespace GenericProjectManager {
namespace Internal {
class Manager: public ProjectExplorer::IProjectManager
{
Q_OBJECT
public:
Manager();
virtual ~Manager();
virtual int projectContext() const;
virtual int projectLanguage() const;
virtual QString mimeType() const;
virtual ProjectExplorer::Project *openProject(const QString &fileName);
private:
int _projectContext;
int _projectLanguage;
};
} // namespace Internal
} // namespace GenericProjectManager
#endif // GENERICPROJECTMANAGER_H
TEMPLATE = lib
TARGET = GenericProjectManager
include(../../qworkbenchplugin.pri)
include(genericprojectmanager_dependencies.pri)
HEADERS = genericproject.h \
genericprojectplugin.h \
genericprojectmanager.h \
genericprojectconstants.h \
genericprojectnodes.h \
makestep.h
SOURCES = genericproject.cpp \
genericprojectplugin.cpp \
genericprojectmanager.cpp \
genericprojectnodes.cpp \
makestep.cpp
RESOURCES += genericproject.qrc
FORMS +=
include(../../plugins/projectexplorer/projectexplorer.pri)
include(../../plugins/cpptools/cpptools.pri)
include(../../plugins/cppeditor/cppeditor.pri)
include(../../plugins/texteditor/texteditor.pri)
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "genericprojectnodes.h"
#include <QFileInfo>
#include <QSettings>
#include <QtDebug>
using namespace GenericProjectManager;
using namespace GenericProjectManager::Internal;
GenericProjectNode::GenericProjectNode(Core::IFile *projectFile)
: ProjectExplorer::ProjectNode(QFileInfo(projectFile->fileName()).absolutePath()),
_projectFile(projectFile)
{}
GenericProjectNode::~GenericProjectNode()
{ }
Core::IFile *GenericProjectNode::projectFile() const
{ return _projectFile; }
QString GenericProjectNode::projectFilePath() const
{ return _projectFile->fileName(); }
void GenericProjectNode::refresh()
{
QSettings projectInfo(projectFilePath(), QSettings::IniFormat);
_files = projectInfo.value(QLatin1String("files")).toStringList();
_generated = projectInfo.value(QLatin1String("generated")).toStringList();
_includePaths = projectInfo.value(QLatin1String("includes")).toStringList();
_defines = projectInfo.value(QLatin1String("defines")).toStringList();
_toolChainId = projectInfo.value(QLatin1String("toolchain"), QLatin1String("gcc")).toString().toLower();
using namespace ProjectExplorer;
QList<FileNode *> fileNodes;
FileNode *projectFileNode = new FileNode(projectFilePath(), ProjectFileType, /*generated = */ false);
fileNodes.append(projectFileNode);
foreach (const QString &file, _files) {
QFileInfo fileInfo(file);
QString filePath = fileInfo.absoluteFilePath();
FileType fileType = SourceType;
FileNode *fileNode = new FileNode(filePath, fileType, /*generated = */ false);
fileNodes.append(fileNode);
}
addFileNodes(fileNodes, this);
}
QStringList GenericProjectNode::files() const
{ return _files; }
QStringList GenericProjectNode::generated() const
{ return _generated; }
QStringList GenericProjectNode::includePaths() const
{ return _includePaths; }
QStringList GenericProjectNode::defines() const
{ return _defines; }
QString GenericProjectNode::toolChainId() const
{ return _toolChainId; }
bool GenericProjectNode::hasTargets() const
{
qDebug() << Q_FUNC_INFO;
return true;
}
QList<ProjectExplorer::ProjectNode::ProjectAction> GenericProjectNode::supportedActions() const
{
qDebug() << Q_FUNC_INFO;
return QList<ProjectAction>();
}
bool GenericProjectNode::addSubProjects(const QStringList &proFilePaths)
{
qDebug() << Q_FUNC_INFO;
Q_UNUSED(proFilePaths);
return false;
}
bool GenericProjectNode::removeSubProjects(const QStringList &proFilePaths)
{
qDebug() << Q_FUNC_INFO;
Q_UNUSED(proFilePaths);
return false;
}
bool GenericProjectNode::addFiles(const ProjectExplorer::FileType fileType,
const QStringList &filePaths, QStringList *notAdded)
{
qDebug() << Q_FUNC_INFO;
Q_UNUSED(fileType);
Q_UNUSED(filePaths);
Q_UNUSED(notAdded);
return false;
}
bool GenericProjectNode::removeFiles(const ProjectExplorer::FileType fileType,
const QStringList &filePaths, QStringList *notRemoved)
{
qDebug() << Q_FUNC_INFO;
Q_UNUSED(fileType);
Q_UNUSED(filePaths);
Q_UNUSED(notRemoved);
return false;
}
bool GenericProjectNode::renameFile(const ProjectExplorer::FileType fileType,
const QString &filePath, const QString &newFilePath)
{
qDebug() << Q_FUNC_INFO;
Q_UNUSED(fileType);
Q_UNUSED(filePath);
Q_UNUSED(newFilePath);
return false;
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef GENERICPROJECTNODE_H
#define GENERICPROJECTNODE_H
#include <coreplugin/ifile.h>
#include <projectexplorer/projectnodes.h>
#include <QStringList>
namespace GenericProjectManager {
namespace Internal {
class GenericProjectNode : public ProjectExplorer::ProjectNode
{
public:
GenericProjectNode(Core::IFile *projectFile);
virtual ~GenericProjectNode();
Core::IFile *projectFile() const;
QString projectFilePath() const;
virtual bool hasTargets() const;
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions() const;
virtual bool addSubProjects(const QStringList &proFilePaths);
virtual bool removeSubProjects(const QStringList &proFilePaths);
virtual bool addFiles(const ProjectExplorer::FileType fileType,
const QStringList &filePaths,
QStringList *notAdded = 0);
virtual bool removeFiles(const ProjectExplorer::FileType fileType,
const QStringList &filePaths,
QStringList *notRemoved = 0);
virtual bool renameFile(const ProjectExplorer::FileType fileType,
const QString &filePath,
const QString &newFilePath);
void refresh();
QStringList files() const;
QStringList generated() const;
QStringList includePaths() const;
QStringList defines() const;
QString toolChainId() const;
private:
Core::IFile *_projectFile;
QStringList _files;
QStringList _generated;
QStringList _includePaths;
QStringList _defines;
QString _toolChainId;
};
} // namespace Internal
} // namespace GenericProjectManager
#endif // GENERICPROJECTNODE_H
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software