Commit ee4bf638 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner: Type of the propertyname is now PropertyName



And PropertyName is a typedef for QByteArray. Because we don't use the
features of QString and the source would be cluttered with QLatin1Strings
we changed the property name to QByteArray.

Change-Id: Ib70ef136bbc411504b450456bd9bb705ae93dd25
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent e74d4c48
...@@ -38,11 +38,11 @@ InstanceContainer::InstanceContainer() ...@@ -38,11 +38,11 @@ InstanceContainer::InstanceContainer()
{ {
} }
InstanceContainer::InstanceContainer(qint32 instanceId, const QString &type, int majorNumber, int minorNumber, const QString &componentPath, const QString &nodeSource, NodeSourceType nodeSourceType,NodeMetaType metaType) InstanceContainer::InstanceContainer(qint32 instanceId, const TypeName &type, int majorNumber, int minorNumber, const QString &componentPath, const QString &nodeSource, NodeSourceType nodeSourceType, NodeMetaType metaType)
: m_instanceId(instanceId), m_type(type), m_majorNumber(majorNumber), m_minorNumber(minorNumber), m_componentPath(componentPath), : m_instanceId(instanceId), m_type(type), m_majorNumber(majorNumber), m_minorNumber(minorNumber), m_componentPath(componentPath),
m_nodeSource(nodeSource), m_nodeSourceType(nodeSourceType), m_metaType(metaType) m_nodeSource(nodeSource), m_nodeSourceType(nodeSourceType), m_metaType(metaType)
{ {
m_type.replace(QLatin1Char('.'), QLatin1Char('/')); m_type.replace('.', '/');
} }
qint32 InstanceContainer::instanceId() const qint32 InstanceContainer::instanceId() const
...@@ -50,7 +50,7 @@ qint32 InstanceContainer::instanceId() const ...@@ -50,7 +50,7 @@ qint32 InstanceContainer::instanceId() const
return m_instanceId; return m_instanceId;
} }
QString InstanceContainer::type() const TypeName InstanceContainer::type() const
{ {
return m_type; return m_type;
} }
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <QString> #include <QString>
#include <QDataStream> #include <QDataStream>
#include "nodeinstanceglobal.h"
namespace QmlDesigner { namespace QmlDesigner {
class InstanceContainer; class InstanceContainer;
...@@ -58,10 +60,10 @@ public: ...@@ -58,10 +60,10 @@ public:
}; };
InstanceContainer(); InstanceContainer();
InstanceContainer(qint32 instanceId, const QString &type, int majorNumber, int minorNumber, const QString &componentPath, const QString &nodeSource, NodeSourceType nodeSourceType, NodeMetaType metaType); InstanceContainer(qint32 instanceId, const TypeName &type, int majorNumber, int minorNumber, const QString &componentPath, const QString &nodeSource, NodeSourceType nodeSourceType, NodeMetaType metaType);
qint32 instanceId() const; qint32 instanceId() const;
QString type() const; TypeName type() const;
int majorNumber() const; int majorNumber() const;
int minorNumber() const; int minorNumber() const;
QString componentPath() const; QString componentPath() const;
...@@ -71,7 +73,7 @@ public: ...@@ -71,7 +73,7 @@ public:
private: private:
qint32 m_instanceId; qint32 m_instanceId;
QString m_type; TypeName m_type;
qint32 m_majorNumber; qint32 m_majorNumber;
qint32 m_minorNumber; qint32 m_minorNumber;
QString m_componentPath; QString m_componentPath;
......
...@@ -36,7 +36,7 @@ PropertyAbstractContainer::PropertyAbstractContainer() ...@@ -36,7 +36,7 @@ PropertyAbstractContainer::PropertyAbstractContainer()
{ {
} }
PropertyAbstractContainer::PropertyAbstractContainer(qint32 instanceId, const QString &name, const QString &dynamicTypeName) PropertyAbstractContainer::PropertyAbstractContainer(qint32 instanceId, const PropertyName &name, const QString &dynamicTypeName)
: m_instanceId(instanceId), : m_instanceId(instanceId),
m_name(name), m_name(name),
m_dynamicTypeName(dynamicTypeName) m_dynamicTypeName(dynamicTypeName)
...@@ -48,7 +48,7 @@ qint32 PropertyAbstractContainer::instanceId() const ...@@ -48,7 +48,7 @@ qint32 PropertyAbstractContainer::instanceId() const
return m_instanceId; return m_instanceId;
} }
QString PropertyAbstractContainer::name() const PropertyName PropertyAbstractContainer::name() const
{ {
return m_name; return m_name;
} }
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <qmetatype.h> #include <qmetatype.h>
#include <QString> #include <QString>
#include "nodeinstanceglobal.h"
namespace QmlDesigner { namespace QmlDesigner {
...@@ -49,16 +50,16 @@ class PropertyAbstractContainer ...@@ -49,16 +50,16 @@ class PropertyAbstractContainer
friend QDataStream &operator>>(QDataStream &in, PropertyAbstractContainer &container); friend QDataStream &operator>>(QDataStream &in, PropertyAbstractContainer &container);
public: public:
PropertyAbstractContainer(); PropertyAbstractContainer();
PropertyAbstractContainer(qint32 instanceId, const QString &name, const QString &dynamicTypeName); PropertyAbstractContainer(qint32 instanceId, const PropertyName &name, const QString &dynamicTypeName);
qint32 instanceId() const; qint32 instanceId() const;
QString name() const; PropertyName name() const;
bool isDynamic() const; bool isDynamic() const;
QString dynamicTypeName() const; QString dynamicTypeName() const;
private: private:
qint32 m_instanceId; qint32 m_instanceId;
QString m_name; PropertyName m_name;
QString m_dynamicTypeName; QString m_dynamicTypeName;
}; };
......
...@@ -37,7 +37,7 @@ PropertyBindingContainer::PropertyBindingContainer() ...@@ -37,7 +37,7 @@ PropertyBindingContainer::PropertyBindingContainer()
{ {
} }
PropertyBindingContainer::PropertyBindingContainer(qint32 instanceId, const QString &name, const QString &expression, const QString &dynamicTypeName) PropertyBindingContainer::PropertyBindingContainer(qint32 instanceId, const PropertyName &name, const QString &expression, const TypeName &dynamicTypeName)
: m_instanceId(instanceId), : m_instanceId(instanceId),
m_name(name), m_name(name),
m_expression(expression), m_expression(expression),
...@@ -50,7 +50,7 @@ qint32 PropertyBindingContainer::instanceId() const ...@@ -50,7 +50,7 @@ qint32 PropertyBindingContainer::instanceId() const
return m_instanceId; return m_instanceId;
} }
QString PropertyBindingContainer::name() const PropertyName PropertyBindingContainer::name() const
{ {
return m_name; return m_name;
} }
...@@ -65,7 +65,7 @@ bool PropertyBindingContainer::isDynamic() const ...@@ -65,7 +65,7 @@ bool PropertyBindingContainer::isDynamic() const
return !m_dynamicTypeName.isEmpty(); return !m_dynamicTypeName.isEmpty();
} }
QString PropertyBindingContainer::dynamicTypeName() const TypeName PropertyBindingContainer::dynamicTypeName() const
{ {
return m_dynamicTypeName; return m_dynamicTypeName;
} }
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <qmetatype.h> #include <qmetatype.h>
#include <QString> #include <QString>
#include "nodeinstanceglobal.h"
namespace QmlDesigner { namespace QmlDesigner {
...@@ -43,19 +44,19 @@ class PropertyBindingContainer ...@@ -43,19 +44,19 @@ class PropertyBindingContainer
public: public:
PropertyBindingContainer(); PropertyBindingContainer();
PropertyBindingContainer(qint32 instanceId, const QString &name, const QString &expression, const QString &dynamicTypeName); PropertyBindingContainer(qint32 instanceId, const PropertyName &name, const QString &expression, const TypeName &dynamicTypeName);
qint32 instanceId() const; qint32 instanceId() const;
QString name() const; PropertyName name() const;
QString expression() const; QString expression() const;
bool isDynamic() const; bool isDynamic() const;
QString dynamicTypeName() const; TypeName dynamicTypeName() const;
private: private:
qint32 m_instanceId; qint32 m_instanceId;
QString m_name; PropertyName m_name;
QString m_expression; QString m_expression;
QString m_dynamicTypeName; TypeName m_dynamicTypeName;
}; };
QDataStream &operator<<(QDataStream &out, const PropertyBindingContainer &container); QDataStream &operator<<(QDataStream &out, const PropertyBindingContainer &container);
......
...@@ -36,7 +36,7 @@ PropertyValueContainer::PropertyValueContainer() ...@@ -36,7 +36,7 @@ PropertyValueContainer::PropertyValueContainer()
{ {
} }
PropertyValueContainer::PropertyValueContainer(qint32 instanceId, const QString &name, const QVariant &value, const QString &dynamicTypeName) PropertyValueContainer::PropertyValueContainer(qint32 instanceId, const PropertyName &name, const QVariant &value, const TypeName &dynamicTypeName)
: m_instanceId(instanceId), : m_instanceId(instanceId),
m_name(name), m_name(name),
m_value(value), m_value(value),
...@@ -49,7 +49,7 @@ qint32 PropertyValueContainer::instanceId() const ...@@ -49,7 +49,7 @@ qint32 PropertyValueContainer::instanceId() const
return m_instanceId; return m_instanceId;
} }
QString PropertyValueContainer::name() const PropertyName PropertyValueContainer::name() const
{ {
return m_name; return m_name;
} }
...@@ -64,7 +64,7 @@ bool PropertyValueContainer::isDynamic() const ...@@ -64,7 +64,7 @@ bool PropertyValueContainer::isDynamic() const
return !m_dynamicTypeName.isEmpty(); return !m_dynamicTypeName.isEmpty();
} }
QString PropertyValueContainer::dynamicTypeName() const TypeName PropertyValueContainer::dynamicTypeName() const
{ {
return m_dynamicTypeName; return m_dynamicTypeName;
} }
......
...@@ -35,8 +35,9 @@ ...@@ -35,8 +35,9 @@
#include <QVariant> #include <QVariant>
#include <QString> #include <QString>
namespace QmlDesigner { #include "nodeinstanceglobal.h"
namespace QmlDesigner {
class PropertyValueContainer class PropertyValueContainer
{ {
...@@ -44,19 +45,19 @@ class PropertyValueContainer ...@@ -44,19 +45,19 @@ class PropertyValueContainer
public: public:
PropertyValueContainer(); PropertyValueContainer();
PropertyValueContainer(qint32 instanceId, const QString &name, const QVariant &value, const QString &dynamicTypeName); PropertyValueContainer(qint32 instanceId, const PropertyName &name, const QVariant &value, const TypeName &dynamicTypeName);
qint32 instanceId() const; qint32 instanceId() const;
QString name() const; PropertyName name() const;
QVariant value() const; QVariant value() const;
bool isDynamic() const; bool isDynamic() const;
QString dynamicTypeName() const; TypeName dynamicTypeName() const;
private: private:
qint32 m_instanceId; qint32 m_instanceId;
QString m_name; PropertyName m_name;
QVariant m_value; QVariant m_value;
QString m_dynamicTypeName; TypeName m_dynamicTypeName;
}; };
QDataStream &operator<<(QDataStream &out, const PropertyValueContainer &container); QDataStream &operator<<(QDataStream &out, const PropertyValueContainer &container);
......
...@@ -42,9 +42,9 @@ ReparentContainer::ReparentContainer() ...@@ -42,9 +42,9 @@ ReparentContainer::ReparentContainer()
ReparentContainer::ReparentContainer(qint32 instanceId, ReparentContainer::ReparentContainer(qint32 instanceId,
qint32 oldParentInstanceId, qint32 oldParentInstanceId,
const QString &oldParentProperty, const PropertyName &oldParentProperty,
qint32 newParentInstanceId, qint32 newParentInstanceId,
const QString &newParentProperty) const PropertyName &newParentProperty)
: m_instanceId(instanceId), : m_instanceId(instanceId),
m_oldParentInstanceId(oldParentInstanceId), m_oldParentInstanceId(oldParentInstanceId),
m_oldParentProperty(oldParentProperty), m_oldParentProperty(oldParentProperty),
...@@ -63,7 +63,7 @@ qint32 ReparentContainer::oldParentInstanceId() const ...@@ -63,7 +63,7 @@ qint32 ReparentContainer::oldParentInstanceId() const
return m_oldParentInstanceId; return m_oldParentInstanceId;
} }
QString ReparentContainer::oldParentProperty() const PropertyName ReparentContainer::oldParentProperty() const
{ {
return m_oldParentProperty; return m_oldParentProperty;
} }
...@@ -73,7 +73,7 @@ qint32 ReparentContainer::newParentInstanceId() const ...@@ -73,7 +73,7 @@ qint32 ReparentContainer::newParentInstanceId() const
return m_newParentInstanceId; return m_newParentInstanceId;
} }
QString ReparentContainer::newParentProperty() const PropertyName ReparentContainer::newParentProperty() const
{ {
return m_newParentProperty; return m_newParentProperty;
} }
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <QString> #include <QString>
#include <QDataStream> #include <QDataStream>
#include "nodeinstanceglobal.h"
namespace QmlDesigner { namespace QmlDesigner {
class ReparentContainer class ReparentContainer
...@@ -43,22 +45,22 @@ public: ...@@ -43,22 +45,22 @@ public:
ReparentContainer(); ReparentContainer();
ReparentContainer(qint32 instanceId, ReparentContainer(qint32 instanceId,
qint32 oldParentInstanceId, qint32 oldParentInstanceId,
const QString &oldParentProperty, const PropertyName &oldParentProperty,
qint32 newParentInstanceId, qint32 newParentInstanceId,
const QString &newParentProperty); const PropertyName &newParentProperty);
qint32 instanceId() const; qint32 instanceId() const;
qint32 oldParentInstanceId() const; qint32 oldParentInstanceId() const;
QString oldParentProperty() const; PropertyName oldParentProperty() const;
qint32 newParentInstanceId() const; qint32 newParentInstanceId() const;
QString newParentProperty() const; PropertyName newParentProperty() const;
private: private:
qint32 m_instanceId; qint32 m_instanceId;
qint32 m_oldParentInstanceId; qint32 m_oldParentInstanceId;
QString m_oldParentProperty; PropertyName m_oldParentProperty;
qint32 m_newParentInstanceId; qint32 m_newParentInstanceId;
QString m_newParentProperty; PropertyName m_newParentProperty;
}; };
QDataStream &operator<<(QDataStream &out, const ReparentContainer &container); QDataStream &operator<<(QDataStream &out, const ReparentContainer &container);
......
INCLUDEPATH += $$PWD/ INCLUDEPATH += $$PWD/
HEADERS += $$PWD/nodeinstanceclientinterface.h HEADERS += $$PWD/nodeinstanceclientinterface.h
HEADERS += $$PWD/interfaces/nodeinstanceglobal.h
HEADERS += $$PWD/nodeinstanceserverinterface.h HEADERS += $$PWD/nodeinstanceserverinterface.h
HEADERS += $$PWD/commondefines.h HEADERS += $$PWD/commondefines.h
......
#ifndef NODEINSTANCEGLOBAL_H
#define NODEINSTANCEGLOBAL_H
namespace QmlDesigner {
typedef QByteArray PropertyName;
typedef QList<PropertyName> PropertyNameList;
typedef QByteArray TypeName;
}
#endif // NODEINSTANCEGLOBAL_H
...@@ -55,7 +55,7 @@ BehaviorNodeInstance::Pointer BehaviorNodeInstance::create(QObject *object) ...@@ -55,7 +55,7 @@ BehaviorNodeInstance::Pointer BehaviorNodeInstance::create(QObject *object)
return instance; return instance;
} }
void BehaviorNodeInstance::setPropertyVariant(const QString &name, const QVariant &value) void BehaviorNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value)
{ {
if (name == "enabled") if (name == "enabled")
return; return;
...@@ -63,7 +63,7 @@ void BehaviorNodeInstance::setPropertyVariant(const QString &name, const QVarian ...@@ -63,7 +63,7 @@ void BehaviorNodeInstance::setPropertyVariant(const QString &name, const QVarian
ObjectNodeInstance::setPropertyVariant(name, value); ObjectNodeInstance::setPropertyVariant(name, value);
} }
void BehaviorNodeInstance::setPropertyBinding(const QString &name, const QString &expression) void BehaviorNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression)
{ {
if (name == "enabled") if (name == "enabled")
return; return;
...@@ -71,7 +71,7 @@ void BehaviorNodeInstance::setPropertyBinding(const QString &name, const QString ...@@ -71,7 +71,7 @@ void BehaviorNodeInstance::setPropertyBinding(const QString &name, const QString
ObjectNodeInstance::setPropertyBinding(name, expression); ObjectNodeInstance::setPropertyBinding(name, expression);
} }
QVariant BehaviorNodeInstance::property(const QString &name) const QVariant BehaviorNodeInstance::property(const PropertyName &name) const
{ {
if (name == "enabled") if (name == "enabled")
return QVariant::fromValue(m_isEnabled); return QVariant::fromValue(m_isEnabled);
...@@ -79,7 +79,7 @@ QVariant BehaviorNodeInstance::property(const QString &name) const ...@@ -79,7 +79,7 @@ QVariant BehaviorNodeInstance::property(const QString &name) const
return ObjectNodeInstance::property(name); return ObjectNodeInstance::property(name);
} }
void BehaviorNodeInstance::resetProperty(const QString &name) void BehaviorNodeInstance::resetProperty(const PropertyName &name)
{ {
if (name == "enabled") if (name == "enabled")
m_isEnabled = true; m_isEnabled = true;
......
...@@ -45,12 +45,12 @@ public: ...@@ -45,12 +45,12 @@ public:
static Pointer create(QObject *objectToBeWrapped); static Pointer create(QObject *objectToBeWrapped);
void setPropertyVariant(const QString &name, const QVariant &value); void setPropertyVariant(const PropertyName &name, const QVariant &value);
void setPropertyBinding(const QString &name, const QString &expression); void setPropertyBinding(const PropertyName &name, const QString &expression);
QVariant property(const QString &name) const; QVariant property(const PropertyName &name) const;
void resetProperty(const QString &name); void resetProperty(const PropertyName &name);
private: private:
bool m_isEnabled; bool m_isEnabled;
......
...@@ -120,7 +120,7 @@ NodeInstanceMetaObject *NodeInstanceMetaObject::createNodeInstanceMetaObject(con ...@@ -120,7 +120,7 @@ NodeInstanceMetaObject *NodeInstanceMetaObject::createNodeInstanceMetaObject(con
return new NodeInstanceMetaObject(nodeInstance, engine); return new NodeInstanceMetaObject(nodeInstance, engine);
} }
NodeInstanceMetaObject *NodeInstanceMetaObject::createNodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const QString &prefix, QQmlEngine *engine) NodeInstanceMetaObject *NodeInstanceMetaObject::createNodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const PropertyName &prefix, QQmlEngine *engine)
{ {
//Avoid setting up multiple NodeInstanceMetaObjects on the same QObject //Avoid setting up multiple NodeInstanceMetaObjects on the same QObject
QObjectPrivate *op = QObjectPrivate::get(nodeInstance->object()); QObjectPrivate *op = QObjectPrivate::get(nodeInstance->object());
...@@ -175,7 +175,7 @@ NodeInstanceMetaObject::NodeInstanceMetaObject(const ObjectNodeInstance::Pointer ...@@ -175,7 +175,7 @@ NodeInstanceMetaObject::NodeInstanceMetaObject(const ObjectNodeInstance::Pointer
} }
NodeInstanceMetaObject::NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const QString &prefix, QQmlEngine *engine) NodeInstanceMetaObject::NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const PropertyName &prefix, QQmlEngine *engine)
: QQmlVMEMetaObject(object, cacheForObject(object, engine), vMEMetaDataForObject(object)), : QQmlVMEMetaObject(object, cacheForObject(object, engine), vMEMetaDataForObject(object)),
m_nodeInstance(nodeInstance), m_nodeInstance(nodeInstance),
m_prefix(prefix), m_prefix(prefix),
...@@ -199,7 +199,7 @@ NodeInstanceMetaObject::~NodeInstanceMetaObject() ...@@ -199,7 +199,7 @@ NodeInstanceMetaObject::~NodeInstanceMetaObject()
void NodeInstanceMetaObject::createNewProperty(const QString &name) void NodeInstanceMetaObject::createNewProperty(const QString &name)
{ {
int id = createProperty(name.toLatin1(), 0); int id = createProperty(name.toUtf8(), 0);
setValue(id, QVariant()); setValue(id, QVariant());
Q_ASSERT(id >= 0); Q_ASSERT(id >= 0);
Q_UNUSED(id); Q_UNUSED(id);
......