Commit d204ee0b authored by Thomas Hartmann's avatar Thomas Hartmann

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>
(cherry picked from commit ee4bf638)
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent dd9b1687
......@@ -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_nodeSource(nodeSource), m_nodeSourceType(nodeSourceType), m_metaType(metaType)
{
m_type.replace(QLatin1Char('.'), QLatin1Char('/'));
m_type.replace('.', '/');
}
qint32 InstanceContainer::instanceId() const
......@@ -50,7 +50,7 @@ qint32 InstanceContainer::instanceId() const
return m_instanceId;
}
QString InstanceContainer::type() const
TypeName InstanceContainer::type() const
{
return m_type;
}
......
......@@ -34,6 +34,8 @@
#include <QString>
#include <QDataStream>
#include "nodeinstanceglobal.h"
namespace QmlDesigner {
class InstanceContainer;
......@@ -58,10 +60,10 @@ public:
};
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;
QString type() const;
TypeName type() const;
int majorNumber() const;
int minorNumber() const;
QString componentPath() const;
......@@ -71,7 +73,7 @@ public:
private:
qint32 m_instanceId;
QString m_type;
TypeName m_type;
qint32 m_majorNumber;
qint32 m_minorNumber;
QString m_componentPath;
......
......@@ -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_name(name),
m_dynamicTypeName(dynamicTypeName)
......@@ -48,7 +48,7 @@ qint32 PropertyAbstractContainer::instanceId() const
return m_instanceId;
}
QString PropertyAbstractContainer::name() const
PropertyName PropertyAbstractContainer::name() const
{
return m_name;
}
......
......@@ -34,6 +34,7 @@
#include <qmetatype.h>
#include <QString>
#include "nodeinstanceglobal.h"
namespace QmlDesigner {
......@@ -49,16 +50,16 @@ class PropertyAbstractContainer
friend QDataStream &operator>>(QDataStream &in, PropertyAbstractContainer &container);
public:
PropertyAbstractContainer();
PropertyAbstractContainer(qint32 instanceId, const QString &name, const QString &dynamicTypeName);
PropertyAbstractContainer(qint32 instanceId, const PropertyName &name, const QString &dynamicTypeName);
qint32 instanceId() const;
QString name() const;
PropertyName name() const;
bool isDynamic() const;
QString dynamicTypeName() const;
private:
qint32 m_instanceId;
QString m_name;
PropertyName m_name;
QString m_dynamicTypeName;
};
......
......@@ -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_name(name),
m_expression(expression),
......@@ -50,7 +50,7 @@ qint32 PropertyBindingContainer::instanceId() const
return m_instanceId;
}
QString PropertyBindingContainer::name() const
PropertyName PropertyBindingContainer::name() const
{
return m_name;
}
......@@ -65,7 +65,7 @@ bool PropertyBindingContainer::isDynamic() const
return !m_dynamicTypeName.isEmpty();
}
QString PropertyBindingContainer::dynamicTypeName() const
TypeName PropertyBindingContainer::dynamicTypeName() const
{
return m_dynamicTypeName;
}
......
......@@ -34,6 +34,7 @@
#include <qmetatype.h>
#include <QString>
#include "nodeinstanceglobal.h"
namespace QmlDesigner {
......@@ -43,19 +44,19 @@ class PropertyBindingContainer
public:
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;
QString name() const;
PropertyName name() const;
QString expression() const;
bool isDynamic() const;
QString dynamicTypeName() const;
TypeName dynamicTypeName() const;
private:
qint32 m_instanceId;
QString m_name;
PropertyName m_name;
QString m_expression;
QString m_dynamicTypeName;
TypeName m_dynamicTypeName;
};
QDataStream &operator<<(QDataStream &out, const PropertyBindingContainer &container);
......
......@@ -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_name(name),
m_value(value),
......@@ -49,7 +49,7 @@ qint32 PropertyValueContainer::instanceId() const
return m_instanceId;
}
QString PropertyValueContainer::name() const
PropertyName PropertyValueContainer::name() const
{
return m_name;
}
......@@ -64,7 +64,7 @@ bool PropertyValueContainer::isDynamic() const
return !m_dynamicTypeName.isEmpty();
}
QString PropertyValueContainer::dynamicTypeName() const
TypeName PropertyValueContainer::dynamicTypeName() const
{
return m_dynamicTypeName;
}
......
......@@ -35,8 +35,9 @@
#include <QVariant>
#include <QString>
namespace QmlDesigner {
#include "nodeinstanceglobal.h"
namespace QmlDesigner {
class PropertyValueContainer
{
......@@ -44,19 +45,19 @@ class PropertyValueContainer
public:
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;
QString name() const;
PropertyName name() const;
QVariant value() const;
bool isDynamic() const;
QString dynamicTypeName() const;
TypeName dynamicTypeName() const;
private:
qint32 m_instanceId;
QString m_name;
PropertyName m_name;
QVariant m_value;
QString m_dynamicTypeName;
TypeName m_dynamicTypeName;
};
QDataStream &operator<<(QDataStream &out, const PropertyValueContainer &container);
......
......@@ -42,9 +42,9 @@ ReparentContainer::ReparentContainer()
ReparentContainer::ReparentContainer(qint32 instanceId,
qint32 oldParentInstanceId,
const QString &oldParentProperty,
const PropertyName &oldParentProperty,
qint32 newParentInstanceId,
const QString &newParentProperty)
const PropertyName &newParentProperty)
: m_instanceId(instanceId),
m_oldParentInstanceId(oldParentInstanceId),
m_oldParentProperty(oldParentProperty),
......@@ -63,7 +63,7 @@ qint32 ReparentContainer::oldParentInstanceId() const
return m_oldParentInstanceId;
}
QString ReparentContainer::oldParentProperty() const
PropertyName ReparentContainer::oldParentProperty() const
{
return m_oldParentProperty;
}
......@@ -73,7 +73,7 @@ qint32 ReparentContainer::newParentInstanceId() const
return m_newParentInstanceId;
}
QString ReparentContainer::newParentProperty() const
PropertyName ReparentContainer::newParentProperty() const
{
return m_newParentProperty;
}
......
......@@ -34,6 +34,8 @@
#include <QString>
#include <QDataStream>
#include "nodeinstanceglobal.h"
namespace QmlDesigner {
class ReparentContainer
......@@ -43,22 +45,22 @@ public:
ReparentContainer();
ReparentContainer(qint32 instanceId,
qint32 oldParentInstanceId,
const QString &oldParentProperty,
const PropertyName &oldParentProperty,
qint32 newParentInstanceId,
const QString &newParentProperty);
const PropertyName &newParentProperty);
qint32 instanceId() const;
qint32 oldParentInstanceId() const;
QString oldParentProperty() const;
PropertyName oldParentProperty() const;
qint32 newParentInstanceId() const;
QString newParentProperty() const;
PropertyName newParentProperty() const;
private:
qint32 m_instanceId;
qint32 m_oldParentInstanceId;
QString m_oldParentProperty;
PropertyName m_oldParentProperty;
qint32 m_newParentInstanceId;
QString m_newParentProperty;
PropertyName m_newParentProperty;
};
QDataStream &operator<<(QDataStream &out, const ReparentContainer &container);
......
INCLUDEPATH += $$PWD/
HEADERS += $$PWD/nodeinstanceclientinterface.h
HEADERS += $$PWD/interfaces/nodeinstanceglobal.h
HEADERS += $$PWD/nodeinstanceserverinterface.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)
return instance;
}
void BehaviorNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
void BehaviorNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value)
{
if (name == "enabled")
return;
......@@ -63,7 +63,7 @@ void BehaviorNodeInstance::setPropertyVariant(const QString &name, const QVarian
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")
return;
......@@ -71,7 +71,7 @@ void BehaviorNodeInstance::setPropertyBinding(const QString &name, const QString
ObjectNodeInstance::setPropertyBinding(name, expression);
}
QVariant BehaviorNodeInstance::property(const QString &name) const
QVariant BehaviorNodeInstance::property(const PropertyName &name) const
{
if (name == "enabled")
return QVariant::fromValue(m_isEnabled);
......@@ -79,7 +79,7 @@ QVariant BehaviorNodeInstance::property(const QString &name) const
return ObjectNodeInstance::property(name);
}
void BehaviorNodeInstance::resetProperty(const QString &name)
void BehaviorNodeInstance::resetProperty(const PropertyName &name)
{
if (name == "enabled")
m_isEnabled = true;
......
......@@ -45,12 +45,12 @@ public:
static Pointer create(QObject *objectToBeWrapped);
void setPropertyVariant(const QString &name, const QVariant &value);
void setPropertyBinding(const QString &name, const QString &expression);
void setPropertyVariant(const PropertyName &name, const QVariant &value);
void setPropertyBinding(const PropertyName &name, const QString &expression);
QVariant property(const QString &name) const;
void resetProperty(const QString &name);
QVariant property(const PropertyName &name) const;
void resetProperty(const PropertyName &name);
private:
bool m_isEnabled;
......
......@@ -120,7 +120,7 @@ NodeInstanceMetaObject *NodeInstanceMetaObject::createNodeInstanceMetaObject(con
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
QObjectPrivate *op = QObjectPrivate::get(nodeInstance->object());
......@@ -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)),
m_nodeInstance(nodeInstance),
m_prefix(prefix),
......@@ -199,7 +199,7 @@ NodeInstanceMetaObject::~NodeInstanceMetaObject()
void NodeInstanceMetaObject::createNewProperty(const QString &name)
{
int id = createProperty(name.toLatin1(), 0);
int id = createProperty(name.toUtf8(), 0);
setValue(id, QVariant());
Q_ASSERT(id >= 0);
Q_UNUSED(id);
......
......@@ -35,7 +35,10 @@
#include <private/qqmlopenmetaobject_p.h>
#include <private/qqmlvmemetaobject_p.h>
#include "nodeinstanceglobal.h"
namespace QmlDesigner {
namespace Internal {
class ObjectNodeInstance;
......@@ -48,13 +51,13 @@ class NodeInstanceMetaObject : public QQmlVMEMetaObject
{
public:
static NodeInstanceMetaObject *createNodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QQmlEngine *engine);
static NodeInstanceMetaObject *createNodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const QString &prefix, QQmlEngine *engine);
static NodeInstanceMetaObject *createNodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const PropertyName &prefix, QQmlEngine *engine);
~NodeInstanceMetaObject();
void createNewProperty(const QString &name);
protected:
NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QQmlEngine *engine);
NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const QString &prefix, QQmlEngine *engine);
NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const PropertyName &prefix, QQmlEngine *engine);
int openMetaCall(QMetaObject::Call _c, int _id, void **_a);
int metaCall(QMetaObject::Call _c, int _id, void **_a);
......@@ -93,7 +96,7 @@ private:
void init(QObject *, QQmlEngine *engine);
ObjectNodeInstanceWeakPointer m_nodeInstance;
QString m_prefix;
PropertyName m_prefix;
QPointer<QQmlContext> m_context;
QQmlOpenMetaObjectType *m_type;
QScopedPointer<MetaPropertyData> m_data;
......
......@@ -68,9 +68,9 @@ class NodeInstanceServer : public NodeInstanceServerInterface
{
Q_OBJECT
public:
typedef QPair<QPointer<QObject>, QString> ObjectPropertyPair;
typedef QPair<QPointer<QObject>, PropertyName> ObjectPropertyPair;
typedef QPair<qint32, QString> IdPropertyPair;
typedef QPair<ServerNodeInstance, QString> InstancePropertyPair;
typedef QPair<ServerNodeInstance, PropertyName> InstancePropertyPair;
typedef QPair<QString, QPointer<QObject> > DummyPair;
explicit NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
......@@ -107,8 +107,8 @@ public:
QFileSystemWatcher *fileSystemWatcher();
QFileSystemWatcher *dummydataFileSystemWatcher();
Internal::ChildrenChangeEventFilter *childrenChangeEventFilter() const;
void addFilePropertyToFileSystemWatcher(QObject *object, const QString &propertyName, const QString &path);
void removeFilePropertyFromFileSystemWatcher(QObject *object, const QString &propertyName, const QString &path);
void addFilePropertyToFileSystemWatcher(QObject *object, const PropertyName &propertyName, const QString &path);
void removeFilePropertyFromFileSystemWatcher(QObject *object, const PropertyName &propertyName, const QString &path);
QUrl fileUrl() const;
......@@ -118,7 +118,7 @@ public:
ServerNodeInstance rootNodeInstance() const;
void notifyPropertyChange(qint32 instanceid, const QString &propertyName);
void notifyPropertyChange(qint32 instanceid, const PropertyName &propertyName);
QStringList imports() const;
QObject *dummyContextObject() const;
......
......@@ -53,7 +53,7 @@ void NodeInstanceSignalSpy::setObjectNodeInstance(const ObjectNodeInstance::Poin
}
void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString &prefix)
void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const PropertyName &prefix)
{
if (m_registeredObjectList.contains(spiedObject)) // prevent cycles
return;
......@@ -70,7 +70,7 @@ void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString &
&& QQmlMetaType::isQObject(metaProperty.userType())) {
QObject *propertyObject = QQmlMetaType::toQObject(metaProperty.read(spiedObject));
if (propertyObject)
registerObject(propertyObject, prefix + metaProperty.name() + QLatin1Char('.'));
registerObject(propertyObject, prefix + metaProperty.name() + '.');
} else if (metaProperty.hasNotifySignal()) {
QMetaMethod metaMethod = metaProperty.notifySignal();
bool isConnecting = QMetaObject::connect(spiedObject, metaMethod.methodIndex(), this, methodeOffset, Qt::DirectConnection);
......@@ -87,7 +87,7 @@ void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString &
&& QLatin1String(metaProperty.name()) != QLatin1String("parent")) {
QObject *propertyObject = QQmlMetaType::toQObject(metaProperty.read(spiedObject));
if (propertyObject)
registerObject(propertyObject, prefix + metaProperty.name() + QLatin1Char('/'));
registerObject(propertyObject, prefix + metaProperty.name() + '/');
}
// search recursive in objects list
......@@ -100,7 +100,7 @@ void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString &
for (int i = 0; i < list.count(); i++) {
QObject *propertyObject = list.at(i);
if (propertyObject)
registerObject(propertyObject, prefix + metaProperty.name() + QLatin1Char('/'));
registerObject(propertyObject, prefix + metaProperty.name() + '/');
}
}
}
......
......@@ -34,7 +34,10 @@
#include <QHash>
#include <QSharedPointer>
#include "nodeinstanceglobal.h"
namespace QmlDesigner {
namespace Internal {
class ObjectNodeInstance;
......@@ -51,11 +54,11 @@ public:
virtual int qt_metacall(QMetaObject::Call, int, void **);
protected:
void registerObject(QObject *spiedObject, const QString &prefix = QString());
void registerObject(QObject *spiedObject, const PropertyName &prefix = PropertyName());
private:
int methodeOffset;
QHash<int, QString> m_indexPropertyHash;
QHash<int, PropertyName> m_indexPropertyHash;
QObjectList m_registeredObjectList;
ObjectNodeInstanceWeakPointer m_objectNodeInstance;
};
......
......@@ -90,7 +90,7 @@ public:
Pointer parentInstance() const;
virtual void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const QString &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const QString &newParentProperty);
virtual void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty);