Commit 9242b8e5 authored by Wouter's avatar Wouter

Move away from QObject-based data classes

Which also gets rid of the QProperties. Makes inheritance easier.
parent 74086bb8
......@@ -21,7 +21,6 @@
#include "lib/metacode/classmember.h"
#include "lib/metacode/method.h"
#include "lib/metacode/property.h"
#include "lib/metacode/qproperty.h"
#include "lib/metacode/constructor.h"
#include "lib/metacode/innertype.h"
#include "lib/metacode/notification.h"
......@@ -75,8 +74,6 @@ Introspector::Introspector(QObject *parent)
qRegisterMetaType<QList<Method*>>();
qRegisterMetaType<Property*>();
qRegisterMetaType<QList<Property*>>();
qRegisterMetaType<QProperty*>();
qRegisterMetaType<QList<QProperty*>>();
qRegisterMetaType<InnerType*>();
qRegisterMetaType<QList<InnerType*>>();
qRegisterMetaType<Notification*>();
......@@ -762,7 +759,7 @@ Class *Introspector::introspectObject(const QString& id, const QVariantMap& data
namespaces.removeLast();
}
Class *result = new Class(namespaces, makeIdentifier(id), Type::Local | Type::Introspected, m_typeRegistry);
result->setIsQObject(containerClass == 0 || !introspectAsNested);
result->setIsQObject(false /*containerClass == 0 || !introspectAsNested*/);
result->setSourceId(id);
if (containerClass) {
......@@ -904,13 +901,7 @@ Property *Introspector::introspectProperty(const QString& id, const QVariantMap&
}
Property *member;
if (parent->isQObject()) {
// TODO This may have to be more restricted due to types and all
member = new QProperty(finalId, reference, Type::Public, id, parent);
}
else {
member = new Property(finalId, reference, Type::Public, id, parent);
}
member = new Property(finalId, reference, Type::Public, id, parent);
// Apply default value
if (data.contains("default")) {
......
......@@ -13,7 +13,6 @@ set(libMetacode_SRCS
initializer.cpp
field.cpp
property.cpp
qproperty.cpp
notification.cpp
array.cpp
wrappertype.cpp
......
......@@ -28,7 +28,6 @@
#include "lib/metacode/constructor.h"
#include "lib/metacode/innertype.h"
#include "lib/metacode/property.h"
#include "lib/metacode/qproperty.h"
using namespace QJsonIntrospect;
......@@ -128,11 +127,6 @@ QList< Property* > Class::properties() const
return membersSet<Property>();
}
QList< QProperty* > Class::qproperties() const
{
return membersSet<QProperty>();
}
void Class::addMember(ClassMember* member)
{
member->setParent(this);
......
......@@ -35,7 +35,6 @@ class Field;
class Method;
class Constructor;
class Property;
class QProperty;
class InnerType;
class TypeRegistry;
......@@ -55,7 +54,6 @@ class Class : public Type
Q_PROPERTY(QList<QJsonIntrospect::Method* > methods READ methods STORED false)
Q_PROPERTY(QList<QJsonIntrospect::Constructor* > constructors READ constructors STORED false)
Q_PROPERTY(QList<QJsonIntrospect::Property *> properties READ properties STORED false)
Q_PROPERTY(QList<QJsonIntrospect::QProperty *> qproperties READ qproperties STORED false)
Q_PROPERTY(QList<QJsonIntrospect::InnerType *> innerTypes READ innerTypes STORED false)
Q_PROPERTY(QString sourceId READ sourceId WRITE setSourceId);
......@@ -105,7 +103,6 @@ public:
QList< QJsonIntrospect::Method* > methods() const;
QList< QJsonIntrospect::Constructor* > constructors() const;
QList< QJsonIntrospect::Property* > properties() const;
QList< QJsonIntrospect::QProperty* > qproperties() const;
QList< QJsonIntrospect::InnerType* > innerTypes() const;
bool isQObject() const;
......
/*
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 2012 Cheetah <cheetah@thesimszone.co.uk>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lib/metacode/qproperty.h"
#include "lib/metacode/method.h"
using namespace QJsonIntrospect;
QProperty::QProperty(const QString& name, Class* parent)
: Property(name, parent)
{
init();
}
QProperty::QProperty(const QString& name, const QString& type, Class* parent)
: Property(name, type, parent)
{
init();
}
QProperty::QProperty(const QString& name, const QString& type, Type::ProtectionLevel protectionLevel, Class* parent)
: Property(name, type, protectionLevel, parent)
{
init(protectionLevel);
}
QProperty::QProperty(const QString& name, const TypeReference& type, Class* parent)
: Property(name, type, parent)
{
init();
}
QProperty::QProperty(const QString& name, const TypeReference& type, Type::ProtectionLevel protectionLevel, Class* parent)
: Property(name, type, protectionLevel, parent)
{
init(protectionLevel);
}
QProperty::QProperty(const QString& name, const QString& type, Type::ProtectionLevel protectionLevel, const QString& originalName, Class* parent)
: Property(name, type, protectionLevel, originalName, parent)
{
init(protectionLevel);
}
QProperty::QProperty(const QString& name, const TypeReference& type, Type::ProtectionLevel protectionLevel, const QString& originalName, Class* parent)
: Property(name, type, protectionLevel, originalName, parent)
{
init(protectionLevel);
}
void QProperty::init(Type::ProtectionLevel protection)
{
switch(protection)
{
default:
case Type::Public:
case Type::PublicSlot:
setSetterProtection(Type::PublicSlot);
break;
case Type::Protected:
case Type::ProtectedSlot:
setSetterProtection(Type::ProtectedSlot);
break;
case Type::Private:
case Type::PrivateSlot:
setSetterProtection(Type::PrivateSlot);
break;
}
Property::setQProperty(true);
}
void QProperty::setQProperty(bool isQProperty)
{
// Do nothing - not supported
}
bool QProperty::isQProperty() const
{
return true;
}
#include "moc_qproperty.cpp"
/*
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 2012 Cheetah <cheetah@thesimszone.co.uk>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef QJSONINTROSPECT_QPROPERTY_H
#define QJSONINTROSPECT_QPROPERTY_H
#include "lib/metacode/property.h"
namespace QJsonIntrospect {
class QProperty : public Property
{
Q_OBJECT
private:
void init(Type::ProtectionLevel protection = Type::Public);
public slots:
virtual void setQProperty(bool isQProperty);
public:
explicit QProperty(const QString& name, Class* parent);
explicit QProperty(const QString& name, const QString& type, Class* parent);
explicit QProperty(const QString& name, const QString& type, Type::ProtectionLevel protectionLevel, Class* parent);
explicit QProperty(const QString& name, const QString& type, Type::ProtectionLevel protectionLevel, const QString &originalName, Class* parent);
explicit QProperty(const QString& name, const TypeReference& type, Class* parent);
explicit QProperty(const QString& name, const TypeReference& type, Type::ProtectionLevel protectionLevel, Class* parent);
explicit QProperty(const QString& name, const TypeReference& type, Type::ProtectionLevel protectionLevel, const QString &originalName, Class* parent);
virtual bool isQProperty() const;
};
}
Q_DECLARE_METATYPE(QJsonIntrospect::QProperty*)
Q_DECLARE_METATYPE(QList<QJsonIntrospect::QProperty*>)
#endif // QJSONINTROSPECT_QPROPERTY_H
......@@ -31,7 +31,7 @@
{{ member.body }}
}{% endif %};
{% endfilter %}
{% case "Field" "Property" "QProperty" %}
{% case "Field" "Property" %}
{% filter indent:0 %}
{{ member.type.signature }} {{ member.name }};
{% endfilter %}
......
Q_OBJECT
Q_CLASSINFO("Generated By", "{{ qjsonIntrospect.name }} {{ qjsonIntrospect.version }}")
{% for prop in class.qproperties %}
Q_PROPERTY({{ prop.type.type.fullName }} {{ prop.propertyName }} READ {{ prop.getter.name }}{% if prop.setter.name %} WRITE {{prop.setter.name}}{% endif %})
{% endfor %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment