diff options
author | Radovan Zivkovic <pivonroll@gmail.com> | 2013-10-10 23:44:11 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2014-03-11 19:54:59 +0100 |
commit | 42e7e7fef9c799096160bddb2f745a7f1c82751d (patch) | |
tree | 24d14d81f170510a3a29d9f290d2b54ff9621339 | |
parent | b776d61752633d6423d9797ad92a18b65eeaad53 (diff) | |
download | qt-creator-42e7e7fef9c799096160bddb2f745a7f1c82751d.tar.gz |
ToolFile implements IToolFile interface.
Change-Id: I82a0aefa9c9f3b5cfe1ad9925b0430b9ef62063f
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
7 files changed, 90 insertions, 19 deletions
diff --git a/src/plugins/vcprojectmanager/interfaces/interfaces.pri b/src/plugins/vcprojectmanager/interfaces/interfaces.pri index f9e5d052cb..b29fba59b4 100644 --- a/src/plugins/vcprojectmanager/interfaces/interfaces.pri +++ b/src/plugins/vcprojectmanager/interfaces/interfaces.pri @@ -22,4 +22,5 @@ HEADERS += \ interfaces/idebuggertools.h \ interfaces/iglobal.h \ interfaces/iglobals.h \ - interfaces/ireferences.h + interfaces/ireferences.h \ + interfaces/itoolfile.h diff --git a/src/plugins/vcprojectmanager/interfaces/itoolfile.h b/src/plugins/vcprojectmanager/interfaces/itoolfile.h new file mode 100644 index 0000000000..82c5505887 --- /dev/null +++ b/src/plugins/vcprojectmanager/interfaces/itoolfile.h @@ -0,0 +1,52 @@ +/************************************************************************** +** +** 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_ITOOLFILE_H +#define VCPROJECTMANAGER_INTERNAL_ITOOLFILE_H + +#include <QString> +#include "../vcprojectmodel/ivcprojectnodemodel.h" + +namespace VcProjectManager { +namespace Internal { + +class IAttributeContainer; + +class IToolFile : public IVcProjectXMLNode +{ +public: + virtual ~IToolFile() {} + virtual QString type() const = 0; + virtual IToolFile* clone() const = 0; + virtual IAttributeContainer* attributeContainer() const = 0; +}; + +} // Internal +} // VcProjectManager +#endif // VCPROJECTMANAGER_INTERNAL_ITOOLFILE_H diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/projectreference.h b/src/plugins/vcprojectmanager/vcprojectmodel/projectreference.h index 8e985007c6..5db2cf513f 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/projectreference.h +++ b/src/plugins/vcprojectmanager/vcprojectmodel/projectreference.h @@ -42,8 +42,6 @@ class GeneralAttributeContainer; class ProjectReference : public IReference { public: - typedef QSharedPointer<ProjectReference> Ptr; - ProjectReference(); ProjectReference(const ProjectReference &projRef); ProjectReference& operator=(const ProjectReference &projRef); diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/toolfile.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/toolfile.cpp index 5e282d241b..07d590a8b2 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/toolfile.cpp +++ b/src/plugins/vcprojectmanager/vcprojectmodel/toolfile.cpp @@ -28,28 +28,33 @@ ** ****************************************************************************/ #include "toolfile.h" +#include "generalattributecontainer.h" +#include "vcprojectdocument_constants.h" namespace VcProjectManager { namespace Internal { ToolFile::ToolFile() { + m_attributeContainer = new GeneralAttributeContainer; } ToolFile::ToolFile(const ToolFile &file) { - m_relativePath = file.m_relativePath; + m_attributeContainer = new GeneralAttributeContainer; + *m_attributeContainer = *file.m_attributeContainer; } ToolFile &ToolFile::operator =(const ToolFile &file) { if (this != &file) - m_relativePath = file.m_relativePath; + *m_attributeContainer = *file.m_attributeContainer; return *this; } ToolFile::~ToolFile() { + delete m_attributeContainer; } void ToolFile::processNode(const QDomNode &node) @@ -69,19 +74,24 @@ VcNodeWidget *ToolFile::createSettingsWidget() QDomNode ToolFile::toXMLDomNode(QDomDocument &domXMLDocument) const { QDomElement toolNode = domXMLDocument.createElement(QLatin1String("ToolFile")); - toolNode.setAttribute(QLatin1String("RelativePath"), m_relativePath); + m_attributeContainer->appendToXMLNode(toolNode); return toolNode; } -QString ToolFile::relativePath() const +QString ToolFile::type() const { - return m_relativePath; + return QLatin1String(VcDocConstants::TOOL_FILE); } -void ToolFile::setRelativePath(const QString &relativePath) +IToolFile *ToolFile::clone() const { - m_relativePath = relativePath; + return new ToolFile(*this); +} + +IAttributeContainer *ToolFile::attributeContainer() const +{ + return m_attributeContainer; } void ToolFile::processNodeAttributes(const QDomElement &element) @@ -95,7 +105,7 @@ void ToolFile::processNodeAttributes(const QDomElement &element) QDomAttr domElement = domNode.toAttr(); if (domElement.name() == QLatin1String("RelativePath")) - m_relativePath = domElement.value(); + m_attributeContainer->setAttribute(domElement.name(), domElement.value()); } } } diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/toolfile.h b/src/plugins/vcprojectmanager/vcprojectmodel/toolfile.h index f0a56b5c2d..350cbf0c61 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/toolfile.h +++ b/src/plugins/vcprojectmanager/vcprojectmodel/toolfile.h @@ -30,7 +30,7 @@ #ifndef VCPROJECTMANAGER_INTERNAL_TOOLFILE_H #define VCPROJECTMANAGER_INTERNAL_TOOLFILE_H -#include "ivcprojectnodemodel.h" +#include "../interfaces/itoolfile.h" #include <QString> #include <QSharedPointer> @@ -38,7 +38,9 @@ namespace VcProjectManager { namespace Internal { -class ToolFile : public IVcProjectXMLNode +class GeneralAttributeContainer; + +class ToolFile : public IToolFile { public: typedef QSharedPointer<ToolFile> Ptr; @@ -52,13 +54,14 @@ public: VcNodeWidget* createSettingsWidget(); QDomNode toXMLDomNode(QDomDocument &domXMLDocument) const; - QString relativePath() const; - void setRelativePath(const QString &relativePath); + QString type() const; + IToolFile *clone() const; + IAttributeContainer *attributeContainer() const; private: void processNodeAttributes(const QDomElement &element); - QString m_relativePath; // required + GeneralAttributeContainer *m_attributeContainer; }; } // namespace Internal diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/toolfiles.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/toolfiles.cpp index 3c8277997d..65529c8424 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/toolfiles.cpp +++ b/src/plugins/vcprojectmanager/vcprojectmodel/toolfiles.cpp @@ -28,6 +28,8 @@ ** ****************************************************************************/ #include "toolfiles.h" +#include "../interfaces/iattributecontainer.h" +#include "vcprojectdocument_constants.h" namespace VcProjectManager { namespace Internal { @@ -109,7 +111,7 @@ void ToolFiles::addToolFile(ToolFile::Ptr toolFile) return; foreach (const ToolFile::Ptr &toolF, m_toolFiles) { - if (toolF->relativePath() == toolFile->relativePath()) + if (toolF->attributeContainer()->attributeValue(QLatin1String(VcDocConstants::TOOL_FILE_RELATIVE_PATH)) == toolFile->attributeContainer()->attributeValue(QLatin1String(VcDocConstants::TOOL_FILE_RELATIVE_PATH))) return; } m_toolFiles.append(toolFile); @@ -123,7 +125,7 @@ void ToolFiles::removeToolFile(ToolFile::Ptr toolFile) void ToolFiles::removeToolFile(const QString &relativeToolFilePath) { foreach (const ToolFile::Ptr &toolF, m_toolFiles) { - if (toolF->relativePath() == relativeToolFilePath) { + if (toolF->attributeContainer()->attributeValue(QLatin1String(VcDocConstants::TOOL_FILE_RELATIVE_PATH)) == relativeToolFilePath) { removeToolFile(toolF); return; } @@ -138,7 +140,7 @@ QList<ToolFile::Ptr> ToolFiles::toolFiles() const ToolFile::Ptr ToolFiles::toolFile(const QString &relativePath) { foreach (const ToolFile::Ptr &toolFile, m_toolFiles) { - if (toolFile->relativePath() == relativePath) + if (toolFile->attributeContainer()->attributeValue(QLatin1String(VcDocConstants::TOOL_FILE_RELATIVE_PATH)) == relativePath) return toolFile; } return ToolFile::Ptr(); diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectdocument_constants.h b/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectdocument_constants.h index 777c4e9a42..30acb825d6 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectdocument_constants.h +++ b/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectdocument_constants.h @@ -78,6 +78,11 @@ const char PROJECT_REFERENCE_USE_DEPENDENCIES_IN_BUILD [] = "UseDependenciesInBu const char PROJECT_REFERENCE_COPY_LOCAL_SATELITE_ASSEMBLIES [] = "CopyLocalSatelliteAssemblies"; const char PROJECT_REFERENCE_COPY_LOCAL_DEPENDENCIES [] = "CopyLocalDependencies"; +// ToolFile +const char TOOL_FILE [] = "ToolFile"; +const char TOOL_FILE_RELATIVE_PATH [] = "RelativePath"; +const char DEFAULT_TOOL_FILE [] = "DefaultToolFile"; + } // VcDocConstants } // namespace Internal } // namespace VcProjectManager |