diff options
author | Radovan Zivkovic <pivonroll@gmail.com> | 2013-10-08 13:48:38 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2014-03-11 19:54:59 +0100 |
commit | 39331f5611e5e229ce15243020a406e45f5d814a (patch) | |
tree | 65e882649d666a418e9ceca62ca8685d67427e3f /src/plugins | |
parent | 1acb0e25887d35f507fa942523f601675d71199c (diff) | |
download | qt-creator-39331f5611e5e229ce15243020a406e45f5d814a.tar.gz |
Added GeneralToolAttributeContainer.
Change-Id: Ifb8198c7660bf20947104d62eaf7d8ee9ad5a1cf
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Diffstat (limited to 'src/plugins')
12 files changed, 254 insertions, 75 deletions
diff --git a/src/plugins/vcprojectmanager/interfaces/interfaces.pri b/src/plugins/vcprojectmanager/interfaces/interfaces.pri index a97bd9feb3..2eb4bae2af 100644 --- a/src/plugins/vcprojectmanager/interfaces/interfaces.pri +++ b/src/plugins/vcprojectmanager/interfaces/interfaces.pri @@ -13,4 +13,5 @@ HEADERS += \ interfaces/ifilecontainer.h \ interfaces/ifiles.h \ interfaces/ireference.h \ - interfaces/iconfigurationtool.h + interfaces/iconfigurationtool.h \ + interfaces/itoolattributecontainer.h diff --git a/src/plugins/vcprojectmanager/interfaces/itoolattributecontainer.h b/src/plugins/vcprojectmanager/interfaces/itoolattributecontainer.h new file mode 100644 index 0000000000..6e94b7b8fe --- /dev/null +++ b/src/plugins/vcprojectmanager/interfaces/itoolattributecontainer.h @@ -0,0 +1,53 @@ +/************************************************************************** +** +** 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 ITOOLATTRIBUTECONTAINER_H +#define ITOOLATTRIBUTECONTAINER_H + +#include <QString> + +namespace VcProjectManager { +namespace Internal { + +class IToolAttribute; + +class IToolAttributeContainer +{ +public: + virtual ~IToolAttributeContainer() {} + virtual IToolAttribute* toolAttribute(int index) const = 0; + virtual IToolAttribute* toolAttribute(const QString &attributeKey) const = 0; + virtual int toolAttributeCount() const = 0; + virtual void addToolAttribute(IToolAttribute* toolAttribute) = 0; + virtual void removeToolAttribute(IToolAttribute* toolAttribute) = 0; +}; + +} // Internal +} // VcProjectManager +#endif // ITOOLATTRIBUTECONTAINER_H diff --git a/src/plugins/vcprojectmanager/interfaces/itoolsection.h b/src/plugins/vcprojectmanager/interfaces/itoolsection.h index 6752456b0f..a80631c573 100644 --- a/src/plugins/vcprojectmanager/interfaces/itoolsection.h +++ b/src/plugins/vcprojectmanager/interfaces/itoolsection.h @@ -36,16 +36,13 @@ namespace Internal { class IToolAttribute; class IToolSectionDescription; class VcNodeWidget; +class IToolAttributeContainer; class IToolSection { public: virtual ~IToolSection() {} - virtual IToolAttribute* toolAttribute(int index) const = 0; - virtual IToolAttribute* toolAttribute(const QString &attributeKey) const = 0; - virtual int toolAttributeCount() const = 0; - virtual void addToolAttribute(IToolAttribute* toolAttribute) = 0; - virtual void removeToolAttribute(IToolAttribute* toolAttribute) = 0; + virtual IToolAttributeContainer *attributeContainer() const = 0; virtual const IToolSectionDescription *sectionDescription() const = 0; virtual VcNodeWidget* createSettingsWidget() = 0; virtual IToolSection* clone() const = 0; diff --git a/src/plugins/vcprojectmanager/vcproject.cpp b/src/plugins/vcprojectmanager/vcproject.cpp index eaace93b85..ce4dae7d45 100644 --- a/src/plugins/vcprojectmanager/vcproject.cpp +++ b/src/plugins/vcprojectmanager/vcproject.cpp @@ -47,6 +47,7 @@ #include "interfaces/iattributedescriptiondataitem.h" #include "interfaces/isectioncontainer.h" #include "interfaces/itools.h" +#include "interfaces/itoolattributecontainer.h" #include <coreplugin/icontext.h> #include <coreplugin/icore.h> @@ -317,7 +318,7 @@ void VcProject::updateCodeModels() IToolSection *toolSection = configTool->sectionContainer()->section(i); if (toolSection) { - IToolAttribute *toolAttr = toolSection->toolAttribute(QLatin1String("PreprocessorDefinitions")); + IToolAttribute *toolAttr = toolSection->attributeContainer()->toolAttribute(QLatin1String("PreprocessorDefinitions")); if (toolAttr) { StringListToolAttribute *stringToolAttr = static_cast<StringListToolAttribute *>(toolAttr); diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/tools/configurationtool.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/tools/configurationtool.cpp index d7e0253d0d..8a4a5cfa65 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/tools/configurationtool.cpp +++ b/src/plugins/vcprojectmanager/vcprojectmodel/tools/configurationtool.cpp @@ -30,6 +30,7 @@ #include "configurationtool.h" #include "../../interfaces/itoolattribute.h" #include "../../interfaces/iattributedescriptiondataitem.h" +#include "../../interfaces/itoolattributecontainer.h" #include "toolattributes/tooldescriptiondatamanager.h" #include "toolattributes/tooldescription.h" #include "toolsectiondescription.h" @@ -112,7 +113,7 @@ void ConfigurationTool::processNodeAttributes(const QDomElement &domElement) for (int i = 0; i < m_sectionContainer->sectionCount(); ++i) { IToolSection *toolSection = m_sectionContainer->section(i); if (toolSection) { - IToolAttribute *toolAttr = toolSection->toolAttribute(domElement.name()); + IToolAttribute *toolAttr = toolSection->attributeContainer()->toolAttribute(domElement.name()); if (toolAttr) toolAttr->setValue(domElement.value()); diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/tools/generaltoolattributecontainer.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/tools/generaltoolattributecontainer.cpp new file mode 100644 index 0000000000..c57469b2e1 --- /dev/null +++ b/src/plugins/vcprojectmanager/vcprojectmodel/tools/generaltoolattributecontainer.cpp @@ -0,0 +1,110 @@ +/************************************************************************** +** +** 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. +** +****************************************************************************/ +#include "generaltoolattributecontainer.h" +#include "../../interfaces/iattributedescriptiondataitem.h" +#include "../../interfaces/itoolattribute.h" + +namespace VcProjectManager { +namespace Internal { + +GeneralToolAttributeContainer::GeneralToolAttributeContainer() +{ +} + +GeneralToolAttributeContainer::GeneralToolAttributeContainer(const GeneralToolAttributeContainer &container) +{ + foreach (IToolAttribute *toolAttr, container.m_toolAttributes) + m_toolAttributes.append(toolAttr->clone()); +} + +GeneralToolAttributeContainer &GeneralToolAttributeContainer::operator=(const GeneralToolAttributeContainer &container) +{ + if (this != &container) { + qDeleteAll(m_toolAttributes); + foreach (IToolAttribute *toolAttr, container.m_toolAttributes) + m_toolAttributes.append(toolAttr->clone()); + } + return *this; +} + +GeneralToolAttributeContainer::~GeneralToolAttributeContainer() +{ + qDeleteAll(m_toolAttributes); +} + +IToolAttribute *GeneralToolAttributeContainer::toolAttribute(int index) const +{ + if (0 <= index && index < m_toolAttributes.size()) + return m_toolAttributes[index]; + return 0; +} + +IToolAttribute *GeneralToolAttributeContainer::toolAttribute(const QString &attributeKey) const +{ + foreach (IToolAttribute *toolAttr, m_toolAttributes) { + if (toolAttr->descriptionDataItem()->key() == attributeKey) + return toolAttr; + } + + return 0; +} + +int GeneralToolAttributeContainer::toolAttributeCount() const +{ + return m_toolAttributes.size(); +} + +void GeneralToolAttributeContainer::addToolAttribute(IToolAttribute *toolAttribute) +{ + if (!toolAttribute || m_toolAttributes.contains(toolAttribute)) + return; + + foreach (IToolAttribute *toolAttr, m_toolAttributes) { + if (toolAttr->descriptionDataItem()->key() == toolAttribute->descriptionDataItem()->key()) + return; + } + m_toolAttributes.append(toolAttribute); +} + +void GeneralToolAttributeContainer::removeToolAttribute(IToolAttribute *toolAttribute) +{ + if (!toolAttribute) + return; + + foreach (IToolAttribute *toolAttr, m_toolAttributes) { + if (toolAttr->descriptionDataItem()->key() == toolAttribute->descriptionDataItem()->key()) { + m_toolAttributes.removeOne(toolAttr); + return; + } + } +} + +} // Internal +} // VcProjectManager diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/tools/generaltoolattributecontainer.h b/src/plugins/vcprojectmanager/vcprojectmodel/tools/generaltoolattributecontainer.h new file mode 100644 index 0000000000..d60f411080 --- /dev/null +++ b/src/plugins/vcprojectmanager/vcprojectmodel/tools/generaltoolattributecontainer.h @@ -0,0 +1,60 @@ +/************************************************************************** +** +** 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 GENERALTOOLATTRIBUTECONTAINER_H +#define GENERALTOOLATTRIBUTECONTAINER_H + +#include <QList> +#include "../../interfaces/itoolattributecontainer.h" + +namespace VcProjectManager { +namespace Internal { + +class GeneralToolAttributeContainer : public IToolAttributeContainer +{ +public: + GeneralToolAttributeContainer(); + GeneralToolAttributeContainer(const GeneralToolAttributeContainer &container); + GeneralToolAttributeContainer& operator=(const GeneralToolAttributeContainer &container); + ~GeneralToolAttributeContainer(); + + // IToolAttributeContainer interface + IToolAttribute *toolAttribute(int index) const; + IToolAttribute *toolAttribute(const QString &attributeKey) const; + int toolAttributeCount() const; + void addToolAttribute(IToolAttribute *toolAttribute); + void removeToolAttribute(IToolAttribute *toolAttribute); + +private: + QList<IToolAttribute *> m_toolAttributes; +}; + +} // Internal +} // VcProjectManager +#endif // GENERALTOOLATTRIBUTECONTAINER_H diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/tools/toolattributes/toolsectioncontainer.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/tools/toolattributes/toolsectioncontainer.cpp index bb83932644..d51c28faf8 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/tools/toolattributes/toolsectioncontainer.cpp +++ b/src/plugins/vcprojectmanager/vcprojectmodel/tools/toolattributes/toolsectioncontainer.cpp @@ -32,6 +32,7 @@ #include "../../../interfaces/itoolsectiondescription.h" #include "../../../interfaces/itoolattribute.h" #include "../../../interfaces/iattributedescriptiondataitem.h" +#include "../../../interfaces/itoolattributecontainer.h" namespace VcProjectManager { namespace Internal { @@ -121,8 +122,8 @@ void ToolSectionContainer::appendToXMLNode(QDomElement &elementNode) { foreach (IToolSection *toolSection, m_toolSections) { if (toolSection) { - for (int i = 0; i < toolSection->toolAttributeCount(); ++i) { - IToolAttribute *toolAttr = toolSection->toolAttribute(i); + for (int i = 0; i < toolSection->attributeContainer()->toolAttributeCount(); ++i) { + IToolAttribute *toolAttr = toolSection->attributeContainer()->toolAttribute(i); if (toolAttr && toolAttr->isUsed()) elementNode.setAttribute(toolAttr->descriptionDataItem()->key(), toolAttr->value()); diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/tools/toolsection.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/tools/toolsection.cpp index 717cb78c94..72fad5359f 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/tools/toolsection.cpp +++ b/src/plugins/vcprojectmanager/vcprojectmodel/tools/toolsection.cpp @@ -32,6 +32,7 @@ #include "../../interfaces/iattributedescriptiondataitem.h" #include "../../widgets/toolwidgets/toolsectionsettingswidget.h" #include "toolsectiondescription.h" +#include "generaltoolattributecontainer.h" namespace VcProjectManager { namespace Internal { @@ -39,75 +40,32 @@ namespace Internal { ToolSection::ToolSection(const ToolSectionDescription *toolSectionDesc) : m_toolDesc(toolSectionDesc) { + m_attributeContainer = new GeneralToolAttributeContainer; for (int i = 0; i < toolSectionDesc->attributeDescriptionCount(); ++i) { if (toolSectionDesc->attributeDescription(i)) - m_toolAttributes.append(toolSectionDesc->attributeDescription(i)->createAttribute()); + m_attributeContainer->addToolAttribute(toolSectionDesc->attributeDescription(i)->createAttribute()); } } ToolSection::ToolSection(const ToolSection &toolSec) { - qDeleteAll(m_toolAttributes); - m_toolAttributes.clear(); + m_attributeContainer = new GeneralToolAttributeContainer; + *m_attributeContainer = *toolSec.m_attributeContainer; m_toolDesc = toolSec.m_toolDesc; - foreach (const IToolAttribute *toolAttribute, toolSec.m_toolAttributes) { - if (toolAttribute) - m_toolAttributes.append(toolAttribute->clone()); - } + for (int i = 0; i < toolSec.attributeContainer()->toolAttributeCount(); ++i) + m_attributeContainer->addToolAttribute(toolSec.attributeContainer()->toolAttribute(i)->clone()); } ToolSection::~ToolSection() { - qDeleteAll(m_toolAttributes); -} - -IToolAttribute *ToolSection::toolAttribute(int index) const -{ - if (0 <= index && index < m_toolAttributes.size()) - return m_toolAttributes[index]; - return 0; -} - -IToolAttribute *ToolSection::toolAttribute(const QString &attributeKey) const -{ - foreach (IToolAttribute *toolAttr, m_toolAttributes) { - if (toolAttr->descriptionDataItem()->key() == attributeKey) - return toolAttr; - } - - return 0; + delete m_attributeContainer; } -int ToolSection::toolAttributeCount() const +IToolAttributeContainer *ToolSection::attributeContainer() const { - return m_toolAttributes.size(); -} - -void ToolSection::addToolAttribute(IToolAttribute *toolAttribute) -{ - if (!toolAttribute || m_toolAttributes.contains(toolAttribute)) - return; - - foreach (IToolAttribute *toolAttr, m_toolAttributes) { - if (toolAttr->descriptionDataItem()->key() == toolAttribute->descriptionDataItem()->key()) - return; - } - m_toolAttributes.append(toolAttribute); -} - -void ToolSection::removeToolAttribute(IToolAttribute *toolAttribute) -{ - if (!toolAttribute) - return; - - foreach (IToolAttribute *toolAttr, m_toolAttributes) { - if (toolAttr->descriptionDataItem()->key() == toolAttribute->descriptionDataItem()->key()) { - m_toolAttributes.removeOne(toolAttr); - return; - } - } + return m_attributeContainer; } const IToolSectionDescription *ToolSection::sectionDescription() const diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/tools/toolsection.h b/src/plugins/vcprojectmanager/vcprojectmodel/tools/toolsection.h index 750697f110..b627039b0a 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/tools/toolsection.h +++ b/src/plugins/vcprojectmanager/vcprojectmodel/tools/toolsection.h @@ -41,6 +41,7 @@ namespace Internal { class ToolSectionDescription; class IToolAttribute; class ToolSectionSettingsWidget; +class GeneralToolAttributeContainer; class ToolSection : public IToolSection { @@ -49,21 +50,14 @@ public: ToolSection(const ToolSection &toolSec); ~ToolSection(); - IToolAttribute* toolAttribute(int index) const; - IToolAttribute* toolAttribute(const QString &attributeKey) const; - int toolAttributeCount() const; - void addToolAttribute(IToolAttribute* toolAttribute); - void removeToolAttribute(IToolAttribute* toolAttribute); - + IToolAttributeContainer *attributeContainer() const; const IToolSectionDescription *sectionDescription() const; - VcNodeWidget* createSettingsWidget(); - IToolSection* clone() const; private: const ToolSectionDescription * m_toolDesc; - QList<IToolAttribute *> m_toolAttributes; + GeneralToolAttributeContainer *m_attributeContainer; }; } // namespace Internal diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri b/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri index 34946caef5..c68b917f9c 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri +++ b/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri @@ -44,7 +44,8 @@ HEADERS += \ vcprojectmodel/generalattributecontainer.h \ vcprojectmodel/configurationtools.h \ vcprojectmodel/tools/toolattributes/toolsectioncontainer.h \ - vcprojectmodel/configurationcontainer.h + vcprojectmodel/configurationcontainer.h \ + vcprojectmodel/tools/generaltoolattributecontainer.h SOURCES += \ vcprojectmodel/vcprojectdocument.cpp \ @@ -88,7 +89,8 @@ SOURCES += \ vcprojectmodel/generalattributecontainer.cpp \ vcprojectmodel/configurationtools.cpp \ vcprojectmodel/tools/toolattributes/toolsectioncontainer.cpp \ - vcprojectmodel/configurationcontainer.cpp + vcprojectmodel/configurationcontainer.cpp \ + vcprojectmodel/tools/generaltoolattributecontainer.cpp OTHER_FILES += \ vcprojectmodel/tools/xml_definitions/VCXMLDataGeneratorTool.xml \ diff --git a/src/plugins/vcprojectmanager/widgets/toolwidgets/toolsectionsettingswidget.cpp b/src/plugins/vcprojectmanager/widgets/toolwidgets/toolsectionsettingswidget.cpp index 99240f1609..b426e443cf 100644 --- a/src/plugins/vcprojectmanager/widgets/toolwidgets/toolsectionsettingswidget.cpp +++ b/src/plugins/vcprojectmanager/widgets/toolwidgets/toolsectionsettingswidget.cpp @@ -32,6 +32,7 @@ #include "../../vcprojectmodel/tools/toolsection.h" #include "../../interfaces/itoolattribute.h" #include "../../interfaces/iattributedescriptiondataitem.h" +#include "../../interfaces/itoolattributecontainer.h" #include "../basicconfigurationwidget.h" #include <QVBoxLayout> @@ -44,8 +45,8 @@ ToolSectionSettingsWidget::ToolSectionSettingsWidget(ToolSection *toolSection, Q { BasicConfigurationWidget *basicWidget = new BasicConfigurationWidget(this); - for (int i = 0; i < toolSection->toolAttributeCount(); ++i) { - IToolAttribute *toolAttr = toolSection->toolAttribute(i); + for (int i = 0; i < toolSection->attributeContainer()->toolAttributeCount(); ++i) { + IToolAttribute *toolAttr = toolSection->attributeContainer()->toolAttribute(i); if (toolAttr) appendAttributeToBasicWidget(toolAttr, basicWidget); |