commit f2bd88b8c1b479b1ecaceb3ea0c5e07d93f8370e
Author: Christian Ehringfeld <c.ehringfeld@t-online.de>
Date:   Sun Sep 27 21:09:06 2015 +0200

    init test models

diff --git a/tests/models.cpp b/tests/models.cpp
new file mode 100644
index 0000000..d29008d
--- /dev/null
+++ b/tests/models.cpp
@@ -0,0 +1,164 @@
+#include "models.h"
+
+Person::Person(QObject *parent): Entity(parent) {
+}
+Person::Person(QString firstName, QString familyName, Gender gender,
+               QString customPictureFileName, QString namePrefix, QString nickName,
+               QDate birthday, QObject *parent): Entity(parent) {
+    setFirstName(firstName);
+    setFamilyName(familyName);
+    setNamePrefix(namePrefix);
+    setNickName(nickName);
+    setBirthday(birthday);
+    setGender(gender);
+    setCustomPictureFileName(customPictureFileName);
+}
+
+const QHash<QString, CuteEntityManager::Relation> Person::getRelations() const {
+    auto hash = QHash<QString, CuteEntityManager::Relation>();
+    hash.insert("groups", CuteEntityManager::Relation("groups",
+                RelationType::MANY_TO_MANY,
+                QString("persons")));
+    hash.insert("maintainedGroups", CuteEntityManager::Relation("maintainedGroups",
+                RelationType::ONE_TO_MANY,
+                QString("leader")));
+    return hash;
+}
+
+QString Person::fullName(NameOrder nameOrder) const {
+    QString name = QString();
+    if (nameOrder == NameOrder::FAMILY_FIRST_NAME_ORDER) {
+        name += this->getFamilyName();
+        name += ", ";
+        if (!this->getNamePrefix().isEmpty()) {
+            name += this->getNamePrefix();
+            name += " ";
+        }
+        name += this->getFirstName();
+    } else {
+        name += this->getFirstName();
+        name += " ";
+        name += this->getFamilyName();
+        if (!this->getNamePrefix().isEmpty()) {
+            name += ", ";
+            name += this->getNamePrefix();
+        }
+    }
+    return name;
+}
+QString Person::getFirstName() const {
+    return firstName;
+}
+
+void Person::setFirstName(const QString &value) {
+    firstName = value;
+}
+QString Person::getFamilyName() const {
+    return familyName;
+}
+
+void Person::setFamilyName(const QString &value) {
+    familyName = value;
+}
+QString Person::getNamePrefix() const {
+    return namePrefix;
+}
+
+void Person::setNamePrefix(const QString &value) {
+    namePrefix = value;
+}
+
+QString Person::getNickName() const {
+    return nickName;
+}
+
+void Person::setNickName(const QString &value) {
+    nickName = value;
+}
+
+QDate Person::getBirthday() const {
+    return birthday;
+}
+
+void Person::setBirthday(const QDate &value) {
+    birthday = value;
+}
+
+Person::Gender Person::getGender() const {
+    return gender;
+}
+
+void Person::setGender(const Gender &value) {
+    gender = value;
+}
+
+QString Person::getCustomPictureFileName() const {
+    return customPictureFileName;
+}
+
+void Person::setCustomPictureFileName(const QString &value) {
+    customPictureFileName = value;
+}
+
+QList<QSharedPointer<Group> > Person::getGroups() const {
+    return groups;
+}
+
+void Person::setGroups(const QList<QSharedPointer<Group> > &value) {
+    groups = value;
+}
+
+void Person::addContact(Contact *contact) {
+    this->contacts.append(QSharedPointer<Contact>(contact));
+}
+
+void Person::addAddress(Address *address) {
+    this->addresses.append(QSharedPointer<Address>(address));
+}
+
+QList<QSharedPointer<Group> > Person::getMaintainedGroups() const {
+    return maintainedGroups;
+}
+
+void Person::setMaintainedGroups(const QList<QSharedPointer<Group> > &value) {
+    maintainedGroups = value;
+}
+
+Group::Group() : Entity() {
+}
+
+const QHash<QString, CuteEntityManager::Relation> Group::getRelations() const {
+    auto hash = QHash<QString, CuteEntityManager::Relation>();
+    hash.insert("persons", CuteEntityManager::Relation("persons",
+                RelationType::MANY_TO_MANY));
+    hash.insert("leader", CuteEntityManager::Relation("leader",
+                RelationType::MANY_TO_ONE));
+    return hash;
+}
+
+QString Group::getName() const {
+    return name;
+}
+
+void Group::setName(const QString &value) {
+    name = value;
+}
+
+QSharedPointer<Person> Group::getLeader() const {
+    return mainTeacher;
+}
+
+void Group::setLeader(const QSharedPointer<Person> &value) {
+    mainTeacher = value;
+}
+QList<QSharedPointer<Person> > Group::getPersons() const {
+    return persons;
+}
+
+void Group::setPersons(const QList<QSharedPointer<Person> > &value) {
+    persons = value;
+}
+
+
+
+
diff --git a/tests/models.h b/tests/models.h
new file mode 100644
index 0000000..3bc9055
--- /dev/null
+++ b/tests/models.h
@@ -0,0 +1,127 @@
+#ifndef MODELS_H
+#define MODELS_H
+
+#include <QDateTime>
+#include <QString>
+#include <QList>
+#include <QObject>
+#include <QDebug>
+#include "../../entitymanager/src/entity.h"
+
+using namespace CuteEntityManager;
+class Person: public Entity {
+    Q_OBJECT
+    Q_PROPERTY(QString firstName READ getFirstName WRITE setFirstName)
+    Q_PROPERTY(QString familyName READ getFamilyName WRITE setFamilyName)
+    Q_PROPERTY(QString namePrefix READ getNamePrefix WRITE setNamePrefix)
+    Q_PROPERTY(QString nickName READ getNickName WRITE setNickName)
+    Q_PROPERTY(QString customPictureFileName READ getCustomPictureFileName WRITE
+               setCustomPictureFileName)
+    Q_PROPERTY(QDate birthday READ getBirthday WRITE setBirthday)
+    Q_PROPERTY(Gender gender READ getGender WRITE setGender)
+    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};
+    Q_ENUM(Gender)
+    enum class NameOrder {FIRST_FAMILY_NAME_ORDER, FAMILY_FIRST_NAME_ORDER};
+    Q_ENUM(NameOrder)
+    Q_INVOKABLE explicit Person(QObject *parent = 0);
+    Person(QString firstName, QString familyName,
+           Gender gender = Gender::UNKNOWNGENDER,
+           QString customPictureFileName = QString(), QString namePrefix = QString(),
+           QString nickName = QString(), QDate birthday = QDate(), QObject *parent = 0);
+
+    virtual const QHash<QString, CuteEntityManager::Relation> getRelations() const override;
+
+    bool isPresent(QDateTime date = QDateTime::currentDateTime());
+    QString fullName(NameOrder nameOrder = NameOrder::FAMILY_FIRST_NAME_ORDER)
+    const;
+
+    QString getFirstName() const;
+    void setFirstName(const QString &value);
+
+    QString getFamilyName() const;
+    void setFamilyName(const QString &value);
+
+    QString getNamePrefix() const;
+    void setNamePrefix(const QString &value);
+
+    QString getNickName() const;
+    void setNickName(const QString &value);
+
+    QDate getBirthday() const;
+    void setBirthday(const QDate &value);
+
+    Gender getGender() const;
+    void setGender(const Gender &value);
+
+    QString getCustomPictureFileName() const;
+    void setCustomPictureFileName(const QString &value);
+
+    QList<QSharedPointer<Contact> > getContacts() const;
+    void setContacts(const QList<QSharedPointer<Contact> > &value);
+
+    QList<QSharedPointer<Address> > getAddresses() const;
+    void setAddresses(const QList<QSharedPointer<Address> > &value);
+
+    QList<QSharedPointer<Group> > getGroups() const;
+    void setGroups(const QList<QSharedPointer<Group> > &value);
+
+    void addContact(Contact *contact);
+    void addAddress(Address *address);
+
+    QList<QSharedPointer<Group> > getMaintainedGroups() const;
+    void setMaintainedGroups(const QList<QSharedPointer<Group> > &value);
+
+  protected:
+    QString firstName;
+    QString familyName;
+    QString namePrefix;
+    QString nickName;
+    QDate birthday;
+    Gender gender;
+    QString customPictureFileName;
+    QList <QSharedPointer<Contact>> contacts;
+    QList <QSharedPointer<Address>> addresses;
+    QList <QSharedPointer<Group>> groups;
+    QList <QSharedPointer<Group>> maintainedGroups;
+
+};
+
+class Person;
+class Relation;
+class Group: public CuteEntityManager::Entity {
+    Q_OBJECT
+    Q_PROPERTY(QList<QSharedPointer<Person>> persons READ getPersons WRITE
+               setPersons)
+    Q_PROPERTY(QString name READ getName WRITE setName)
+    Q_PROPERTY(QSharedPointer<Person> leader READ getLeader WRITE
+               setLeader)
+
+  public:
+    Q_INVOKABLE Group();
+    const QHash<QString, CuteEntityManager::Relation> getRelations() const override;
+
+    QString getName() const;
+    void setName(const QString &value);
+
+    QSharedPointer<Person> getLeader() const;
+    void setLeader(const QSharedPointer<Person> &value);
+
+    QList<QSharedPointer<Person> > getPersons() const;
+    void setPersons(const QList<QSharedPointer<Person> > &value);
+
+  protected:
+    QList<QSharedPointer<Person>> persons;
+    QSharedPointer<Person> leader;
+    QString name;
+};
+
+#endif // MODELS_H
