aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@qt.io>2019-08-07 16:00:21 +0200
committerTim Jenssen <tim.jenssen@qt.io>2019-08-07 14:48:04 +0000
commitc9b91e7e6b25d5c76bd736c054c681a6877f625c (patch)
tree4181884b406b8dc6687b6b15613e7205eab8119b /share
parent6ab4d694403cec64c5aa106bb4d457e478e1b8fa (diff)
QmlDesigner: reduce enumeration to header only
It is used in some other external qmldesigner plugin and these are built against current dev packages, which are not contain this cpp file. Different solution would be to add: r"^share/qtcreator/qml/qmlpuppet/types/enumeration.cpp$", to scripts/createDevPackage.py which feels not that clean. Change-Id: Ia1fb5c02f457d98474218689ebf6483706265dde Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h2
-rw-r--r--share/qtcreator/qml/qmlpuppet/types/enumeration.cpp116
-rw-r--r--share/qtcreator/qml/qmlpuppet/types/enumeration.h78
-rw-r--r--share/qtcreator/qml/qmlpuppet/types/types.pri2
4 files changed, 65 insertions, 133 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h
index 07c5d50b6e..55114e872a 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h
@@ -34,7 +34,7 @@
#include <QSharedPointer>
#include <QWeakPointer>
-#include "enumeration.h"
+#include <enumeration.h>
QT_BEGIN_NAMESPACE
class QQmlContext;
diff --git a/share/qtcreator/qml/qmlpuppet/types/enumeration.cpp b/share/qtcreator/qml/qmlpuppet/types/enumeration.cpp
deleted file mode 100644
index 12435838ea..0000000000
--- a/share/qtcreator/qml/qmlpuppet/types/enumeration.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "enumeration.h"
-
-#include <QString>
-#include <QList>
-#include <QtDebug>
-
-namespace QmlDesigner {
-
-Enumeration::Enumeration() = default;
-
-Enumeration::Enumeration(const EnumerationName &enumerationName)
- : m_enumerationName(enumerationName)
-{
-}
-
-Enumeration::Enumeration(const QString &enumerationName)
- : m_enumerationName(enumerationName.toUtf8())
-{
-}
-
-Enumeration::Enumeration(const QString &scope, const QString &name)
-{
- QString enumerationString = scope + QLatin1Char('.') + name;
-
- m_enumerationName = enumerationString.toUtf8();
-}
-
-QmlDesigner::EnumerationName QmlDesigner::Enumeration::scope() const
-{
- return m_enumerationName.split('.').constFirst();
-}
-
-EnumerationName Enumeration::name() const
-{
- return m_enumerationName.split('.').last();
-}
-
-EnumerationName Enumeration::toEnumerationName() const
-{
- return m_enumerationName;
-}
-
-QString Enumeration::toString() const
-{
- return QString::fromUtf8(m_enumerationName);
-}
-
-QString Enumeration::nameToString() const
-{
- return QString::fromUtf8(name());
-}
-
-QDataStream &operator<<(QDataStream &out, const Enumeration &enumeration)
-{
- out << enumeration.toEnumerationName();
-
- return out;
-}
-
-QDataStream &operator>>(QDataStream &in, Enumeration &enumeration)
-{
- in >> enumeration.m_enumerationName;
-
- return in;
-}
-
-
-bool operator ==(const Enumeration &first, const Enumeration &second)
-{
- return first.m_enumerationName == second.m_enumerationName;
-}
-
-bool operator <(const Enumeration &first, const Enumeration &second)
-{
- return first.m_enumerationName < second.m_enumerationName;
-}
-
-QDebug operator <<(QDebug debug, const Enumeration &enumeration)
-{
- debug.nospace() << "Enumeration("
- << enumeration.toString()
- << ")";
-
- return debug;
-}
-
-
-} // namespace QmlDesigner
-
-
-
diff --git a/share/qtcreator/qml/qmlpuppet/types/enumeration.h b/share/qtcreator/qml/qmlpuppet/types/enumeration.h
index d7bc3ac049..c764f16cb2 100644
--- a/share/qtcreator/qml/qmlpuppet/types/enumeration.h
+++ b/share/qtcreator/qml/qmlpuppet/types/enumeration.h
@@ -30,6 +30,10 @@
#include <QMetaType>
#include <QVariant>
+#include <QString>
+#include <QList>
+#include <QtDebug>
+
namespace QmlDesigner {
using EnumerationName = QByteArray;
@@ -41,29 +45,75 @@ class Enumeration
friend QDataStream &operator>>(QDataStream &in, Enumeration &enumeration);
public:
- Enumeration();
- Enumeration(const EnumerationName &enumerationName);
- Enumeration(const QString &enumerationName);
- Enumeration(const QString &scope, const QString &name);
+ Enumeration() = default;
+ Enumeration(const EnumerationName &enumerationName)
+ : m_enumerationName(enumerationName)
+ {
+ }
+ Enumeration(const QString &enumerationName)
+ : m_enumerationName(enumerationName.toUtf8())
+ {
+ }
+ Enumeration(const QString &scope, const QString &name)
+ {
+ QString enumerationString = scope + QLatin1Char('.') + name;
+ m_enumerationName = enumerationString.toUtf8();
+ }
- EnumerationName scope() const;
- EnumerationName name() const;
- EnumerationName toEnumerationName() const;
- QString toString() const;
- QString nameToString() const;
+ EnumerationName scope() const
+ {
+ return m_enumerationName.split('.').constFirst();
+ }
+ EnumerationName name() const
+ {
+ return m_enumerationName.split('.').last();
+ }
+ EnumerationName toEnumerationName() const
+ {
+ return m_enumerationName;
+ }
+ QString toString() const
+ {
+ return QString::fromUtf8(m_enumerationName);
+ }
+ QString nameToString() const
+ {
+ return QString::fromUtf8(name());
+ }
private:
EnumerationName m_enumerationName;
};
-QDataStream &operator<<(QDataStream &out, const Enumeration &enumeration);
-QDataStream &operator>>(QDataStream &in, Enumeration &enumeration);
+inline QDataStream &operator<<(QDataStream &out, const Enumeration &enumeration){
+ out << enumeration.toEnumerationName();
+ return out;
+}
+
+inline QDataStream &operator>>(QDataStream &in, Enumeration &enumeration)
+{
+ in >> enumeration.m_enumerationName;
+ return in;
+}
-bool operator ==(const Enumeration &first, const Enumeration &second);
-bool operator <(const Enumeration &first, const Enumeration &second);
-QDebug operator <<(QDebug debug, const Enumeration &enumeration);
+inline bool operator==(const Enumeration &first, const Enumeration &second)
+{
+ return first.m_enumerationName == second.m_enumerationName;
+}
+inline bool operator<(const Enumeration &first, const Enumeration &second)
+{
+ return first.m_enumerationName < second.m_enumerationName;
+}
+
+inline QDebug operator <<(QDebug debug, const Enumeration &enumeration)
+{
+ debug.nospace() << "Enumeration("
+ << enumeration.toString()
+ << ")";
+ return debug;
+}
} // namespace QmlDesigner
diff --git a/share/qtcreator/qml/qmlpuppet/types/types.pri b/share/qtcreator/qml/qmlpuppet/types/types.pri
index 87425205e6..e5f10bcbe4 100644
--- a/share/qtcreator/qml/qmlpuppet/types/types.pri
+++ b/share/qtcreator/qml/qmlpuppet/types/types.pri
@@ -1,5 +1,3 @@
INCLUDEPATH += $$PWD/
HEADERS += $$PWD/enumeration.h
-
-SOURCES += $$PWD/enumeration.cpp