summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadovan Zivkovic <pivonroll@gmail.com>2013-10-10 01:13:48 +0200
committerOswald Buddenhagen <oswald.buddenhagen@digia.com>2014-03-11 19:54:59 +0100
commitf1d99c010a9c4008f3d4cb7eb2ea8f1a984865cb (patch)
treea412f8ac839b3f450af1b2faf6af017b31c729da
parentde3a523b8ddeb60de292a6f3c154c1e3303d049e (diff)
downloadqt-creator-f1d99c010a9c4008f3d4cb7eb2ea8f1a984865cb.tar.gz
Global and Globals implements IGlobal and IGlobals.
Change-Id: I9eef4fa20331138708371f019900259061f6b115 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
-rw-r--r--src/plugins/vcprojectmanager/interfaces/iglobal.h54
-rw-r--r--src/plugins/vcprojectmanager/interfaces/iglobals.h52
-rw-r--r--src/plugins/vcprojectmanager/interfaces/interfaces.pri4
-rw-r--r--src/plugins/vcprojectmanager/vcprojectmodel/global.cpp9
-rw-r--r--src/plugins/vcprojectmanager/vcprojectmodel/global.h15
-rw-r--r--src/plugins/vcprojectmanager/vcprojectmodel/globals.cpp67
-rw-r--r--src/plugins/vcprojectmanager/vcprojectmodel/globals.h20
-rw-r--r--src/plugins/vcprojectmanager/vcprojectmodel/vcprojectdocument.cpp2
8 files changed, 157 insertions, 66 deletions
diff --git a/src/plugins/vcprojectmanager/interfaces/iglobal.h b/src/plugins/vcprojectmanager/interfaces/iglobal.h
new file mode 100644
index 0000000000..cc6317c011
--- /dev/null
+++ b/src/plugins/vcprojectmanager/interfaces/iglobal.h
@@ -0,0 +1,54 @@
+/**************************************************************************
+**
+** 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_IGLOBAL_H
+#define VCPROJECTMANAGER_INTERNAL_IGLOBAL_H
+
+#include "../vcprojectmodel/ivcprojectnodemodel.h"
+#include <QString>
+
+namespace VcProjectManager {
+namespace Internal {
+
+class IGlobal : public IVcProjectXMLNode
+{
+public:
+ ~IGlobal() {}
+
+ virtual QString displayName() const = 0;
+ virtual void setDisplayName(const QString &name) = 0;
+ virtual QString value() const = 0;
+ virtual void setValue(const QString &value) = 0;
+ virtual IGlobal* clone() const = 0;
+};
+
+} // namespace Internal
+} // namespace VcProjectManager
+
+#endif // VCPROJECTMANAGER_INTERNAL_IGLOBAL_H
diff --git a/src/plugins/vcprojectmanager/interfaces/iglobals.h b/src/plugins/vcprojectmanager/interfaces/iglobals.h
new file mode 100644
index 0000000000..3954172ae0
--- /dev/null
+++ b/src/plugins/vcprojectmanager/interfaces/iglobals.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_IGLOBALHANDLER_H
+#define VCPROJECTMANAGER_INTERNAL_IGLOBALHANDLER_H
+
+#include "../vcprojectmodel/ivcprojectnodemodel.h"
+
+namespace VcProjectManager {
+namespace Internal {
+
+class IGlobal;
+
+class IGlobals : public IVcProjectXMLNode
+{
+public:
+ virtual void addGlobal(IGlobal *global) = 0;
+ virtual int globalCount() const = 0;
+ virtual IGlobal* global(int index) const = 0;
+ virtual void removeGlobal(IGlobal *global) = 0;
+};
+
+} // namespace Internal
+} // namespace VcProjectManager
+
+#endif // VCPROJECTMANAGER_INTERNAL_IGLOBALHANDLER_H
diff --git a/src/plugins/vcprojectmanager/interfaces/interfaces.pri b/src/plugins/vcprojectmanager/interfaces/interfaces.pri
index fca18fc918..5f78ab1b87 100644
--- a/src/plugins/vcprojectmanager/interfaces/interfaces.pri
+++ b/src/plugins/vcprojectmanager/interfaces/interfaces.pri
@@ -19,4 +19,6 @@ HEADERS += \
interfaces/ideploymenttool.h \
interfaces/iconfigurationbuildtool.h \
interfaces/idebuggertool.h \
- interfaces/idebuggertools.h
+ interfaces/idebuggertools.h \
+ interfaces/iglobal.h \
+ interfaces/iglobals.h
diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/global.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/global.cpp
index 573c3ecf86..a5cb8e14a0 100644
--- a/src/plugins/vcprojectmanager/vcprojectmodel/global.cpp
+++ b/src/plugins/vcprojectmanager/vcprojectmodel/global.cpp
@@ -80,12 +80,12 @@ QDomNode Global::toXMLDomNode(QDomDocument &domXMLDocument) const
return globalNode;
}
-QString Global::name() const
+QString Global::displayName() const
{
return m_name;
}
-void Global::setName(const QString &name)
+void Global::setDisplayName(const QString &name)
{
m_name = name;
}
@@ -100,6 +100,11 @@ void Global::setValue(const QString &value)
m_value = value;
}
+IGlobal *Global::clone() const
+{
+ return new Global(*this);
+}
+
void Global::processNodeAttributes(const QDomElement &element)
{
QDomNamedNodeMap namedNodeMap = element.attributes();
diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/global.h b/src/plugins/vcprojectmanager/vcprojectmodel/global.h
index 906e0300e5..7293f81277 100644
--- a/src/plugins/vcprojectmanager/vcprojectmodel/global.h
+++ b/src/plugins/vcprojectmanager/vcprojectmodel/global.h
@@ -30,19 +30,14 @@
#ifndef VCPROJECTMANAGER_INTERNAL_GLOBAL_H
#define VCPROJECTMANAGER_INTERNAL_GLOBAL_H
-#include "ivcprojectnodemodel.h"
-
-#include <QString>
-#include <QSharedPointer>
+#include "../interfaces/iglobal.h"
namespace VcProjectManager {
namespace Internal {
-class Global : public IVcProjectXMLNode
+class Global : public IGlobal
{
public:
- typedef QSharedPointer<Global> Ptr;
-
Global();
Global(const Global &global);
Global& operator=(const Global &global);
@@ -52,11 +47,13 @@ public:
VcNodeWidget* createSettingsWidget();
QDomNode toXMLDomNode(QDomDocument &domXMLDocument) const;
- QString name() const;
- void setName(const QString &name);
+ QString displayName() const;
+ void setDisplayName(const QString &name);
QString value() const;
void setValue(const QString &value);
+ IGlobal* clone() const;
+
private:
void processNodeAttributes(const QDomElement &element);
diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/globals.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/globals.cpp
index 68511d8ff5..4b9be9a85e 100644
--- a/src/plugins/vcprojectmanager/vcprojectmodel/globals.cpp
+++ b/src/plugins/vcprojectmanager/vcprojectmodel/globals.cpp
@@ -29,6 +29,8 @@
****************************************************************************/
#include "globals.h"
+#include <utils/qtcassert.h>
+
namespace VcProjectManager {
namespace Internal {
@@ -38,17 +40,18 @@ Globals::Globals()
Globals::Globals(const Globals &globals)
{
- foreach (Global::Ptr global, globals.m_globals)
- m_globals.append(Global::Ptr(new Global(*global)));
+ foreach (IGlobal *global, globals.m_globals)
+ m_globals.append(global->clone());
}
Globals &Globals::operator =(const Globals &globals)
{
if (this != &globals) {
+ qDeleteAll(m_globals);
m_globals.clear();
- foreach (Global::Ptr global, globals.m_globals)
- m_globals.append(Global::Ptr(new Global(*global)));
+ foreach (IGlobal *global, globals.m_globals)
+ m_globals.append(global->clone());
}
return *this;
@@ -56,7 +59,7 @@ Globals &Globals::operator =(const Globals &globals)
Globals::~Globals()
{
- m_globals.clear();
+ qDeleteAll(m_globals);
}
void Globals::processNode(const QDomNode &node)
@@ -81,62 +84,44 @@ QDomNode Globals::toXMLDomNode(QDomDocument &domXMLDocument) const
{
QDomElement globalsNode = domXMLDocument.createElement(QLatin1String("Globals"));
- foreach (const Global::Ptr &global, m_globals)
+ foreach (const IGlobal *global, m_globals)
globalsNode.appendChild(global->toXMLDomNode(domXMLDocument));
return globalsNode;
}
-bool Globals::isEmpty() const
-{
- return m_globals.isEmpty();
-}
-
-void Globals::processGlobal(const QDomNode &globalNode)
-{
- Global::Ptr global(new Global);
- global->processNode(globalNode);
- m_globals.append(global);
-
- // process next sibling
- QDomNode nextSibling = globalNode.nextSibling();
- if (!nextSibling.isNull())
- processGlobal(nextSibling);
-}
-
-void Globals::addGlobal(Global::Ptr global)
+void Globals::addGlobal(IGlobal *global)
{
if (m_globals.contains(global))
m_globals.append(global);
}
-void Globals::removeGlobal(Global::Ptr global)
+int Globals::globalCount() const
{
- m_globals.removeAll(global);
+ return m_globals.size();
}
-void Globals::removeGlobal(const QString &globalName)
+IGlobal *Globals::global(int index) const
{
- foreach (const Global::Ptr &global, m_globals) {
- if (global->name() == globalName) {
- removeGlobal(global);
- return;
- }
- }
+ QTC_ASSERT(0 <= index && index < m_globals.size(), return 0);
+ return m_globals[index];
}
-QList<Global::Ptr> Globals::globals() const
+void Globals::removeGlobal(IGlobal *global)
{
- return m_globals;
+ m_globals.removeOne(global);
}
-Global::Ptr Globals::global(const QString &name)
+void Globals::processGlobal(const QDomNode &globalNode)
{
- foreach (const Global::Ptr &global, m_globals) {
- if (global->name() == name)
- return global;
- }
- return Global::Ptr();
+ Global* global = new Global;
+ global->processNode(globalNode);
+ m_globals.append(global);
+
+ // process next sibling
+ QDomNode nextSibling = globalNode.nextSibling();
+ if (!nextSibling.isNull())
+ processGlobal(nextSibling);
}
} // namespace Internal
diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/globals.h b/src/plugins/vcprojectmanager/vcprojectmodel/globals.h
index 517ea154c9..4dc79b7f85 100644
--- a/src/plugins/vcprojectmanager/vcprojectmodel/globals.h
+++ b/src/plugins/vcprojectmanager/vcprojectmodel/globals.h
@@ -30,7 +30,7 @@
#ifndef VCPROJECTMANAGER_INTERNAL_GLOBALS_H
#define VCPROJECTMANAGER_INTERNAL_GLOBALS_H
-#include "ivcprojectnodemodel.h"
+#include "../interfaces/iglobals.h"
#include <QList>
#include <QHash>
@@ -42,7 +42,7 @@ namespace Internal {
class Global;
-class Globals : public IVcProjectXMLNode
+class Globals : public IGlobals
{
public:
typedef QSharedPointer<Globals> Ptr;
@@ -56,18 +56,14 @@ public:
VcNodeWidget* createSettingsWidget();
QDomNode toXMLDomNode(QDomDocument &domXMLDocument) const;
- bool isEmpty() const;
-
- void processGlobal(const QDomNode &globalNode);
-
- void addGlobal(Global::Ptr global);
- void removeGlobal(Global::Ptr global);
- void removeGlobal(const QString &globalName);
- QList<Global::Ptr> globals() const;
- Global::Ptr global(const QString &name);
+ void addGlobal(IGlobal *global);
+ int globalCount() const;
+ IGlobal *global(int index) const;
+ void removeGlobal(IGlobal *global);
private:
- QList<Global::Ptr> m_globals;
+ void processGlobal(const QDomNode &globalNode);
+ QList<IGlobal *> m_globals;
};
} // namespace Internal
diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectdocument.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectdocument.cpp
index 701811291e..0bb838d9d2 100644
--- a/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectdocument.cpp
+++ b/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectdocument.cpp
@@ -334,7 +334,7 @@ QDomElement VcProjectDocument::toVcDocumentElement(QDomDocument &domXMLDocument)
if (!m_references->isEmpty())
vcDocNode.appendChild(m_references->toXMLDomNode(domXMLDocument));
- if (!m_globals->isEmpty())
+ if (m_globals->globalCount())
vcDocNode.appendChild(m_globals->toXMLDomNode(domXMLDocument));
return vcDocNode;