VcProjectDocument implements IVisualStudioProject interface.

Change-Id: I063d712950fb98fe9b2b13c02bb8535869029052
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Radovan Zivkovic
2013-10-13 23:25:25 +02:00
committed by Oswald Buddenhagen
parent 1acbf03101
commit e6cd63861b
21 changed files with 294 additions and 778 deletions

View File

@@ -42,7 +42,6 @@ class IFiles : public IVcProjectXMLNode
{ {
public: public:
virtual ~IFiles() {} virtual ~IFiles() {}
virtual IFiles& operator=(const IFiles &files) = 0;
virtual void addFile(IFile *file) = 0; virtual void addFile(IFile *file) = 0;
virtual void removeFile(IFile *file) = 0; virtual void removeFile(IFile *file) = 0;
virtual int fileCount() const = 0; virtual int fileCount() const = 0;

View File

@@ -28,4 +28,5 @@ HEADERS += \
interfaces/iplatform.h \ interfaces/iplatform.h \
interfaces/iplatforms.h \ interfaces/iplatforms.h \
interfaces/ipublishingitem.h \ interfaces/ipublishingitem.h \
interfaces/ipublishingdata.h interfaces/ipublishingdata.h \
interfaces/ivisualstudioproject.h

View File

@@ -0,0 +1,71 @@
/**************************************************************************
**
** Copyright (c) 2013 Bojan Petrovic
** Copyright (c) 2013 Radovan Zivkovic
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef VCPROJECTMANAGER_INTERNAL_IVISUALSTUDIOPROJECT_H
#define VCPROJECTMANAGER_INTERNAL_IVISUALSTUDIOPROJECT_H
#include <QString>
#include "../vcprojectmodel/ivcprojectnodemodel.h"
#include "../vcprojectmodel/vcprojectdocument_constants.h"
namespace VcProjectManager {
namespace Internal {
class IConfigurations;
class IPlatforms;
class IGlobals;
class IReferences;
class IFiles;
class ISettingsWidget;
class IToolFiles;
class IPublishingData;
class IAttributeContainer;
class IVisualStudioProject : public IVcProjectXMLNode
{
public:
virtual ~IVisualStudioProject() {}
virtual IAttributeContainer* attributeContainer() const = 0;
virtual IConfigurations* configurations() const = 0;
virtual IFiles* files() const = 0;
virtual IGlobals* globals() const = 0;
virtual IPlatforms* platforms() const = 0;
virtual IReferences* referencess() const = 0;
virtual IToolFiles* toolFiles() const = 0;
virtual IPublishingData* publishingData() const = 0;
virtual QString filePath() const = 0;
virtual bool saveToFile(const QString &filePath) const = 0;
virtual VcDocConstants::DocumentVersion documentVersion() const = 0;
};
} // namespace Internal
} // namespace VcProjectManager
#endif // VCPROJECTMANAGER_INTERNAL_IVISUALSTUDIOPROJECT_H

View File

@@ -139,7 +139,7 @@ QStringList VcProject::files(Project::FilesMode fileMode) const
// TODO: respect the mode // TODO: respect the mode
QStringList sl; QStringList sl;
if (m_projectFile && m_projectFile->documentModel() && m_projectFile->documentModel()->vcProjectDocument()) if (m_projectFile && m_projectFile->documentModel() && m_projectFile->documentModel()->vcProjectDocument())
m_projectFile->documentModel()->vcProjectDocument()->allProjectFiles(sl); allProjectFile(sl);
return sl; return sl;
} }
@@ -150,20 +150,6 @@ QString VcProject::defaultBuildDirectory() const
return vcFile->path()/* + QLatin1String("-build")*/; return vcFile->path()/* + QLatin1String("-build")*/;
} }
MsBuildInformation::MsBuildVersion VcProject::minSupportedMsBuild() const
{
if (m_projectFile && m_projectFile->documentModel() && m_projectFile->documentModel()->vcProjectDocument())
return m_projectFile->documentModel()->vcProjectDocument()->minSupportedMsBuildVersion();
return MsBuildInformation::MSBUILD_V_UNKNOWN;
}
MsBuildInformation::MsBuildVersion VcProject::maxSupportedMsBuild() const
{
if (m_projectFile && m_projectFile->documentModel() && m_projectFile->documentModel()->vcProjectDocument())
return m_projectFile->documentModel()->vcProjectDocument()->maxSupportedMsBuildVersion();
return MsBuildInformation::MSBUILD_V_UNKNOWN;
}
bool VcProject::needsConfiguration() const bool VcProject::needsConfiguration() const
{ {
return targets().isEmpty() || !activeTarget() || activeTarget()->buildConfigurations().isEmpty(); return targets().isEmpty() || !activeTarget() || activeTarget()->buildConfigurations().isEmpty();
@@ -208,7 +194,7 @@ void VcProject::onSettingsDialogAccepted()
VcProjectDocumentWidget *settingsWidget = qobject_cast<VcProjectDocumentWidget *>(QObject::sender()); VcProjectDocumentWidget *settingsWidget = qobject_cast<VcProjectDocumentWidget *>(QObject::sender());
m_projectFile->documentModel()->saveToFile(m_projectFile->filePath()); m_projectFile->documentModel()->saveToFile(m_projectFile->filePath());
settingsWidget->deleteLater(); settingsWidget->deleteLater();
Configurations::Ptr configs = m_projectFile->documentModel()->vcProjectDocument()->configurations(); IConfigurations *configs = m_projectFile->documentModel()->vcProjectDocument()->configurations();
if (configs) { if (configs) {
QList<ProjectExplorer::Target *> targetList = targets(); QList<ProjectExplorer::Target *> targetList = targets();
@@ -419,6 +405,23 @@ VcProjectBuildConfiguration *VcProject::findBuildConfiguration(Target *target, c
return 0; return 0;
} }
void VcProject::allProjectFile(QStringList &allFiles) const
{
if (m_projectFile && m_projectFile->documentModel() && m_projectFile->documentModel()->vcProjectDocument()) {
for (int i = 0; i < m_projectFile->documentModel()->vcProjectDocument()->files()->fileContainerCount(); ++i) {
IFileContainer *fileContainer = m_projectFile->documentModel()->vcProjectDocument()->files()->fileContainer(i);
if (fileContainer)
fileContainer->allFiles(allFiles);
}
for (int i = 0; i < m_projectFile->documentModel()->vcProjectDocument()->files()->fileCount(); ++i) {
IFile *file = m_projectFile->documentModel()->vcProjectDocument()->files()->file(i);
if (file)
allFiles.append(file->canonicalPath());
}
}
}
VcProjectBuildSettingsWidget::VcProjectBuildSettingsWidget() VcProjectBuildSettingsWidget::VcProjectBuildSettingsWidget()
{ {
QFormLayout *f1 = new QFormLayout(this); QFormLayout *f1 = new QFormLayout(this);

View File

@@ -69,8 +69,6 @@ public:
ProjectExplorer::ProjectNode *rootProjectNode() const; ProjectExplorer::ProjectNode *rootProjectNode() const;
QStringList files(FilesMode fileMode) const; QStringList files(FilesMode fileMode) const;
QString defaultBuildDirectory() const; QString defaultBuildDirectory() const;
MsBuildInformation::MsBuildVersion minSupportedMsBuild() const;
MsBuildInformation::MsBuildVersion maxSupportedMsBuild() const;
bool needsConfiguration() const; bool needsConfiguration() const;
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const; bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const;
@@ -92,7 +90,7 @@ private:
void importBuildConfigurations(); void importBuildConfigurations();
void addBuildConfiguration(ProjectExplorer::Target *target, IConfiguration *config); void addBuildConfiguration(ProjectExplorer::Target *target, IConfiguration *config);
VcProjectBuildConfiguration* findBuildConfiguration(ProjectExplorer::Target *target, const QString &buildConfigurationName) const; VcProjectBuildConfiguration* findBuildConfiguration(ProjectExplorer::Target *target, const QString &buildConfigurationName) const;
void allProjectFile(QStringList &allFiles) const;
VcManager *m_projectManager; VcManager *m_projectManager;
VcProjectFile *m_projectFile; VcProjectFile *m_projectFile;
VcDocProjectNode *m_rootNode; VcDocProjectNode *m_rootNode;

View File

@@ -40,7 +40,7 @@
namespace VcProjectManager { namespace VcProjectManager {
namespace Internal { namespace Internal {
File::File(VcProjectDocument *parentProjectDoc) File::File(IVisualStudioProject *parentProjectDoc)
: m_parentProjectDoc(parentProjectDoc) : m_parentProjectDoc(parentProjectDoc)
{ {
m_configurationContainer = new ConfigurationContainer; m_configurationContainer = new ConfigurationContainer;

View File

@@ -38,7 +38,7 @@
namespace VcProjectManager { namespace VcProjectManager {
namespace Internal { namespace Internal {
class VcProjectDocument; class IVisualStudioProject;
class File : public IFile class File : public IFile
{ {
@@ -47,7 +47,7 @@ class File : public IFile
public: public:
typedef QSharedPointer<File> Ptr; typedef QSharedPointer<File> Ptr;
File(VcProjectDocument *parentProjectDoc); File(IVisualStudioProject *parentProjectDoc);
File(const File &file); File(const File &file);
File& operator=(const File &file); File& operator=(const File &file);
~File(); ~File();
@@ -73,7 +73,7 @@ private:
QString m_relativePath; // required QString m_relativePath; // required
QList<QSharedPointer<File> > m_files; QList<QSharedPointer<File> > m_files;
VcProjectDocument *m_parentProjectDoc; IVisualStudioProject *m_parentProjectDoc;
ConfigurationContainer *m_configurationContainer; ConfigurationContainer *m_configurationContainer;
GeneralAttributeContainer *m_attributeContainer; GeneralAttributeContainer *m_attributeContainer;
}; };

View File

@@ -35,36 +35,41 @@
namespace VcProjectManager { namespace VcProjectManager {
namespace Internal { namespace Internal {
Files::Files(VcProjectDocument *parentProject) Files::Files(IVisualStudioProject *parentProject)
: m_parentProject(parentProject) : m_parentProject(parentProject)
{ {
} }
Files::Files(const Files &files) Files::Files(const Files &files)
{ {
foreach (IFile *file, files.m_files) m_parentProject = files.m_parentProject;
m_files.append(file->clone());
foreach (IFileContainer *filter, files.m_fileContainers) foreach (IFile *file, files.m_files) {
m_fileContainers.append(filter->clone()); if (file)
m_files.append(file->clone());
}
foreach (IFileContainer *fileContainer, files.m_fileContainers) {
if (fileContainer)
m_fileContainers.append(fileContainer->clone());
}
} }
IFiles &Files::operator =(const IFiles &files) Files &Files::operator =(const Files &files)
{ {
if (this != &files) { if (this != &files) {
qDeleteAll(m_files); qDeleteAll(m_files);
qDeleteAll(m_fileContainers); qDeleteAll(m_fileContainers);
m_files.clear(); m_files.clear();
m_fileContainers.clear(); m_fileContainers.clear();
m_parentProject = files.m_parentProject;
for (int i = 0; i < files.fileCount(); ++i) { foreach (IFile *file, files.m_files) {
IFile *file = files.file(i);
if (file) if (file)
m_files.append(file->clone()); m_files.append(file->clone());
} }
for (int i = 0; i < files.fileContainerCount(); ++i) { foreach (IFileContainer *fileContainer, files.m_fileContainers) {
IFileContainer *fileContainer = files.fileContainer(i);
if (fileContainer) if (fileContainer)
m_fileContainers.append(fileContainer->clone()); m_fileContainers.append(fileContainer->clone());
} }

View File

@@ -45,9 +45,9 @@ class Files : public IFiles
public: public:
typedef QSharedPointer<Files> Ptr; typedef QSharedPointer<Files> Ptr;
Files(VcProjectDocument *parentProject); Files(IVisualStudioProject *parentProject);
Files(const Files &files); Files(const Files &files);
IFiles &operator =(const IFiles &files); Files &operator =(const Files &files);
~Files(); ~Files();
void processNode(const QDomNode &node); void processNode(const QDomNode &node);
@@ -73,7 +73,7 @@ protected:
QList<IFileContainer *> m_fileContainers; QList<IFileContainer *> m_fileContainers;
QList<IFile *> m_files; QList<IFile *> m_files;
VcProjectDocument *m_parentProject; IVisualStudioProject *m_parentProject;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -38,7 +38,7 @@
namespace VcProjectManager { namespace VcProjectManager {
namespace Internal { namespace Internal {
Filter::Filter(VcProjectDocument *parentProjectDoc) Filter::Filter(IVisualStudioProject *parentProjectDoc)
: m_parentProjectDoc(parentProjectDoc) : m_parentProjectDoc(parentProjectDoc)
{ {
m_attributeContainer = new GeneralAttributeContainer; m_attributeContainer = new GeneralAttributeContainer;

View File

@@ -42,7 +42,7 @@ class Filter;
class Filter : public IFileContainer class Filter : public IFileContainer
{ {
public: public:
Filter(VcProjectDocument *parentProjectDoc); Filter(IVisualStudioProject *parentProjectDoc);
Filter(const Filter &filter); Filter(const Filter &filter);
Filter& operator=(const Filter &filter); Filter& operator=(const Filter &filter);
~Filter(); ~Filter();
@@ -80,7 +80,7 @@ private:
QString m_name; QString m_name;
QList<IFileContainer *> m_fileContainers; QList<IFileContainer *> m_fileContainers;
QList<IFile *> m_files; QList<IFile *> m_files;
VcProjectDocument *m_parentProjectDoc; IVisualStudioProject *m_parentProjectDoc;
GeneralAttributeContainer *m_attributeContainer; GeneralAttributeContainer *m_attributeContainer;
}; };

View File

@@ -38,7 +38,7 @@
namespace VcProjectManager { namespace VcProjectManager {
namespace Internal { namespace Internal {
Folder::Folder(VcProjectDocument *parentProjectDoc) Folder::Folder(IVisualStudioProject *parentProjectDoc)
: m_parentProjectDoc(parentProjectDoc) : m_parentProjectDoc(parentProjectDoc)
{ {
m_attributeContainer = new GeneralAttributeContainer; m_attributeContainer = new GeneralAttributeContainer;

View File

@@ -40,7 +40,7 @@ namespace Internal {
class Folder : public IFileContainer class Folder : public IFileContainer
{ {
public: public:
Folder(VcProjectDocument *parentProjectDoc); Folder(IVisualStudioProject *parentProjectDoc);
Folder(const Folder &folder); Folder(const Folder &folder);
Folder& operator=(const Folder &folder); Folder& operator=(const Folder &folder);
~Folder(); ~Folder();
@@ -80,7 +80,7 @@ private:
QList<IFileContainer *> m_fileContainers; QList<IFileContainer *> m_fileContainers;
QString m_name; // required QString m_name; // required
VcProjectDocument *m_parentProjectDoc; IVisualStudioProject *m_parentProjectDoc;
GeneralAttributeContainer *m_attributeContainer; GeneralAttributeContainer *m_attributeContainer;
}; };

View File

@@ -38,6 +38,7 @@
#include <QFileInfo> #include <QFileInfo>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <QDir>
namespace VcProjectManager { namespace VcProjectManager {
namespace Internal { namespace Internal {
@@ -236,7 +237,7 @@ VcFileNode *VcFileContainerNode::findFileNode(const QString &filePath)
return 0; return 0;
} }
VcDocProjectNode::VcDocProjectNode(VcProjectDocument *vcProjectModel) VcDocProjectNode::VcDocProjectNode(IVisualStudioProject *vcProjectModel)
: ProjectExplorer::ProjectNode(vcProjectModel->filePath()), : ProjectExplorer::ProjectNode(vcProjectModel->filePath()),
m_vcProjectModel(vcProjectModel) m_vcProjectModel(vcProjectModel)
{ {
@@ -319,7 +320,7 @@ bool VcDocProjectNode::addFiles(const ProjectExplorer::FileType fileType, const
if (vcContainerNode) { if (vcContainerNode) {
foreach (const QString &filePath, filePaths) { foreach (const QString &filePath, filePaths) {
QString relativeFilePath = m_vcProjectModel->fileRelativePath(filePath); QString relativeFilePath = fileRelativePath(m_vcProjectModel->filePath(), filePath);
// if file is already in the project don't add it // if file is already in the project don't add it
if (m_vcProjectModel->files()->fileExists(relativeFilePath)) if (m_vcProjectModel->files()->fileExists(relativeFilePath))
@@ -338,7 +339,7 @@ bool VcDocProjectNode::addFiles(const ProjectExplorer::FileType fileType, const
if (projectNode) { if (projectNode) {
foreach (const QString &filePath, filePaths) { foreach (const QString &filePath, filePaths) {
QString relativeFilePath = m_vcProjectModel->fileRelativePath(filePath); QString relativeFilePath = fileRelativePath(m_vcProjectModel->filePath(), filePath);
// if file is already in the project don't add it // if file is already in the project don't add it
if (m_vcProjectModel->files()->fileExists(relativeFilePath)) if (m_vcProjectModel->files()->fileExists(relativeFilePath))
@@ -368,7 +369,7 @@ bool VcDocProjectNode::removeFiles(const ProjectExplorer::FileType fileType, con
QStringList filesNotRemoved; QStringList filesNotRemoved;
foreach (const QString &filePath, filePaths) { foreach (const QString &filePath, filePaths) {
QString relativeFilePath = m_vcProjectModel->fileRelativePath(filePath); QString relativeFilePath = fileRelativePath(m_vcProjectModel->filePath(), filePath);
if (m_vcProjectModel->files()->fileExists(relativeFilePath)) { if (m_vcProjectModel->files()->fileExists(relativeFilePath)) {
VcFileNode *fileNode = static_cast<VcFileNode *>(findFileNode(filePath)); VcFileNode *fileNode = static_cast<VcFileNode *>(findFileNode(filePath));
@@ -568,5 +569,15 @@ VcFileNode *VcDocProjectNode::findFileNode(const QString &filePath)
return 0; return 0;
} }
QString fileRelativePath(const QString &fullProjectPath, const QString &fullFilePath)
{
QString relativePath = QFileInfo(fullProjectPath).absoluteDir().relativeFilePath(fullFilePath).replace(QLatin1String("/"), QLatin1String("\\"));
if (!relativePath.startsWith(QLatin1String("..")))
relativePath.prepend(QLatin1String(".\\"));
return relativePath;
}
} // namespace Internal } // namespace Internal
} // namespace VcProjectManager } // namespace VcProjectManager

View File

@@ -35,11 +35,13 @@
namespace VcProjectManager { namespace VcProjectManager {
namespace Internal { namespace Internal {
class VcProjectDocument; class IVisualStudioProject;
class IFileContainer; class IFileContainer;
class IFile; class IFile;
class VcDocProjectNode; class VcDocProjectNode;
QString fileRelativePath(const QString &fullProjectPath, const QString &fullFilePath);
class VcFileNode : public ProjectExplorer::FileNode class VcFileNode : public ProjectExplorer::FileNode
{ {
Q_OBJECT Q_OBJECT
@@ -102,7 +104,7 @@ class VcDocProjectNode : public ProjectExplorer::ProjectNode
friend class VcFileContainerNode; friend class VcFileContainerNode;
public: public:
VcDocProjectNode(VcProjectDocument* vcProjectModel); VcDocProjectNode(IVisualStudioProject* vcProjectModel);
~VcDocProjectNode(); ~VcDocProjectNode();
bool hasBuildTargets() const; bool hasBuildTargets() const;
@@ -135,7 +137,7 @@ public:
private: private:
VcFileNode* findFileNode(const QString &filePath); VcFileNode* findFileNode(const QString &filePath);
VcProjectDocument *m_vcProjectModel; IVisualStudioProject *m_vcProjectModel;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -50,9 +50,9 @@ VcDocumentModel::VcDocumentModel(const QString &filePath, VcDocConstants::Docume
if (!document.setContent(&file)) if (!document.setContent(&file))
return; return;
m_vcProjectDocument = VcProjectDocumentFactory::create(filePath, version); m_vcProjectDocument = new VcProjectDocument(filePath, version);
if (m_vcProjectDocument) if (m_vcProjectDocument)
m_vcProjectDocument->readFromXMLDomDocument(document); m_vcProjectDocument->processNode(document);
} }
VcDocumentModel::~VcDocumentModel() VcDocumentModel::~VcDocumentModel()
@@ -60,7 +60,7 @@ VcDocumentModel::~VcDocumentModel()
delete m_vcProjectDocument; delete m_vcProjectDocument;
} }
VcProjectDocument* VcDocumentModel::vcProjectDocument() const IVisualStudioProject* VcDocumentModel::vcProjectDocument() const
{ {
return m_vcProjectDocument; return m_vcProjectDocument;
} }

View File

@@ -40,7 +40,7 @@ class QDomDocument;
namespace VcProjectManager { namespace VcProjectManager {
namespace Internal { namespace Internal {
class VcProjectDocument; class IVisualStudioProject;
class VcDocumentModel class VcDocumentModel
{ {
@@ -48,11 +48,12 @@ public:
explicit VcDocumentModel(const QString &filePath, VcDocConstants::DocumentVersion version); explicit VcDocumentModel(const QString &filePath, VcDocConstants::DocumentVersion version);
virtual ~VcDocumentModel(); virtual ~VcDocumentModel();
VcProjectDocument* vcProjectDocument() const; IVisualStudioProject* vcProjectDocument() const;
bool saveToFile(const QString &filePath) const; bool saveToFile(const QString &filePath) const;
private: private:
VcProjectDocument *m_vcProjectDocument; IVisualStudioProject *m_vcProjectDocument;
QDomDocument *m_document;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -30,7 +30,6 @@
#include "vcprojectdocument.h" #include "vcprojectdocument.h"
#include <QDomElement> #include <QDomElement>
#include <QDir>
#include <QFile> #include <QFile>
#include <QStringList> #include <QStringList>
#include <QTextStream> #include <QTextStream>
@@ -43,6 +42,7 @@
#include "../widgets/configurationswidgets.h" #include "../widgets/configurationswidgets.h"
#include "configurationcontainer.h" #include "configurationcontainer.h"
#include "../interfaces/iattributecontainer.h" #include "../interfaces/iattributecontainer.h"
#include "generalattributecontainer.h"
namespace VcProjectManager { namespace VcProjectManager {
namespace Internal { namespace Internal {
@@ -51,18 +51,6 @@ VcProjectDocument::~VcProjectDocument()
{ {
} }
void VcProjectDocument::readFromXMLDomDocument(const QDomNode &domDoc)
{
QDomNode node = domDoc.firstChild(); // xml
parseProcessingInstruction(node.toProcessingInstruction());
node = node.nextSibling(); // Visual studio
processVisualStudioNode(node.toElement());
node = node.firstChild();
processNode(node);
}
bool VcProjectDocument::saveToFile(const QString &filePath) const bool VcProjectDocument::saveToFile(const QString &filePath) const
{ {
QDomDocument domDoc; QDomDocument domDoc;
@@ -90,138 +78,108 @@ QString VcProjectDocument::filePath() const
return m_filePath; return m_filePath;
} }
void VcProjectDocument::allProjectFiles(QStringList &sl) const IConfigurations* VcProjectDocument::configurations() const
{
for (int i = 0; i < m_files->fileContainerCount(); ++i) {
IFileContainer *fileContainer = m_files->fileContainer(i);
if (fileContainer)
fileContainer->allFiles(sl);
}
for (int i = 0; i < m_files->fileCount(); ++i) {
IFile *file = m_files->file(i);
if (file)
sl.append(file->canonicalPath());
}
}
QString VcProjectDocument::fileRelativePath(const QString &filePath)
{
QString relativePath = QFileInfo(m_filePath).absoluteDir().relativeFilePath(filePath).replace(QLatin1String("/"), QLatin1String("\\"));
if (!relativePath.startsWith(QLatin1String("..")))
relativePath.prepend(QLatin1String(".\\"));
return relativePath;
}
Configurations::Ptr VcProjectDocument::configurations() const
{ {
return m_configurations; return m_configurations;
} }
Platforms::Ptr VcProjectDocument::platforms() const IPlatforms* VcProjectDocument::platforms() const
{ {
return m_platforms; return m_platforms;
} }
Files::Ptr VcProjectDocument::files() const IReferences *VcProjectDocument::referencess() const
{
return m_files;
}
Globals::Ptr VcProjectDocument::globals() const
{
return m_globals;
}
References::Ptr VcProjectDocument::references() const
{ {
return m_references; return m_references;
} }
VcProjectDocument::VcProjectDocument(const QString &filePath) IToolFiles *VcProjectDocument::toolFiles() const
: IVcProjectXMLNode(), {
m_filePath(filePath), return m_toolFiles;
m_projectType(QLatin1String("Visual C++")), }
m_platforms(Platforms::Ptr(new Platforms)),
m_globals(Globals::Ptr(new Globals)) IPublishingData *VcProjectDocument::publishingData() const
{
return m_publishingData;
}
IAttributeContainer *VcProjectDocument::attributeContainer() const
{
return m_attributeContainer;
}
IFiles* VcProjectDocument::files() const
{
return m_files;
}
IGlobals* VcProjectDocument::globals() const
{
return m_globals;
}
VcProjectDocument::VcProjectDocument(const QString &filePath, VcDocConstants::DocumentVersion docVersion)
: m_filePath(filePath),
m_platforms(new Platforms),
m_globals(new Globals),
m_files(new Files(this)),
m_configurations(new Configurations(this)),
m_references(new References),
m_toolFiles(new ToolFiles),
m_publishingData(new PublishingData),
m_documentVersion(docVersion),
m_attributeContainer(new GeneralAttributeContainer)
{ {
} }
VcProjectDocument::VcProjectDocument(const VcProjectDocument &vcDoc) VcProjectDocument::VcProjectDocument(const VcProjectDocument &vcDoc)
{ {
m_documentVersion = vcDoc.m_documentVersion;
m_filePath = vcDoc.m_filePath;
m_projectType = vcDoc.m_projectType;
m_version = vcDoc.m_version;
m_projectGUID = vcDoc.m_projectGUID;
m_rootNamespace = vcDoc.m_rootNamespace;
m_keyword = vcDoc.m_keyword;
m_name = vcDoc.m_name;
m_anyAttribute = vcDoc.m_anyAttribute;
// <?xml part // <?xml part
m_processingInstructionData = vcDoc.m_processingInstructionData; m_processingInstructionData = vcDoc.m_processingInstructionData;
m_processingInstructionTarget = vcDoc.m_processingInstructionTarget; m_processingInstructionTarget = vcDoc.m_processingInstructionTarget;
m_platforms = Platforms::Ptr(new Platforms(*(vcDoc.m_platforms))); m_attributeContainer = new GeneralAttributeContainer(*vcDoc.m_attributeContainer);
m_configurations = Configurations::Ptr(new Configurations(*(vcDoc.m_configurations))); m_platforms = new Platforms(*(vcDoc.m_platforms));
m_files = Files::Ptr(new Files(*vcDoc.m_files)); m_configurations = new Configurations(*(vcDoc.m_configurations));
m_references = References::Ptr(new References(*(vcDoc.m_references))); m_files = new Files(*vcDoc.m_files);
m_globals = Globals::Ptr(new Globals(*(vcDoc.m_globals))); m_references = new References(*(vcDoc.m_references));
m_globals = new Globals(*(vcDoc.m_globals));
m_toolFiles = new ToolFiles(*(vcDoc.m_toolFiles));
m_publishingData = new PublishingData(*(vcDoc.m_publishingData));
} }
VcProjectDocument &VcProjectDocument::operator =(const VcProjectDocument &vcDoc) VcProjectDocument &VcProjectDocument::operator =(const VcProjectDocument &vcDoc)
{ {
if (this != &vcDoc) { if (this != &vcDoc) {
m_documentVersion = vcDoc.m_documentVersion; *m_attributeContainer = *vcDoc.m_attributeContainer;
m_filePath = vcDoc.m_filePath;
m_projectType = vcDoc.m_projectType;
m_version = vcDoc.m_version;
m_projectGUID = vcDoc.m_projectGUID;
m_rootNamespace = vcDoc.m_rootNamespace;
m_keyword = vcDoc.m_keyword;
m_name = vcDoc.m_name;
m_anyAttribute = vcDoc.m_anyAttribute;
// <?xml part // <?xml part
m_processingInstructionData = vcDoc.m_processingInstructionData; m_processingInstructionData = vcDoc.m_processingInstructionData;
m_processingInstructionTarget = vcDoc.m_processingInstructionTarget; m_processingInstructionTarget = vcDoc.m_processingInstructionTarget;
m_platforms = Platforms::Ptr(new Platforms(*(vcDoc.m_platforms))); *m_platforms = *vcDoc.m_platforms;
m_configurations = Configurations::Ptr(new Configurations(*(vcDoc.m_configurations))); *m_configurations = *vcDoc.m_configurations;
m_files = Files::Ptr(new Files(*vcDoc.m_files)); *m_files = *vcDoc.m_files;
m_references = References::Ptr(new References(*(vcDoc.m_references))); *m_references = *vcDoc.m_references;
m_globals = Globals::Ptr(new Globals(*(vcDoc.m_globals))); *m_globals = *vcDoc.m_globals;
*m_toolFiles = *vcDoc.m_toolFiles;
*m_publishingData = *vcDoc.m_publishingData;
} }
return *this; return *this;
} }
void VcProjectDocument::processNode(const QDomNode &node) void VcProjectDocument::processNode(const QDomNode &domDoc)
{ {
if (node.isNull()) QDomNode node = domDoc.firstChild(); // xml
return;
if (node.nodeName() == QLatin1String("Platforms")) parseProcessingInstruction(node.toProcessingInstruction());
m_platforms->processNode(node);
else if (node.nodeName() == QLatin1String("Configurations")) node = node.nextSibling(); // Visual studio
m_configurations->processNode(node); processDocumentAttributes(node.toElement());
node = node.firstChild();
else if (node.nodeName() == QLatin1String("References")) processDocumentNode(node);
m_references->processNode(node);
else if (node.nodeName() == QLatin1String("Files"))
m_files->processNode(node);
else if (node.nodeName() == QLatin1String("Globals"))
m_globals->processNode(node);
processNode(node.nextSibling());
} }
void VcProjectDocument::parseProcessingInstruction(const QDomProcessingInstruction &processingInstruction) void VcProjectDocument::parseProcessingInstruction(const QDomProcessingInstruction &processingInstruction)
@@ -240,7 +198,7 @@ void VcProjectDocument::parseProcessingInstruction(const QDomProcessingInstructi
m_processingInstructionTarget = processingInstruction.target(); m_processingInstructionTarget = processingInstruction.target();
} }
void VcProjectDocument::processVisualStudioNode(const QDomElement &vsNode) void VcProjectDocument::processDocumentAttributes(const QDomElement &vsNode)
{ {
QDomNamedNodeMap namedNodeMap = vsNode.attributes(); QDomNamedNodeMap namedNodeMap = vsNode.attributes();
@@ -249,27 +207,7 @@ void VcProjectDocument::processVisualStudioNode(const QDomElement &vsNode)
if (domNode.nodeType() == QDomNode::AttributeNode) { if (domNode.nodeType() == QDomNode::AttributeNode) {
QDomAttr domElement = domNode.toAttr(); QDomAttr domElement = domNode.toAttr();
m_attributeContainer->setAttribute(domElement.name(), domElement.value());
if (domElement.name() == QLatin1String("ProjectType"))
m_projectType = domElement.value();
else if (domElement.name() == QLatin1String("Version"))
m_version = domElement.value();
else if (domElement.name() == QLatin1String("ProjectGUID"))
m_projectGUID = domElement.value();
else if (domElement.name() == QLatin1String("RootNamespace"))
m_rootNamespace = domElement.value();
else if (domElement.name() == QLatin1String("Keyword"))
m_keyword = domElement.value();
else if (domElement.name() == QLatin1String("Name"))
m_name = domElement.value();
else
m_anyAttribute.insert(domElement.name(), domElement.value());
} }
} }
} }
@@ -298,30 +236,7 @@ QDomElement VcProjectDocument::toVcDocumentElement(QDomDocument &domXMLDocument)
{ {
QDomElement vcDocNode = domXMLDocument.createElement(QLatin1String("VisualStudioProject")); QDomElement vcDocNode = domXMLDocument.createElement(QLatin1String("VisualStudioProject"));
if (!m_name.isEmpty()) m_attributeContainer->appendToXMLNode(vcDocNode);
vcDocNode.setAttribute(QLatin1String("Name"), m_name);
if (!m_projectType.isEmpty())
vcDocNode.setAttribute(QLatin1String("ProjectType"), m_projectType);
if (!m_version.isEmpty())
vcDocNode.setAttribute(QLatin1String("Version"), m_version);
if (!m_projectGUID.isEmpty())
vcDocNode.setAttribute(QLatin1String("ProjectGUID"), m_projectGUID);
if (!m_rootNamespace.isEmpty())
vcDocNode.setAttribute(QLatin1String("RootNamespace"), m_rootNamespace);
if (!m_keyword.isEmpty())
vcDocNode.setAttribute(QLatin1String("Keyword"), m_keyword);
QHashIterator<QString, QString> itAttr(m_anyAttribute);
while (itAttr.hasNext()) {
itAttr.next();
vcDocNode.setAttribute(itAttr.key(), itAttr.value());
}
if (m_platforms->platformCount()) if (m_platforms->platformCount())
vcDocNode.appendChild(m_platforms->toXMLDomNode(domXMLDocument)); vcDocNode.appendChild(m_platforms->toXMLDomNode(domXMLDocument));
@@ -338,51 +253,47 @@ QDomElement VcProjectDocument::toVcDocumentElement(QDomDocument &domXMLDocument)
if (m_globals->globalCount()) if (m_globals->globalCount())
vcDocNode.appendChild(m_globals->toXMLDomNode(domXMLDocument)); vcDocNode.appendChild(m_globals->toXMLDomNode(domXMLDocument));
if (m_toolFiles->toolFileCount())
vcDocNode.appendChild(m_toolFiles->toXMLDomNode(domXMLDocument));
if (m_publishingData->publishingItemCount() && m_publishingData->attributeContainer()->getAttributeCount())
vcDocNode.appendChild(m_publishingData->toXMLDomNode(domXMLDocument));
return vcDocNode; return vcDocNode;
} }
VcNodeWidget *VcProjectDocument::createSettingsWidget()
VcProjectDocument2003::VcProjectDocument2003(const VcProjectDocument2003 &vcDoc)
: VcProjectDocument(vcDoc)
{ {
return new VcProjectDocumentWidget(this);
} }
VcProjectDocument2003 &VcProjectDocument2003::operator =(const VcProjectDocument2003 &vcDoc) void VcProjectDocument::processDocumentNode(const QDomNode &node)
{ {
VcProjectDocument::operator =(vcDoc); if (node.isNull())
return *this; return;
}
VcProjectDocument2003::~VcProjectDocument2003() if (node.nodeName() == QLatin1String("Platforms"))
{ m_platforms->processNode(node);
}
VcNodeWidget *VcProjectDocument2003::createSettingsWidget() else if (node.nodeName() == QLatin1String("Configurations"))
{ m_configurations->processNode(node);
return new VcProjectDocument2003Widget(this);
}
MsBuildInformation::MsBuildVersion VcProjectDocument2003::minSupportedMsBuildVersion() const else if (node.nodeName() == QLatin1String("References"))
{ m_references->processNode(node);
return MsBuildInformation::MSBUILD_V_2_0;
}
MsBuildInformation::MsBuildVersion VcProjectDocument2003::maxSupportedMsBuildVersion() const else if (node.nodeName() == QLatin1String("Files"))
{ m_files->processNode(node);
return MsBuildInformation::MSBUILD_V_3_5;
}
VcProjectDocument2003::VcProjectDocument2003(const QString &filePath) else if (node.nodeName() == QLatin1String("Globals"))
: VcProjectDocument(filePath) m_globals->processNode(node);
{
}
void VcProjectDocument2003::init() else if (node.nodeName() == QLatin1String("ToolFiles"))
{ m_toolFiles->processNode(node);
m_documentVersion = VcDocConstants::DV_MSVC_2003;
m_files = Files::Ptr(new Files(this)); else if (node.nodeName() == QLatin1String("PublishingData"))
m_configurations = Configurations::Ptr(new Configurations(this)); m_publishingData->processNode(node);
m_references = References::Ptr(new References);
processDocumentNode(node.nextSibling());
} }
@@ -426,367 +337,5 @@ void VcProjectDocumentWidget::onCancelButtonClicked()
deleteLater(); deleteLater();
} }
VcProjectDocument2003Widget::VcProjectDocument2003Widget(VcProjectDocument2003 *vcDoc)
: VcProjectDocumentWidget(vcDoc)
{
}
VcProjectDocument2003Widget::~VcProjectDocument2003Widget()
{
}
VcProjectDocument2005::VcProjectDocument2005(const VcProjectDocument2005 &vcDoc)
: VcProjectDocument2003(vcDoc)
{
m_toolFiles = ToolFiles::Ptr(new ToolFiles(*(vcDoc.m_toolFiles)));
}
VcProjectDocument2005 &VcProjectDocument2005::operator =(const VcProjectDocument2005 &vcDoc)
{
if (this != &vcDoc) {
VcProjectDocument2003::operator =(vcDoc);
m_toolFiles = ToolFiles::Ptr(new ToolFiles(*(vcDoc.m_toolFiles)));
}
return *this;
}
VcProjectDocument2005::~VcProjectDocument2005()
{
}
VcNodeWidget *VcProjectDocument2005::createSettingsWidget()
{
return new VcProjectDocument2005Widget(this);
}
MsBuildInformation::MsBuildVersion VcProjectDocument2005::minSupportedMsBuildVersion() const
{
return MsBuildInformation::MSBUILD_V_3_0;
}
MsBuildInformation::MsBuildVersion VcProjectDocument2005::maxSupportedMsBuildVersion() const
{
return MsBuildInformation::MSBUILD_V_3_5;
}
ToolFiles::Ptr VcProjectDocument2005::toolFiles() const
{
return m_toolFiles;
}
VcProjectDocument2005::VcProjectDocument2005(const QString &filePath)
: VcProjectDocument2003(filePath),
m_toolFiles(ToolFiles::Ptr(new ToolFiles))
{
}
void VcProjectDocument2005::init()
{
m_documentVersion = VcDocConstants::DV_MSVC_2005;
m_files = Files::Ptr(new Files(this));
m_configurations = Configurations::Ptr(new Configurations(this));
m_references = References::Ptr(new References);
}
void VcProjectDocument2005::processNode(const QDomNode &node)
{
if (node.isNull())
return;
if (node.nodeName() == QLatin1String("Platforms"))
m_platforms->processNode(node);
else if (node.nodeName() == QLatin1String("Configurations"))
m_configurations->processNode(node);
else if (node.nodeName() == QLatin1String("References"))
m_references->processNode(node);
else if (node.nodeName() == QLatin1String("Files"))
m_files->processNode(node);
else if (node.nodeName() == QLatin1String("Globals"))
m_globals->processNode(node);
else if (node.nodeName() == QLatin1String("ToolFiles"))
m_toolFiles->processNode(node);
processNode(node.nextSibling());
}
QDomElement VcProjectDocument2005::toVcDocumentElement(QDomDocument &domXMLDocument) const
{
QDomElement vcDocNode = VcProjectDocument2003::toVcDocumentElement(domXMLDocument);
if (m_toolFiles->toolFileCount())
vcDocNode.appendChild(m_toolFiles->toXMLDomNode(domXMLDocument));
return vcDocNode;
}
VcProjectDocument2005Widget::VcProjectDocument2005Widget(VcProjectDocument2005 *vcDoc)
: VcProjectDocumentWidget(vcDoc)
{
}
VcProjectDocument2005Widget::~VcProjectDocument2005Widget()
{
}
VcProjectDocument2008::VcProjectDocument2008(const VcProjectDocument2008 &vcDoc)
: VcProjectDocument2005(vcDoc)
{
m_publishingData = PublishingData::Ptr(new PublishingData(*(vcDoc.m_publishingData)));
m_assemblyReferenceSearchPaths = vcDoc.m_assemblyReferenceSearchPaths;
m_manifestKeyFile = vcDoc.m_manifestKeyFile;
m_manifestCertificateThumbprint = vcDoc.m_manifestCertificateThumbprint;
m_manifestTimestampURL = vcDoc.m_manifestTimestampURL;
m_signManifests = vcDoc.m_signManifests;
m_signAssembly = vcDoc.m_signAssembly;
m_assemblyOriginatorKeyFile = vcDoc.m_assemblyOriginatorKeyFile;
m_delaySign = vcDoc.m_delaySign;
m_generateManifests = vcDoc.m_generateManifests;
m_targetZone = vcDoc.m_targetZone;
m_excludedPermissions = vcDoc.m_excludedPermissions;
m_targetFrameworkVersion = vcDoc.m_targetFrameworkVersion;
}
VcProjectDocument2008 &VcProjectDocument2008::operator=(const VcProjectDocument2008 &vcDoc)
{
if (this != &vcDoc) {
VcProjectDocument2005::operator =(vcDoc);
m_publishingData = PublishingData::Ptr(new PublishingData(*(vcDoc.m_publishingData)));
m_assemblyReferenceSearchPaths = vcDoc.m_assemblyReferenceSearchPaths;
m_manifestKeyFile = vcDoc.m_manifestKeyFile;
m_manifestCertificateThumbprint = vcDoc.m_manifestCertificateThumbprint;
m_manifestTimestampURL = vcDoc.m_manifestTimestampURL;
m_signManifests = vcDoc.m_signManifests;
m_signAssembly = vcDoc.m_signAssembly;
m_assemblyOriginatorKeyFile = vcDoc.m_assemblyOriginatorKeyFile;
m_delaySign = vcDoc.m_delaySign;
m_generateManifests = vcDoc.m_generateManifests;
m_targetZone = vcDoc.m_targetZone;
m_excludedPermissions = vcDoc.m_excludedPermissions;
m_targetFrameworkVersion = vcDoc.m_targetFrameworkVersion;
}
return *this;
}
VcProjectDocument2008::~VcProjectDocument2008()
{
}
VcNodeWidget *VcProjectDocument2008::createSettingsWidget()
{
return new VcProjectDocument2008Widget(this);
}
MsBuildInformation::MsBuildVersion VcProjectDocument2008::minSupportedMsBuildVersion() const
{
return MsBuildInformation::MSBUILD_V_3_5;
}
MsBuildInformation::MsBuildVersion VcProjectDocument2008::maxSupportedMsBuildVersion() const
{
return MsBuildInformation::MSBUILD_V_3_5;
}
PublishingData::Ptr VcProjectDocument2008::publishingData() const
{
return m_publishingData;
}
VcProjectDocument2008::VcProjectDocument2008(const QString &filePath)
: VcProjectDocument2005(filePath),
m_publishingData(PublishingData::Ptr(new PublishingData))
{
}
void VcProjectDocument2008::init()
{
m_documentVersion = VcDocConstants::DV_MSVC_2008;
m_files = Files::Ptr(new Files(this));
m_configurations = Configurations::Ptr(new Configurations(this));
m_references = References::Ptr(new References);
}
void VcProjectDocument2008::processNode(const QDomNode &node)
{
if (node.isNull())
return;
if (node.nodeName() == QLatin1String("Platforms"))
m_platforms->processNode(node);
else if (node.nodeName() == QLatin1String("Configurations"))
m_configurations->processNode(node);
else if (node.nodeName() == QLatin1String("References"))
m_references->processNode(node);
else if (node.nodeName() == QLatin1String("Files"))
m_files->processNode(node);
else if (node.nodeName() == QLatin1String("Globals"))
m_globals->processNode(node);
else if (node.nodeName() == QLatin1String("ToolFiles"))
m_toolFiles->processNode(node);
else if (node.nodeName() == QLatin1String("PublishingData"))
m_publishingData->processNode(node);
processNode(node.nextSibling());
}
void VcProjectDocument2008::processVisualStudioNode(const QDomElement &vsNode)
{
VcProjectDocument2005::processVisualStudioNode(vsNode);
QDomNamedNodeMap namedNodeMap = vsNode.attributes();
for (int i = 0; i < namedNodeMap.count(); ++i) {
QDomNode domNode = namedNodeMap.item(i);
if (domNode.nodeType() == QDomNode::AttributeNode) {
QDomAttr domElement = domNode.toAttr();
if (domElement.name() == QLatin1String("AssemblyReferenceSearchPaths"))
m_assemblyReferenceSearchPaths = domElement.value();
else if (domElement.name() == QLatin1String("ManifestKeyFile"))
m_manifestKeyFile = domElement.value();
else if (domElement.name() == QLatin1String("ManifestCertificateThumbprint"))
m_manifestCertificateThumbprint = domElement.value();
else if (domElement.name() == QLatin1String("ManifestTimestampURL"))
m_manifestTimestampURL = domElement.value();
else if (domElement.name() == QLatin1String("SignManifests")) {
if (domElement.value() == QLatin1String("false"))
m_signManifests = false;
else
m_signManifests = true;
}
else if (domElement.name() == QLatin1String("SignAssembly")) {
if (domElement.value() == QLatin1String("false"))
m_signAssembly = false;
else
m_signAssembly = true;
}
else if (domElement.name() == QLatin1String("AssemblyOriginatorKeyFile"))
m_assemblyOriginatorKeyFile = domElement.value();
else if (domElement.name() == QLatin1String("DelaySign")) {
if (domElement.value() == QLatin1String("false"))
m_delaySign = false;
else
m_delaySign = true;
}
else if (domElement.name() == QLatin1String("DelaySign")) {
if (domElement.value() == QLatin1String("GenerateManifests"))
m_generateManifests = false;
else
m_generateManifests = true;
}
else if (domElement.name() == QLatin1String("TargetZone"))
m_targetZone = domElement.value();
else if (domElement.name() == QLatin1String("ExcludedPermissions"))
m_excludedPermissions = domElement.value();
else if (domElement.name() == QLatin1String("TargetFrameworkVersion"))
m_targetFrameworkVersion = domElement.value();
}
}
}
QDomElement VcProjectDocument2008::toVcDocumentElement(QDomDocument &domXMLDocument) const
{
QDomElement vcDocNode = VcProjectDocument2005::toVcDocumentElement(domXMLDocument);
if (!m_assemblyReferenceSearchPaths.isEmpty())
vcDocNode.setAttribute(QLatin1String("AssemblyReferenceSearchPaths"), m_assemblyReferenceSearchPaths);
if (!m_manifestKeyFile.isEmpty())
vcDocNode.setAttribute(QLatin1String("ManifestKeyFile"), m_manifestKeyFile);
if (!m_manifestCertificateThumbprint.isEmpty())
vcDocNode.setAttribute(QLatin1String("ManifestCertificateThumbprint"), m_manifestCertificateThumbprint);
if (!m_manifestTimestampURL.isEmpty())
vcDocNode.setAttribute(QLatin1String("ManifestTimestampURL"), m_manifestTimestampURL);
vcDocNode.setAttribute(QLatin1String("SignManifests"), QVariant(m_signManifests).toString());
vcDocNode.setAttribute(QLatin1String("SignAssembly"), QVariant(m_signAssembly).toString());
if (!m_assemblyOriginatorKeyFile.isEmpty())
vcDocNode.setAttribute(QLatin1String("AssemblyOriginatorKeyFile"), m_assemblyOriginatorKeyFile);
vcDocNode.setAttribute(QLatin1String("DelaySign"), QVariant(m_delaySign).toString());
vcDocNode.setAttribute(QLatin1String("GenerateManifests"), QVariant(m_generateManifests).toString());
if (!m_targetZone.isEmpty())
vcDocNode.setAttribute(QLatin1String("TargetZone"), m_targetZone);
if (!m_excludedPermissions.isEmpty())
vcDocNode.setAttribute(QLatin1String("ExcludedPermissions"), m_excludedPermissions);
if (!m_targetFrameworkVersion.isEmpty())
vcDocNode.setAttribute(QLatin1String("TargetFrameworkVersion"), m_targetFrameworkVersion);
if (m_publishingData->publishingItemCount() && m_publishingData->attributeContainer()->getAttributeCount())
vcDocNode.appendChild(m_publishingData->toXMLDomNode(domXMLDocument));
return vcDocNode;
}
VcProjectDocument2008Widget::VcProjectDocument2008Widget(VcProjectDocument2008 *vcDoc)
: VcProjectDocumentWidget(vcDoc)
{
}
VcProjectDocument2008Widget::~VcProjectDocument2008Widget()
{
}
VcProjectDocument *VcProjectDocumentFactory::create(const QString &filePath, VcDocConstants::DocumentVersion version)
{
VcProjectDocument *vcDoc = 0;
switch (version) {
case VcDocConstants::DV_MSVC_2003:
vcDoc = new VcProjectDocument2003(filePath);
break;
case VcDocConstants::DV_MSVC_2005:
vcDoc = new VcProjectDocument2005(filePath);
break;
case VcDocConstants::DV_MSVC_2008:
vcDoc = new VcProjectDocument2008(filePath);
break;
case VcDocConstants::DV_UNRECOGNIZED:
return 0;
}
if (vcDoc)
vcDoc->init();
return vcDoc;
}
} // namespace Internal } // namespace Internal
} // namespace VcProjectManager } // namespace VcProjectManager

View File

@@ -31,7 +31,7 @@
#ifndef VCPROJECTMANAGER_INTERNAL_VCPROJECTDOCUMENT_H #ifndef VCPROJECTMANAGER_INTERNAL_VCPROJECTDOCUMENT_H
#define VCPROJECTMANAGER_INTERNAL_VCPROJECTDOCUMENT_H #define VCPROJECTMANAGER_INTERNAL_VCPROJECTDOCUMENT_H
#include "ivcprojectnodemodel.h" #include "../interfaces/ivisualstudioproject.h"
#include "configurations.h" #include "configurations.h"
#include "files.h" #include "files.h"
@@ -48,103 +48,56 @@ namespace Internal {
class ConfigurationsBaseWidget; class ConfigurationsBaseWidget;
class VcProjectDocument : public IVcProjectXMLNode class VcProjectDocument : public IVisualStudioProject
{ {
friend class VcProjectDocumentFactory; friend class VcProjectDocumentFactory;
public: public:
VcProjectDocument(const QString &filePath, VcDocConstants::DocumentVersion docVersion);
VcProjectDocument(const VcProjectDocument &vcDoc);
VcProjectDocument& operator=(const VcProjectDocument &vcDoc);
virtual ~VcProjectDocument(); virtual ~VcProjectDocument();
void processNode(const QDomNode &domDoc);
void readFromXMLDomDocument(const QDomNode &domDoc);
bool saveToFile(const QString &filePath) const; bool saveToFile(const QString &filePath) const;
VcDocConstants::DocumentVersion documentVersion() const; VcDocConstants::DocumentVersion documentVersion() const;
QString filePath() const; QString filePath() const;
void allProjectFiles(QStringList &sl) const;
/*! IConfigurations *configurations() const;
* Implementation should return a minimal version of MS Build tool that is required to build a project. IFiles *files() const;
* For example VS 2008 project can be compiled with MS Build 3.0 and 3.5. IGlobals *globals() const;
* So the minimal MS Build version for VS 2008 projects is 3.0 IPlatforms *platforms() const;
* \return A minimal supported Ms Build version that is required to compile a project. IReferences *referencess() const;
*/ IToolFiles *toolFiles() const;
virtual MsBuildInformation::MsBuildVersion minSupportedMsBuildVersion() const = 0; IPublishingData *publishingData() const;
IAttributeContainer* attributeContainer() const;
/*! VcNodeWidget *createSettingsWidget();
* Implementation should return a max version of MS Build tool that can be used to build a project.
* For example VS 2008 project can be compiled with MS Build 3.0 and 3.5.
* So the maximum MS Build version for VS 2008 projects is 3.5
* \return
*/
virtual MsBuildInformation::MsBuildVersion maxSupportedMsBuildVersion() const = 0;
// helper function, used to create a relative path to a file, path is relative to a project's file path
QString fileRelativePath(const QString &filePath);
Configurations::Ptr configurations() const;
Platforms::Ptr platforms() const;
Files::Ptr files() const;
Globals::Ptr globals() const;
References::Ptr references() const;
protected: protected:
VcProjectDocument(const QString &filePath); void processDocumentNode(const QDomNode &node);
VcProjectDocument(const VcProjectDocument &vcDoc); void processDocumentAttributes(const QDomElement &vsNode);
VcProjectDocument& operator=(const VcProjectDocument &vcDoc);
void processNode(const QDomNode &node);
virtual void processVisualStudioNode(const QDomElement &vsNode);
QDomNode toXMLDomNode(QDomDocument &domXMLDocument) const; QDomNode toXMLDomNode(QDomDocument &domXMLDocument) const;
virtual QDomElement toVcDocumentElement(QDomDocument &domXMLDocument) const; QDomElement toVcDocumentElement(QDomDocument &domXMLDocument) const;
/*!
* Called to initialize VcProjectDocument after instance is created.
* This is the place in which objects that represent Configurations, References, Globals etc. should be created.
*/
virtual void init() = 0;
void parseProcessingInstruction(const QDomProcessingInstruction &processingInstruction); void parseProcessingInstruction(const QDomProcessingInstruction &processingInstruction);
QString m_filePath; QString m_filePath; // used to store path to a file
QString m_projectType; // optional
QString m_version; // optional
QString m_projectGUID; // optional
QString m_rootNamespace; // optional
QString m_keyword; // optional
QString m_name; // optional
QHash<QString, QString> m_anyAttribute;
// <?xml part // <?xml part
QHash<QString, QString> m_processingInstructionData; QHash<QString, QString> m_processingInstructionData;
QString m_processingInstructionTarget; QString m_processingInstructionTarget;
VcDocConstants::DocumentVersion m_documentVersion; VcDocConstants::DocumentVersion m_documentVersion;
Platforms::Ptr m_platforms; Platforms *m_platforms;
Configurations::Ptr m_configurations; Configurations *m_configurations;
Files::Ptr m_files; Files *m_files;
References::Ptr m_references; References *m_references;
Globals::Ptr m_globals; Globals *m_globals;
ToolFiles *m_toolFiles;
PublishingData *m_publishingData;
GeneralAttributeContainer* m_attributeContainer;
}; };
class VcProjectDocument2003 : public VcProjectDocument
{
friend class VcProjectDocumentFactory;
public:
VcProjectDocument2003(const VcProjectDocument2003 &vcDoc);
VcProjectDocument2003& operator=(const VcProjectDocument2003 &vcDoc);
~VcProjectDocument2003();
VcNodeWidget* createSettingsWidget();
MsBuildInformation::MsBuildVersion minSupportedMsBuildVersion() const;
MsBuildInformation::MsBuildVersion maxSupportedMsBuildVersion() const;
protected:
VcProjectDocument2003(const QString &filePath);
void init();
};
class VcProjectDocumentWidget : public VcNodeWidget class VcProjectDocumentWidget : public VcNodeWidget
{ {
Q_OBJECT Q_OBJECT
@@ -166,103 +119,6 @@ protected:
ConfigurationsBaseWidget *m_configurationsWidget; ConfigurationsBaseWidget *m_configurationsWidget;
}; };
class VcProjectDocument2003Widget : public VcProjectDocumentWidget
{
Q_OBJECT
public:
explicit VcProjectDocument2003Widget(VcProjectDocument2003 *vcDoc);
~VcProjectDocument2003Widget();
};
class VcProjectDocument2005 : public VcProjectDocument2003
{
friend class VcProjectDocumentFactory;
public:
VcProjectDocument2005(const VcProjectDocument2005 &vcDoc);
VcProjectDocument2005& operator=(const VcProjectDocument2005 &vcDoc);
~VcProjectDocument2005();
VcNodeWidget* createSettingsWidget();
MsBuildInformation::MsBuildVersion minSupportedMsBuildVersion() const;
MsBuildInformation::MsBuildVersion maxSupportedMsBuildVersion() const;
ToolFiles::Ptr toolFiles() const;
protected:
VcProjectDocument2005(const QString &filePath);
void init();
void processNode(const QDomNode &node);
QDomElement toVcDocumentElement(QDomDocument &domXMLDocument) const;
ToolFiles::Ptr m_toolFiles;
};
class VcProjectDocument2005Widget : public VcProjectDocumentWidget
{
Q_OBJECT
public:
explicit VcProjectDocument2005Widget(VcProjectDocument2005 *vcDoc);
~VcProjectDocument2005Widget();
};
class VcProjectDocument2008 : public VcProjectDocument2005
{
friend class VcProjectDocumentFactory;
public:
VcProjectDocument2008(const VcProjectDocument2008 &vcDoc);
VcProjectDocument2008& operator=(const VcProjectDocument2008 &vcDoc);
~VcProjectDocument2008();
VcNodeWidget* createSettingsWidget();
MsBuildInformation::MsBuildVersion minSupportedMsBuildVersion() const;
MsBuildInformation::MsBuildVersion maxSupportedMsBuildVersion() const;
PublishingData::Ptr publishingData() const;
protected:
VcProjectDocument2008(const QString &filePath);
void init();
void processNode(const QDomNode &node);
void processVisualStudioNode(const QDomElement &vsNode);
QDomElement toVcDocumentElement(QDomDocument &domXMLDocument) const;
private:
PublishingData::Ptr m_publishingData;
QString m_assemblyReferenceSearchPaths;
QString m_manifestKeyFile;
QString m_manifestCertificateThumbprint;
QString m_manifestTimestampURL;
bool m_signManifests;
bool m_signAssembly;
QString m_assemblyOriginatorKeyFile;
bool m_delaySign;
bool m_generateManifests;
QString m_targetZone;
QString m_excludedPermissions;
QString m_targetFrameworkVersion;
};
class VcProjectDocument2008Widget : public VcProjectDocumentWidget
{
Q_OBJECT
public:
explicit VcProjectDocument2008Widget(VcProjectDocument2008 *vcDoc);
~VcProjectDocument2008Widget();
};
class VcProjectDocumentFactory
{
public:
static VcProjectDocument* create(const QString &filePath, VcDocConstants::DocumentVersion version);
};
} // namespace Internal } // namespace Internal
} // namespace VcProjectManager } // namespace VcProjectManager

View File

@@ -84,6 +84,26 @@ const char TOOL_FILE_RELATIVE_PATH [] = "RelativePath";
const char DEFAULT_TOOL_FILE [] = "DefaultToolFile"; const char DEFAULT_TOOL_FILE [] = "DefaultToolFile";
const char DEFAULT_TOOL_FILE_FILE_NAME [] = "FileName"; const char DEFAULT_TOOL_FILE_FILE_NAME [] = "FileName";
// Vs Project Constants
const char VS_PROJECT_PROJECT_TYPE [] = "ProjectType";
const char VS_PROJECT_VERSION [] = "Version";
const char VS_PROJECT_PROJECT_GUID [] = "ProjectGUID";
const char VS_PROJECT_ROOT_NAMESPACE [] = "RootNamespace";
const char VS_PROJECT_KEYWORD [] = "Keyword";
const char VS_PROJECT_NAME [] = "Name";
const char VS_PROJECT_ASSEMBLY_REFERENCE_SEARCH_PATH [] = "AssemblyReferenceSearchPaths";
const char VS_PROJECT_MANIFEST_KEY_FILE [] = "ManifestKeyFile";
const char VS_PROJECT_MANIFEST_CERTIFICATE_THUMBPRINT [] = "ManifestCertificateThumbprint";
const char VS_PROJECT_MANIFEST_TIMESTAMP_URL [] = "ManifestTimestampURL";
const char VS_PROJECT_SIGN_MANIFEST [] = "SignManifests";
const char VS_PROJECT_SIGN_ASSEMBLY [] = "SignAssembly";
const char VS_PROJECT_ASSEMBLY_ORIGINATOR_KEY_FILE [] = "AssemblyOriginatorKeyFile";
const char VS_PROJECT_DELAY_SIGN [] = "DelaySign";
const char VS_PROJECT_GENERATE_MANIFESTS [] = "GenerateManifests";
const char VS_PROJECT_TARGET_ZONE [] = "TargetZone";
const char VS_PROJECT_EXCLUDED_PERMISSIONS [] = "ExcludedPermissions";
const char VS_PROJECT_TARGET_FRAMEWORK_VERSION [] = "TargetFrameworkVersion";
} // VcDocConstants } // VcDocConstants
} // namespace Internal } // namespace Internal
} // namespace VcProjectManager } // namespace VcProjectManager

View File

@@ -117,7 +117,7 @@ void ConfigurationsBaseWidget::saveData()
void ConfigurationsBaseWidget::onAddNewConfig(QString newConfigName, QString copyFrom) void ConfigurationsBaseWidget::onAddNewConfig(QString newConfigName, QString copyFrom)
{ {
Platforms::Ptr platforms = m_vcProjDoc->platforms(); IPlatforms *platforms = m_vcProjDoc->platforms();
if (platforms && !newConfigName.isEmpty()) { if (platforms && !newConfigName.isEmpty()) {
if (copyFrom.isEmpty()) { if (copyFrom.isEmpty()) {
@@ -156,7 +156,7 @@ void ConfigurationsBaseWidget::onAddNewConfig(QString newConfigName, QString cop
void ConfigurationsBaseWidget::onRenameConfig(QString newConfigName, QString oldConfigNameWithPlatform) void ConfigurationsBaseWidget::onRenameConfig(QString newConfigName, QString oldConfigNameWithPlatform)
{ {
Platforms::Ptr platforms = m_vcProjDoc->platforms(); IPlatforms *platforms = m_vcProjDoc->platforms();
if (!platforms || newConfigName.isEmpty() || oldConfigNameWithPlatform.isEmpty()) if (!platforms || newConfigName.isEmpty() || oldConfigNameWithPlatform.isEmpty())
return; return;
@@ -207,7 +207,7 @@ void ConfigurationsBaseWidget::onRenameConfig(QString newConfigName, QString old
void ConfigurationsBaseWidget::onRemoveConfig(QString configNameWithPlatform) void ConfigurationsBaseWidget::onRemoveConfig(QString configNameWithPlatform)
{ {
Platforms::Ptr platforms = m_vcProjDoc->platforms(); IPlatforms *platforms = m_vcProjDoc->platforms();
if (!platforms || configNameWithPlatform.isEmpty()) if (!platforms || configNameWithPlatform.isEmpty())
return; return;
@@ -286,7 +286,7 @@ IConfiguration *ConfigurationsBaseWidget::configInNewConfigurations(const QStrin
void ConfigurationsBaseWidget::addConfigurationToFiles(const QString &copyFromConfig, const QString &targetConfigName) void ConfigurationsBaseWidget::addConfigurationToFiles(const QString &copyFromConfig, const QString &targetConfigName)
{ {
Files::Ptr docFiles = m_vcProjDoc->files(); IFiles *docFiles = m_vcProjDoc->files();
if (docFiles) { if (docFiles) {
for (int i = 0; i < docFiles->fileContainerCount(); ++i) { for (int i = 0; i < docFiles->fileContainerCount(); ++i) {