Commit 6083988b authored by hjk's avatar hjk

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents f73a4d5f e0d91157
......@@ -988,13 +988,16 @@ void CppModelManager::parse(QFutureInterface<void> &future,
Core::MimeType cSourceTy = db->findByType(QLatin1String("text/x-csrc"));
Core::MimeType cppSourceTy = db->findByType(QLatin1String("text/x-c++src"));
Core::MimeType cHeaderTy = db->findByType(QLatin1String("text/x-hdr"));
Core::MimeType cppHeaderTy = db->findByType(QLatin1String("text/x-c++hdr"));
foreach (const QString &file, files) {
const QFileInfo fileInfo(file);
if (cSourceTy.matchesFile(fileInfo) || cppSourceTy.matchesFile(fileInfo))
sources.append(file);
else
else if (cHeaderTy.matchesFile(fileInfo) || cppHeaderTy.matchesFile(fileInfo))
headers.append(file);
}
......
......@@ -231,7 +231,7 @@ QString CppToolsPlugin::correspondingHeaderOrSourceI(const QString &fileName) co
return QString();
const QDir absoluteDir = fi.absoluteDir();
const QString baseName = fi.baseName();
const QString baseName = fi.completeBaseName();
const QStringList suffixes = matchingCandidateSuffixes(mimeDatase, type);
const QString privateHeaderSuffix = QLatin1String("_p");
......
<?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 Qt Creator Project file</comment>
<glob pattern="*.creator"/>
</mime-type>
<mime-type type="application/vnd.nokia.qt.generic.files">
<sub-class-of type="text/plain"/>
<comment>Generic Project Files</comment>
<glob pattern="*.files"/>
</mime-type>
<mime-type type="application/vnd.nokia.qt.generic.includes">
<sub-class-of type="text/plain"/>
<comment>Generic Project Include Paths</comment>
<glob pattern="*.includes"/>
</mime-type>
<mime-type type="application/vnd.nokia.qt.generic.config">
<sub-class-of type="text/plain"/>
<comment>Generic Project Configuration File</comment>
<glob pattern="*.config"/>
</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>
QT_BEGIN_NAMESPACE
class QPushButton;
class QStringListModel;
QT_END_NAMESPACE
namespace GenericProjectManager {
namespace Internal{
class GenericProjectFile;
class GenericProject : public ProjectExplorer::Project
{
Q_OBJECT
public:
GenericProject(Manager *manager, const QString &filename);
virtual ~GenericProject();
QString filesFileName() const;
QString includesFileName() const;
QString configFileName() const;
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 GenericProjectNode *rootProjectNode() const;
virtual QStringList files(FilesMode fileMode) const;
QStringList targets() const;
MakeStep *makeStep() const;
QString buildParser(const QString &buildConfiguration) const;
QStringList convertToAbsoluteFiles(const QStringList &paths) const;
QStringList includePaths() const;
void setIncludePaths(const QStringList &includePaths);
QByteArray defines() const;
QStringList allIncludePaths() const;
QStringList projectIncludePaths() const;
QStringList files() const;
QStringList generated() const;
QString toolChainId() const;
public Q_SLOTS:
void setToolChainId(const QString &toolChainId);
void refresh();
protected:
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
virtual void restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader);
private:
void parseProject();
QStringList readLines(const QString &absoluteFileName) const;
Manager *_manager;
QString _fileName;
QString _filesFileName;
QString _includesFileName;
QString _configFileName;
GenericProjectFile *_file;
QString _projectName;
QStringList _files;
QStringList _generated;
QStringList _includePaths;
QStringList _projectIncludePaths;
QByteArray _defines;
GenericProjectNode* _rootNode;
ProjectExplorer::ToolChain *_toolChain;
QString _toolChainId;
};
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"; // ### FIXME
const char *const MAKESTEP = "GenericProjectManager.MakeStep";
// contexts
const char *const C_FILESEDITOR = ".files Editor";
// kinds
const char *const PROJECT_KIND = "Generic";
const char *const FILES_EDITOR = ".files Editor";
const char *const FILES_MIMETYPE = "application/vnd.nokia.qt.generic.files";
const char *const INCLUDES_EDITOR = ".includes Editor";
const char *const INCLUDES_MIMETYPE = "application/vnd.nokia.qt.generic.includes";
const char *const CONFIG_EDITOR = ".includes Editor";
const char *const CONFIG_MIMETYPE = "application/vnd.nokia.qt.generic.config";
} // namespace Constants
} // namespace GenericProjectManager
#endif // GENERICPROJECTCONSTANTS_H
#include "genericprojectfileseditor.h"
#include "genericprojectmanager.h"
#include "genericprojectconstants.h"
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QtDebug>
using namespace GenericProjectManager;
using namespace GenericProjectManager::Internal;
////////////////////////////////////////////////////////////////////////////////////////
// ProjectFilesEditable
////////////////////////////////////////////////////////////////////////////////////////
ProjectFilesFactory::ProjectFilesFactory(Manager *manager,
TextEditor::TextEditorActionHandler *handler)
: Core::IEditorFactory(manager),
_manager(manager),
_actionHandler(handler)
{
_mimeTypes.append(QLatin1String(Constants::FILES_MIMETYPE));
_mimeTypes.append(QLatin1String(Constants::INCLUDES_MIMETYPE));
_mimeTypes.append(QLatin1String(Constants::CONFIG_MIMETYPE));
}
ProjectFilesFactory::~ProjectFilesFactory()
{ }
Manager *ProjectFilesFactory::manager() const
{ return _manager; }
Core::IEditor *ProjectFilesFactory::createEditor(QWidget *parent)
{
ProjectFilesEditor *ed = new ProjectFilesEditor(parent, this, _actionHandler);
// ### initialize
return ed->editableInterface();
}
QStringList ProjectFilesFactory::mimeTypes() const
{ return _mimeTypes; }
QString ProjectFilesFactory::kind() const
{ return QLatin1String(Constants::FILES_EDITOR); }
Core::IFile *ProjectFilesFactory::open(const QString &fileName)
{
Core::EditorManager *editorManager = Core::EditorManager::instance();
if (Core::IEditor *editor = editorManager->openEditor(fileName, kind()))
return editor->file();
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////
// ProjectFilesEditable
////////////////////////////////////////////////////////////////////////////////////////
ProjectFilesEditable::ProjectFilesEditable(ProjectFilesEditor *editor)
: TextEditor::BaseTextEditorEditable(editor)
{
Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
_context << uidm->uniqueIdentifier(Constants::C_FILESEDITOR);
}
ProjectFilesEditable::~ProjectFilesEditable()
{ }
QList<int> ProjectFilesEditable::context() const
{ return _context; }
const char *ProjectFilesEditable::kind() const
{ return Constants::FILES_EDITOR; }
bool ProjectFilesEditable::duplicateSupported() const
{ return true; }
Core::IEditor *ProjectFilesEditable::duplicate(QWidget *parent)
{
ProjectFilesEditor *parentEditor = qobject_cast<ProjectFilesEditor *>(editor());
ProjectFilesEditor *editor = new ProjectFilesEditor(parent,
parentEditor->factory(),
parentEditor->actionHandler());
return editor->editableInterface();
}
////////////////////////////////////////////////////////////////////////////////////////
// ProjectFilesEditor
////////////////////////////////////////////////////////////////////////////////////////
ProjectFilesEditor::ProjectFilesEditor(QWidget *parent, ProjectFilesFactory *factory,
TextEditor::TextEditorActionHandler *handler)
: TextEditor::BaseTextEditor(parent),
_factory(factory),
_actionHandler(handler)
{
Manager *manager = factory->manager();
ProjectFilesDocument *doc = new ProjectFilesDocument(manager);
setBaseTextDocument(doc);
}
ProjectFilesEditor::~ProjectFilesEditor()
{ }
ProjectFilesFactory *ProjectFilesEditor::factory() const
{ return _factory; }
TextEditor::TextEditorActionHandler *ProjectFilesEditor::actionHandler() const
{ return _actionHandler; }
TextEditor::BaseTextEditorEditable *ProjectFilesEditor::createEditableInterface()
{ return new ProjectFilesEditable(this); }
////////////////////////////////////////////////////////////////////////////////////////
// ProjectFilesDocument
////////////////////////////////////////////////////////////////////////////////////////
ProjectFilesDocument::ProjectFilesDocument(Manager *manager)
: _manager(manager)
{
setMimeType(QLatin1String(Constants::FILES_MIMETYPE));
}
ProjectFilesDocument::~ProjectFilesDocument()
{ }
bool ProjectFilesDocument::save(const QString &name)
{
if (! BaseTextDocument::save(name))
return false;
_manager->notifyChanged(name);
return true;
}
#ifndef GENERICPROJECTFILESEDITOR_H
#define GENERICPROJECTFILESEDITOR_H
#include <texteditor/basetexteditor.h>
#include <texteditor/basetextdocument.h>
#include <coreplugin/editormanager/ieditorfactory.h>
namespace GenericProjectManager {
namespace Internal {
class Manager;
class ProjectFilesEditable;
class ProjectFilesEditor;
class ProjectFilesDocument;
class ProjectFilesFactory;
class ProjectFilesFactory: public Core::IEditorFactory
{
Q_OBJECT
public:
ProjectFilesFactory(Manager *manager, TextEditor::TextEditorActionHandler *handler);
virtual ~ProjectFilesFactory();
Manager *manager() const;
virtual Core::IEditor *createEditor(QWidget *parent);
virtual QStringList mimeTypes() const;
virtual QString kind() const;
virtual Core::IFile *open(const QString &fileName);
private:
Manager *_manager;
TextEditor::TextEditorActionHandler *_actionHandler;
QStringList _mimeTypes;
};
class ProjectFilesEditable: public TextEditor::BaseTextEditorEditable
{
Q_OBJECT
public:
ProjectFilesEditable(ProjectFilesEditor *editor);
virtual ~ProjectFilesEditable();
virtual QList<int> context() const;
virtual const char *kind() const;
virtual bool duplicateSupported() const;
virtual Core::IEditor *duplicate(QWidget *parent);
private:
QList<int> _context;
};
class ProjectFilesEditor: public TextEditor::BaseTextEditor
{
Q_OBJECT
public:
ProjectFilesEditor(QWidget *parent, ProjectFilesFactory *factory,
TextEditor::TextEditorActionHandler *handler);
virtual ~ProjectFilesEditor();
ProjectFilesFactory *factory() const;
TextEditor::TextEditorActionHandler *actionHandler() const;
virtual TextEditor::BaseTextEditorEditable *createEditableInterface();
private:
ProjectFilesFactory *_factory;
TextEditor::TextEditorActionHandler *_actionHandler;
};
class ProjectFilesDocument: public TextEditor::BaseTextDocument
{
Q_OBJECT
public:
ProjectFilesDocument(Manager *manager);
virtual ~ProjectFilesDocument();
virtual bool save(const QString &name);
private:
Manager *_manager;
};
} // end of namespace Internal
} // end of namespace GenericProjectManager
#endif // GENERICPROJECTFILESEDITOR_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>
#include <QtDebug>
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()) {
GenericProject *project = new GenericProject(this, fileName);
return project;
}
return 0;
}
void Manager::registerProject(GenericProject *project)
{ _projects.append(project); }
void Manager::unregisterProject(GenericProject *project)
{ _projects.removeAll(project); }
void Manager::notifyChanged(const QString &fileName)
{
foreach (GenericProject *project, _projects) {
if (fileName == project->filesFileName() ||
fileName == project->includesFileName() ||
fileName == project->configFileName())
project->refresh();
}