commit af84b9c49dc80f70ee77216012cb415cba778e7e
Author: Christian Ehringfeld <c.ehringfeld@t-online.de>
Date:   Fri Jul 24 18:11:51 2015 +0200

    example update

diff --git a/samples/example/models/address.cpp b/samples/example/models/address.cpp
index dec4d80..6530005 100644
--- a/samples/example/models/address.cpp
+++ b/samples/example/models/address.cpp
@@ -1,49 +1,72 @@
 #include "address.h"
+#include "pupil.h"
 
-Address::Address(QString label, QString street, QString postcode, QString city) {
-    m_label=label;
-    m_street=street;
-    m_postcode=postcode;
-    m_city=city;
+Address::Address(QString label, QString street, QString postcode,
+                 QString city) {
+    this->label = label;
+    this->street = street;
+    this->postcode = postcode;
+    this->city = city;
 }
-QString Address::label() const
-{
-    return m_label;
+
+QString Address::getLabel() const {
+    return label;
 }
 
-void Address::setLabel(const QString &label)
-{
-    m_label = label;
+void Address::setLabel(const QString &value) {
+    label = value;
 }
-QString Address::street() const
-{
-    return m_street;
+
+QString Address::getStreet() const {
+    return street;
 }
 
-void Address::setStreet(const QString &street)
-{
-    m_street = street;
+void Address::setStreet(const QString &value) {
+    street = value;
 }
-QString Address::postcode() const
-{
-    return m_postcode;
+
+QString Address::getPostcode() const {
+    return postcode;
 }
 
-void Address::setPostcode(const QString &postcode)
-{
-    m_postcode = postcode;
+void Address::setPostcode(const QString &value) {
+    postcode = value;
 }
-QString Address::city() const
-{
-    return m_city;
+
+QString Address::getCity() const {
+    return city;
 }
 
-void Address::setCity(const QString &city)
-{
-    m_city = city;
+void Address::setCity(const QString &value) {
+    city = value;
 }
 
+QList<QSharedPointer<Person> > Address::getPersons() const {
+    return persons;
+}
 
+void Address::setPersons(const QList<QSharedPointer<Person> > &value) {
+    persons = value;
+}
 
+const QHash<QString, CuteEntityManager::Relation> Address::getRelations()
+const {
+    auto hash = Entity::getRelations();
+    hash.insert("persons", CuteEntityManager::Relation("persons",
+                RelationType::MANY_TO_MANY,
+                QString("addresses")));
+    hash.insert("pupils", CuteEntityManager::Relation("pupils",
+                RelationType::MANY_TO_MANY,
+                QString("addresses")));
+    return hash;
+}
+
+QList<QSharedPointer<Pupil> > Address::getPupils() const {
+    return pupils;
+}
+
+void Address::setPupils(const QList<QSharedPointer<Pupil> > &value) {
+    pupils = value;
+}
 
 
diff --git a/samples/example/models/address.h b/samples/example/models/address.h
index 3033579..243d66c 100644
--- a/samples/example/models/address.h
+++ b/samples/example/models/address.h
@@ -2,40 +2,55 @@
 #define ADDRESS_H
 
 #include <QString>
-//#iclude "../../em/entitymanager/src/entity.h"
+#include <QHash>
 #include "entity.h"
 
-class Address: public CuteEntityManager::Entity
-{
+class Person;
+class Relation;
+class Pupil;
+class Address: public CuteEntityManager::Entity {
     Q_OBJECT
 
-    Q_PROPERTY(QString label READ label WRITE setLabel)
-    Q_PROPERTY(QString street READ street WRITE setStreet)
-    Q_PROPERTY(QString postcode READ postcode WRITE setPostcode)
-    Q_PROPERTY(QString city READ city WRITE setCity)
+    Q_PROPERTY(QString label READ getLabel WRITE setLabel)
+    Q_PROPERTY(QString street READ getStreet WRITE setStreet)
+    Q_PROPERTY(QString postcode READ getPostcode WRITE setPostcode)
+    Q_PROPERTY(QString city READ getCity WRITE setCity)
+    Q_PROPERTY(QList<QSharedPointer<Person>> persons READ
+               getPersons WRITE setPersons)
+    Q_PROPERTY(QList<QSharedPointer<Pupil>> pupils READ
+               getPupils WRITE setPupils)
 
-public:
+  public:
     Q_INVOKABLE Address() {}
     Address(QString label, QString street, QString postcode, QString city);
 
-    QString label() const;
-    void setLabel(const QString &label);
+    QString getLabel() const;
+    void setLabel(const QString &value);
 
-    QString street() const;
-    void setStreet(const QString &street);
+    QString getStreet() const;
+    void setStreet(const QString &value);
 
-    QString postcode() const;
-    void setPostcode(const QString &postcode);
+    QString getPostcode() const;
+    void setPostcode(const QString &value);
 
-    QString city() const;
-    void setCity(const QString &city);
+    QString getCity() const;
+    void setCity(const QString &value);
+
+    QList<QSharedPointer<Person> > getPersons() const;
+    void setPersons(const QList<QSharedPointer<Person> > &value);
+
+    const QHash<QString, CuteEntityManager::Relation> getRelations() const override;
+
+    QList<QSharedPointer<Pupil> > getPupils() const;
+    void setPupils(const QList<QSharedPointer<Pupil> > &value);
 
 protected:
-    // members
-    QString m_label;
-    QString m_street;
-    QString m_postcode;
-    QString m_city;
+    QString label;
+    QString street;
+    QString postcode;
+    QString city;
+    QList<QSharedPointer<Person>> persons;
+    QList<QSharedPointer<Pupil>> pupils;
 };
 
 #endif // ADDRESS_H
diff --git a/samples/example/models/contact.cpp b/samples/example/models/contact.cpp
index d950293..07a69b8 100644
--- a/samples/example/models/contact.cpp
+++ b/samples/example/models/contact.cpp
@@ -1,10 +1,24 @@
 #include "contact.h"
+#include "pupil.h"
 
 Contact::Contact(QString label, Category category, QString content) {
     this->label = label;
     this->category = category;
     this->content = content;
 }
+
+const QHash<QString, CuteEntityManager::Relation> Contact::getRelations()
+const {
+    auto hash = Entity::getRelations();
+    hash.insert("persons", CuteEntityManager::Relation("persons",
+                RelationType::MANY_TO_MANY,
+                QString("contacts")));
+    hash.insert("pupils", CuteEntityManager::Relation("pupils",
+                RelationType::MANY_TO_MANY,
+                QString("contacts")));
+    return hash;
+}
+
 QString Contact::getContent() const {
     return content;
 }
@@ -28,7 +42,18 @@ void Contact::setCategory(const Category &value) {
     category = value;
 }
 
+QList<QSharedPointer<Person> > Contact::getPersons() const {
+    return persons;
+}
 
+void Contact::setPersons(const QList<QSharedPointer<Person> > &value) {
+    persons = value;
+}
 
+QList<QSharedPointer<Pupil> > Contact::getPupils() const {
+    return pupils;
+}
 
-
+void Contact::setPupils(const QList<QSharedPointer<Pupil> > &value) {
+    pupils = value;
+}
diff --git a/samples/example/models/contact.h b/samples/example/models/contact.h
index b7d9cca..8578611 100644
--- a/samples/example/models/contact.h
+++ b/samples/example/models/contact.h
@@ -4,18 +4,27 @@
 #include <QString>
 #include "entity.h"
 
+class Relation;
+class Person;
+class Pupil;
 class Contact: public CuteEntityManager::Entity {
     Q_OBJECT
 
     Q_PROPERTY(QString content READ getContent WRITE setContent)
     Q_PROPERTY(Category category READ getCategory WRITE setCategory)
     Q_PROPERTY(QString label READ getLabel WRITE setLabel)
+    Q_PROPERTY(QList<QSharedPointer<Person>> persons READ
+               getPersons WRITE setPersons)
+    Q_PROPERTY(QList<QSharedPointer<Pupil>> pupils READ
+               getPupils WRITE setPupils)
 
   public:
     enum Category {EMAIL, MOBILE, LANDLINE, MESSENGER, EXTRA} ;
     Q_ENUM(Category)
     Q_INVOKABLE Contact() {}
     Contact(QString label, Category category, QString content);
+    const QHash<QString, CuteEntityManager::Relation> getRelations() const
+    override;
 
     QString getContent() const;
     void setContent(const QString &value);
@@ -26,10 +35,18 @@ class Contact: public CuteEntityManager::Entity {
     Category getCategory() const;
     void setCategory(const Category &value);
 
+    QList<QSharedPointer<Person> > getPersons() const;
+    void setPersons(const QList<QSharedPointer<Person> > &value);
+
+    QList<QSharedPointer<Pupil> > getPupils() const;
+    void setPupils(const QList<QSharedPointer<Pupil> > &value);
+
 protected:
     QString content;
     Category category;
     QString label;
+    QList<QSharedPointer<Person>> persons;
+    QList<QSharedPointer<Pupil>> pupils;
 };
 
 #endif // CONTACT_H
diff --git a/samples/example/models/group.cpp b/samples/example/models/group.cpp
index 656585f..e1ba588 100644
--- a/samples/example/models/group.cpp
+++ b/samples/example/models/group.cpp
@@ -1,6 +1,5 @@
 #include "group.h"
-#include "person.h"
-#include "contact.h"
+#include "pupil.h"
 #include <QDebug>
 
 Group::Group() : Entity() {
@@ -9,8 +8,10 @@ Group::Group() : Entity() {
 
 const QHash<QString, CuteEntityManager::Relation> Group::getRelations() const {
     auto hash = QHash<QString, CuteEntityManager::Relation>();
-    hash.insert("pupils", CuteEntityManager::Relation("pupils", RelationType::MANY_TO_MANY));
-    hash.insert("persons", CuteEntityManager::Relation("persons", RelationType::MANY_TO_MANY));
+    hash.insert("pupils", CuteEntityManager::Relation("pupils",
+                RelationType::MANY_TO_MANY));
+    hash.insert("persons", CuteEntityManager::Relation("persons",
+                RelationType::MANY_TO_MANY));
     hash.insert("mainTeacher", CuteEntityManager::Relation("mainTeacher",
                 RelationType::MANY_TO_ONE));
     return hash;
diff --git a/samples/example/models/group.h b/samples/example/models/group.h
index 5e9d9d3..03c3980 100644
--- a/samples/example/models/group.h
+++ b/samples/example/models/group.h
@@ -1,13 +1,7 @@
 #ifndef GROUP_H
 #define GROUP_H
-
 #include "entity.h"
-#include "contact.h"
-#include "pupil.h"
 #include <QDebug>
-//#include <QQuickView>
-
-
 
 class Teacher;
 class Person;
@@ -18,14 +12,15 @@ using namespace CuteEntityManager;
 class Group: public CuteEntityManager::Entity {
     Q_OBJECT
     Q_PROPERTY(QList<QSharedPointer<Pupil>> pupils READ getPupils WRITE setPupils)
-    Q_PROPERTY(QList<QSharedPointer<Person>> persons READ getPersons WRITE setPersons)
+    Q_PROPERTY(QList<QSharedPointer<Person>> persons READ getPersons WRITE
+               setPersons)
     Q_PROPERTY(QString name READ getName WRITE setName)
     Q_PROPERTY(QSharedPointer<Person> mainTeacher READ getMainTeacher WRITE
                setMainTeacher)
 
   public:
     Q_INVOKABLE Group();
-    virtual const QHash<QString, CuteEntityManager::Relation> getRelations() const;
+    const QHash<QString, CuteEntityManager::Relation> getRelations() const override;
 
     QString getName() const;
     void setName(const QString &value);
@@ -42,7 +37,7 @@ class Group: public CuteEntityManager::Entity {
     void addPerson(Person *person);
     void setPersons(const QList<QSharedPointer<Person> > &value);
 
-protected:
+  protected:
     QList<QSharedPointer<Pupil>> pupils;
     QList<QSharedPointer<Person>> persons;
     QSharedPointer<Person> mainTeacher;
diff --git a/samples/example/models/person.cpp b/samples/example/models/person.cpp
index 700be35..f1d69e8 100644
--- a/samples/example/models/person.cpp
+++ b/samples/example/models/person.cpp
@@ -1,4 +1,6 @@
 #include "person.h"
+#include "contact.h"
+#include "address.h"
 
 Person::Person(QObject *parent): Entity(parent) {
 }
@@ -22,6 +24,10 @@ const QHash<QString, CuteEntityManager::Relation> Person::getRelations() const {
     hash.insert("maintainedGroups", CuteEntityManager::Relation("maintainedGroups",
                 RelationType::ONE_TO_MANY,
                 QString("mainTeacher")));
+    hash.insert("contacts", CuteEntityManager::Relation("contacts",
+                RelationType::MANY_TO_MANY));
+    hash.insert("addresses", CuteEntityManager::Relation("addresses",
+                RelationType::MANY_TO_MANY));
     return hash;
 }
 
diff --git a/samples/example/models/person.h b/samples/example/models/person.h
index 78b5ca4..8254c76 100644
--- a/samples/example/models/person.h
+++ b/samples/example/models/person.h
@@ -5,14 +5,14 @@
 #include <QString>
 #include <QList>
 #include <QObject>
-#include "contact.h"
-#include "address.h"
 #include <QAbstractListModel>
 #include <QDebug>
 #include "../../entitymanager/src/entity.h"
 
 using namespace CuteEntityManager;
 class Group;
+class Contact;
+class Address;
 
 class Person: public Entity {
     Q_OBJECT
@@ -27,7 +27,10 @@ class Person: public Entity {
     Q_PROPERTY(QList<QSharedPointer<Group>> groups READ getGroups WRITE setGroups)
     Q_PROPERTY(QList<QSharedPointer<Group>> maintainedGroups READ
                getMaintainedGroups WRITE setMaintainedGroups)
-
+    Q_PROPERTY(QList<QSharedPointer<Contact>> contacts READ getContacts WRITE
+               setContacts)
+    Q_PROPERTY(QList<QSharedPointer<Address>> addresses READ
+               getAddresses WRITE setAddresses)
 
   public:
     enum class Gender {MALE, FEMALE, UNKNOWNGENDER};
diff --git a/samples/example/models/pupil.cpp b/samples/example/models/pupil.cpp
index 5e855a6..b98bb2d 100644
--- a/samples/example/models/pupil.cpp
+++ b/samples/example/models/pupil.cpp
@@ -27,5 +27,13 @@ void Pupil::setLegalGuardianNote(const QString &value) {
     legalGuardianNote = value;
 }
 
+const QHash<QString, Relation> Pupil::getRelations() const {
+    auto hash = Person::getRelations();
+    hash.insert("groups", CuteEntityManager::Relation("groups",
+                RelationType::MANY_TO_MANY,
+                QString("pupils")));
+    return hash;
+}
+
 
 
diff --git a/samples/example/models/pupil.h b/samples/example/models/pupil.h
index 626bad3..6b9267c 100644
--- a/samples/example/models/pupil.h
+++ b/samples/example/models/pupil.h
@@ -15,6 +15,7 @@ class Pupil : public Person {
 
     QString getLegalGuardianNote() const;
     void setLegalGuardianNote(const QString &value);
+    virtual const QHash<QString, CuteEntityManager::Relation> getRelations() const;
 
     QString getForm() const;
     void setForm(const QString &value);
