Revision e7846d55
Von Sebastian Diel vor etwa 6 Jahren hinzugefügt
tests/em/em.pro | ||
---|---|---|
SOURCES += tst_em.cpp \
|
||
../models.cpp \
|
||
main.cpp \
|
||
tst_querybuilder.cpp
|
||
tst_querybuilder.cpp \
|
||
../model/testpupilchild.cpp \
|
||
../model/testpupilgrandchild.cpp \
|
||
../model/testpupilgreatgrandchild.cpp \
|
||
../model/testperson.cpp \
|
||
../model/testgroup.cpp \
|
||
../model/testpupil.cpp
|
||
DEFINES += SRCDIR=\\\"$$PWD/\\\"
|
||
|
||
HEADERS += \
|
||
../models.h \
|
||
tst_em.h \
|
||
tst_querybuilder.h
|
||
tst_querybuilder.h \
|
||
../model/testpupilchild.h \
|
||
../model/testpupilgrandchild.h \
|
||
../model/testpupilgreatgrandchild.h \
|
||
../model/testperson.h \
|
||
../model/testgroup.h \
|
||
../model/testpupil.h
|
tests/em/tst_em.cpp | ||
---|---|---|
#include "tst_em.h"
|
||
#include "../tests/model/testperson.h"
|
||
#include "../tests/model/testpupil.h"
|
||
#include "../tests/model/testpupilchild.h"
|
||
#include "../tests/model/testpupilgrandchild.h"
|
||
#include "../tests/model/testpupilgreatgrandchild.h"
|
||
#include "../tests/model/testgroup.h"
|
||
|
||
void EmTest::initTestCase() {
|
||
qSetGlobalQHashSeed(0);
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<Group>();
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<Person>();
|
||
CuteEntityManager::EntityInstanceFactory::registerClass<Article>();
|
||
... | ... | |
}
|
||
}
|
||
|
||
void EmTest::testChainedHeritageCreate() {
|
||
// QList<QSharedPointer<TestGroup>> groups;
|
||
// QList<QSharedPointer<TestPerson>> childListAAA;
|
||
// QList<QSharedPointer<TestPerson>> grandChildListBBB;
|
||
// QList<QSharedPointer<TestPerson>> greatGrandChildListCCC;
|
||
|
||
auto testPerson = QSharedPointer<TestPerson>(new TestPerson());
|
||
auto testPupil = QSharedPointer<TestPupil>(new TestPupil());
|
||
auto testPupilChild = QSharedPointer<TestPupilChild>(new TestPupilChild());
|
||
auto testPupilGrandChild = QSharedPointer<TestPupilGrandChild>(new TestPupilGrandChild());
|
||
auto testPupilGreatGrandChild = QSharedPointer<TestPupilGreatGrandChild>(new TestPupilGreatGrandChild());
|
||
|
||
QVERIFY(this->e->save(testPerson));
|
||
QVERIFY(this->e->save(testPupil));
|
||
QVERIFY(this->e->save(testPupilChild));
|
||
QVERIFY(this->e->save(testPupilGrandChild));
|
||
QVERIFY(this->e->save(testPupilGreatGrandChild));
|
||
|
||
auto tim = QSharedPointer<TestPupilGreatGrandChild>(new TestPupilGreatGrandChild());
|
||
// //set TestPerson's properties
|
||
// tim->setFirstName("Tim");
|
||
// tim->setFamilyName("Thaler");
|
||
// tim->setNickName("Timmy");
|
||
// tim->setBirthday(QDate(1973,3,8));
|
||
// tim->setGender(TestPerson::Gender::MALE);
|
||
// tim->setCustomPictureFileName("someFile.jpg");
|
||
|
||
// //set TestPupil's properties
|
||
// tim->setLegalGuardianNote("lost his parens, lives with stepmother");
|
||
// tim->setGroups(groups);
|
||
|
||
// //setTestPupilChild's properties
|
||
// tim->setChildPropertyString("childPropertyStringAAA");
|
||
// tim->setChildPropertyPersons(childListAAA);
|
||
|
||
// //setTestPupilGrandChild's properties
|
||
// tim->setGrandChildPropertyString("grandChildPropertyStringBBB");
|
||
// tim->setGrandChildPropertyPersons(grandChildListBBB);
|
||
|
||
// //setTestPupilGreatGrandChild's properties
|
||
// tim->setGreatGrandChildPropertyString("greatGrandChildPropertyStringCCC");
|
||
// tim->setGrandChildPropertyPersons(greatGrandChildListCCC);
|
||
|
||
QVERIFY(this->e->save(tim));
|
||
}
|
||
|
||
void EmTest::testChainedHeritageUpdate()
|
||
{
|
||
// auto albert = QSharedPointer<TestPupil> (new TestPupil());
|
||
// albert->setFirstName("Albert");
|
||
// albert->setFamilyName("Einstein");
|
||
// auto bette = QSharedPointer<TestPupil> (new TestPupil());
|
||
// bette->setFirstName("Bette");
|
||
// bette->setFamilyName("Middler");
|
||
// auto cassandra = QSharedPointer<TestPupil> (new TestPupil());
|
||
// cassandra ->setFirstName("Cassandra ");
|
||
// cassandra ->setFamilyName("Wilson");
|
||
// auto dean = QSharedPointer<TestPupil> (new TestPupil());
|
||
// dean ->setFirstName("Dean ");
|
||
// dean ->setFamilyName("Martin");
|
||
|
||
// auto group1 = QSharedPointer<TestGroup>(new TestGroup());
|
||
// group1->setName("group one");
|
||
// auto group2 = QSharedPointer<TestGroup>(new TestGroup());
|
||
// group1->setName("group two");
|
||
|
||
// QList<QSharedPointer<TestGroup>> groups;
|
||
// groups << group1;
|
||
// groups << group2;
|
||
|
||
// QList<QSharedPointer<TestPerson>> childListAAA;
|
||
// childListAAA << albert;
|
||
// childListAAA << bette;
|
||
// childListAAA << cassandra;
|
||
// childListAAA << dean;
|
||
|
||
// QList<QSharedPointer<TestPerson>> grandChildListBBB;
|
||
// grandChildListBBB << bette;
|
||
// grandChildListBBB << cassandra;
|
||
// grandChildListBBB << dean;
|
||
|
||
// QList<QSharedPointer<TestPerson>> greatGrandChildListCCC;
|
||
// greatGrandChildListCCC << cassandra;
|
||
// greatGrandChildListCCC << dean;
|
||
|
||
auto tim = QSharedPointer<TestPupilGreatGrandChild>(new TestPupilGreatGrandChild());
|
||
// //set TestPerson's properties
|
||
// tim->setFirstName("Tim");
|
||
// tim->setFamilyName("Thaler");
|
||
// tim->setNickName("Timmy");
|
||
// tim->setBirthday(QDate(1973,3,8));
|
||
// tim->setGender(TestPerson::Gender::MALE);
|
||
// tim->setCustomPictureFileName("someFile.jpg");
|
||
|
||
// //set TestPupil's properties
|
||
// tim->setLegalGuardianNote("lost his parens, lives with stepmother");
|
||
// tim->setGroups(groups);
|
||
|
||
// //setTestPupilChild's properties
|
||
// tim->setChildPropertyString("childPropertyStringAAA");
|
||
// tim->setChildPropertyPersons(childListAAA);
|
||
|
||
// //setTestPupilGrandChild's properties
|
||
// tim->setGrandChildPropertyString("grandChildPropertyStringBBB");
|
||
// tim->setGrandChildPropertyPersons(grandChildListBBB);
|
||
|
||
// //setTestPupilGreatGrandChild's properties
|
||
// tim->setGreatGrandChildPropertyString("greatGrandChildPropertyStringCCC");
|
||
// tim->setGrandChildPropertyPersons(greatGrandChildListCCC);
|
||
|
||
QVERIFY(this->e->save(tim));
|
||
qDebug()<<"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<";
|
||
}
|
||
void EmTest::testCheckDuplicates() {
|
||
QSharedPointer<Article> article = QSharedPointer<Article>(new Article(10,
|
||
QString("TestItem")));
|
tests/em/tst_em.h | ||
---|---|---|
private Q_SLOTS:
|
||
void initTestCase();
|
||
void cleanupTestCase();
|
||
void testChainedHeritageCreate();
|
||
void testChainedHeritageUpdate();
|
||
void testCheckDuplicates();
|
||
void testBasics();
|
||
void init();
|
tests/model/testgroup.cpp | ||
---|---|---|
#include "testgroup.h"
|
||
#include "testperson.h"
|
||
#include "testpupil.h"
|
||
#include <QDebug>
|
||
|
||
TestGroup::TestGroup() : Entity() {
|
||
}
|
||
|
||
const QHash<QString, CuteEntityManager::Relation> TestGroup::getRelations() const {
|
||
auto hash = QHash<QString, CuteEntityManager::Relation>();
|
||
hash.insert("pupils", CuteEntityManager::Relation(
|
||
"pupils", CuteEntityManager::RelationType::MANY_TO_MANY));
|
||
return hash;
|
||
}
|
||
|
||
|
||
QList<QSharedPointer<TestPupil> > TestGroup::pupils() const {
|
||
return m_pupils;
|
||
}
|
||
|
||
void TestGroup::setPupils(const QList<QSharedPointer<TestPupil> > &pupils) {
|
||
m_pupils = pupils;
|
||
}
|
||
|
||
QString TestGroup::name() const {
|
||
return m_name;
|
||
}
|
||
|
||
void TestGroup::setName(const QString &value) {
|
||
m_name = value;
|
||
}
|
||
|
||
|
tests/model/testgroup.h | ||
---|---|---|
#ifndef TESTGROUP_H
|
||
#define TESTGROUP_H
|
||
|
||
#include <QDebug>
|
||
#include "entitymanager.h"
|
||
|
||
class TestPupil;
|
||
class SeatingPlan;
|
||
class TestPerson;
|
||
class AppData;
|
||
|
||
using namespace CuteEntityManager;
|
||
|
||
class TestGroup: public CuteEntityManager::Entity
|
||
{
|
||
Q_OBJECT
|
||
|
||
Q_PROPERTY(QString name READ name WRITE setName)
|
||
Q_PROPERTY(QList<QSharedPointer<TestPupil>> pupils READ pupils WRITE setPupils)
|
||
|
||
public:
|
||
EM_MACRO(TestGroup)
|
||
Q_INVOKABLE TestGroup();
|
||
virtual ~TestGroup() override {}
|
||
|
||
QString name() const;
|
||
void setName(const QString &value);
|
||
|
||
QList<QSharedPointer<TestPupil> > pupils() const;
|
||
void setPupils(const QList<QSharedPointer<TestPupil> > &pupils);
|
||
QSharedPointer<TestPupil> pupilAt(int i) { return m_pupils.at(i); }
|
||
void addPupil(QSharedPointer<TestPupil> p) {m_pupils.append(p);}
|
||
|
||
virtual const QHash<QString, CuteEntityManager::Relation> getRelations() const override;
|
||
|
||
protected:
|
||
// members
|
||
QString m_name;
|
||
QList<QSharedPointer<TestPupil> > m_pupils;
|
||
};
|
||
|
||
#endif // TESTGROUP_H
|
tests/model/testperson.cpp | ||
---|---|---|
#include "testperson.h"
|
||
|
||
TestPerson::TestPerson()
|
||
: Entity()
|
||
{
|
||
}
|
||
|
||
const QHash<QString, Relation> TestPerson::getRelations() const
|
||
{
|
||
auto hash = QHash<QString, Relation>();
|
||
return hash;
|
||
|
||
}
|
tests/model/testperson.h | ||
---|---|---|
#ifndef TESTPERSON_H
|
||
#define TESTPERSON_H
|
||
|
||
#include <QDateTime>
|
||
#include <QDebug>
|
||
|
||
#include "entity.h"
|
||
#include "testgroup.h"
|
||
|
||
using namespace CuteEntityManager;
|
||
|
||
class Gender;
|
||
class NameOrder;
|
||
|
||
class TestPerson: public Entity
|
||
{
|
||
Q_OBJECT
|
||
Q_PROPERTY(QString firstName READ firstName WRITE setFirstName)
|
||
Q_PROPERTY(QString familyName READ familyName WRITE setFamilyName)
|
||
Q_PROPERTY(QString namePrefix READ namePrefix WRITE setNamePrefix)
|
||
Q_PROPERTY(QString nickName READ nickName WRITE setNickName)
|
||
Q_PROPERTY(QDate birthday READ birthday WRITE setBirthday)
|
||
Q_PROPERTY(Gender gender READ gender WRITE setGender)
|
||
Q_PROPERTY(QString customPictureFileName READ customPictureFileName WRITE setCustomPictureFileName)
|
||
|
||
signals:
|
||
void firstNameChanged();
|
||
void familyNameChanged();
|
||
void namePrefixChanged();
|
||
void nickNameChanged();
|
||
void birthdayChanged();
|
||
void genderChanged();
|
||
void customPictureFileNameChanged();
|
||
|
||
public:
|
||
EM_MACRO(TestPerson)
|
||
|
||
enum class Gender {
|
||
MALE = 0,
|
||
FEMALE = 1,
|
||
UNKNOWNGENDER = -1
|
||
};
|
||
Q_ENUM(Gender)
|
||
|
||
enum class NameOrder {
|
||
FIRST_FAMILY=0,
|
||
FAMILY_FIRST=1
|
||
};
|
||
Q_ENUM(NameOrder)
|
||
|
||
|
||
Q_INVOKABLE explicit TestPerson();
|
||
virtual ~TestPerson() override {}
|
||
|
||
virtual const QHash<QString, CuteEntityManager::Relation> getRelations() const override;
|
||
|
||
// getters
|
||
QString firstName() const {return m_firstName;}
|
||
QString familyName() const {return m_familyName;}
|
||
QString namePrefix() const {return m_namePrefix;}
|
||
QString nickName() const {return m_nickName;}
|
||
|
||
QDate birthday() const {return m_birthday;}
|
||
Gender gender() const {return m_gender;}
|
||
QString customPictureFileName() const {return m_customPictureFileName;}
|
||
|
||
// setters
|
||
void setFirstName(QString firstName) {m_firstName=firstName; emit firstNameChanged();}
|
||
void setFamilyName(QString familyName) {m_familyName=familyName; emit familyNameChanged();}
|
||
void setNamePrefix(QString namePrefix) {m_namePrefix=namePrefix; emit namePrefixChanged();}
|
||
void setNickName(QString nickName) {m_nickName=nickName; emit nickNameChanged();}
|
||
|
||
void setBirthday(QDate birthday) {m_birthday=birthday; emit birthdayChanged();}
|
||
void setGender(Gender gender) {m_gender=gender; emit genderChanged();}
|
||
void setCustomPictureFileName(QString fileName) {m_customPictureFileName=fileName; emit customPictureFileNameChanged();}
|
||
|
||
QList<QSharedPointer<TestGroup> > groups() const;
|
||
void setGroups(const QList<QSharedPointer<TestGroup> > &groups);
|
||
|
||
protected:
|
||
// members
|
||
QString m_firstName = QString();
|
||
QString m_familyName = QString();
|
||
QString m_namePrefix = QString();
|
||
QString m_nickName = QString();
|
||
QDate m_birthday = QDate();
|
||
Gender m_gender = Gender::UNKNOWNGENDER;
|
||
QString m_customPictureFileName = QString();
|
||
};
|
||
|
||
#endif // TESTPERSON_H
|
tests/model/testpupil.cpp | ||
---|---|---|
#include "testpupil.h"
|
||
|
||
TestPupil::TestPupil()
|
||
:TestPerson()
|
||
{
|
||
}
|
||
|
||
const QHash<QString, Relation> TestPupil::getRelations() const
|
||
{
|
||
auto hash = TestPerson::getRelations();
|
||
hash.insert("groups",Relation("groups",CuteEntityManager::RelationType::MANY_TO_MANY,QString("pupils")));
|
||
return hash;
|
||
}
|
||
QList<QSharedPointer<TestGroup> > TestPupil::groups() const
|
||
{
|
||
return m_groups;
|
||
}
|
||
|
||
void TestPupil::setGroups(const QList<QSharedPointer<TestGroup> > &groups)
|
||
{
|
||
m_groups = groups;
|
||
}
|
||
|
||
QString TestPupil::legalGuardianNote() const
|
||
{
|
||
return m_legalGuardianNote;
|
||
}
|
||
|
||
void TestPupil::setLegalGuardianNote(const QString &legalGuardianNote)
|
||
{
|
||
m_legalGuardianNote = legalGuardianNote;
|
||
}
|
tests/model/testpupil.h | ||
---|---|---|
#ifndef TESTPUPIL_H
|
||
#define TESTPUPIL_H
|
||
|
||
#include "testperson.h"
|
||
|
||
class TestPupil : public TestPerson
|
||
{
|
||
Q_OBJECT
|
||
Q_PROPERTY(QString legalGuardianNote READ legalGuardianNote WRITE setLegalGuardianNote)
|
||
Q_PROPERTY(QList<QSharedPointer<TestGroup>> groups READ groups WRITE setGroups)
|
||
public:
|
||
EM_MACRO(TestPupil)
|
||
Q_INVOKABLE TestPupil();
|
||
virtual ~TestPupil() override {}
|
||
|
||
virtual const QHash<QString, CuteEntityManager::Relation> getRelations() const override;
|
||
|
||
QList<QSharedPointer<TestGroup> > groups() const;
|
||
void setGroups(const QList<QSharedPointer<TestGroup> > &groups);
|
||
|
||
QString legalGuardianNote() const;
|
||
void setLegalGuardianNote(const QString &legalGuardianNote);
|
||
|
||
protected:
|
||
QString m_legalGuardianNote = QString();
|
||
QList<QSharedPointer<TestGroup>> m_groups = QList<QSharedPointer<TestGroup>>();
|
||
};
|
||
|
||
#endif // TESTPUPIL_H
|
tests/model/testpupilchild.cpp | ||
---|---|---|
#include "testpupilchild.h"
|
||
|
||
TestPupilChild::TestPupilChild() : TestPupil()
|
||
{
|
||
}
|
||
|
||
QString TestPupilChild::childPropertyString() const
|
||
{
|
||
return m_childPropertyString;
|
||
}
|
||
|
||
void TestPupilChild::setChildPropertyString(const QString &childPropertyString)
|
||
{
|
||
m_childPropertyString = childPropertyString;
|
||
}
|
||
|
||
QList<QSharedPointer<TestPerson> > TestPupilChild::childPropertyPersons() const
|
||
{
|
||
return m_childPropertyPersons;
|
||
}
|
||
|
||
void TestPupilChild::setChildPropertyPersons(const QList<QSharedPointer<TestPerson> > &childPropertyPersons)
|
||
{
|
||
m_childPropertyPersons = childPropertyPersons;
|
||
}
|
||
|
||
const QHash<QString, Relation> TestPupilChild::getRelations() const
|
||
{
|
||
auto hash = TestPupil::getRelations();
|
||
hash.insert("childPropertyPersons", Relation("childPropertyPersons",RelationType::MANY_TO_MANY));
|
||
return hash;
|
||
}
|
tests/model/testpupilchild.h | ||
---|---|---|
#ifndef TESTPUPILCHILD_H
|
||
#define TESTPUPILCHILD_H
|
||
|
||
#include <QObject>
|
||
#include "testpupil.h"
|
||
#include "entitymanager.h"
|
||
|
||
class TestPupilChild : public TestPupil
|
||
{
|
||
Q_OBJECT
|
||
Q_PROPERTY(QString childPropertyString READ childPropertyString WRITE setChildPropertyString)
|
||
Q_PROPERTY(QList<QSharedPointer<TestPerson>> childPropertyPersons READ childPropertyPersons WRITE setChildPropertyPersons)
|
||
|
||
public:
|
||
EM_MACRO(TestPupilChild)
|
||
Q_INVOKABLE TestPupilChild();
|
||
virtual ~TestPupilChild() override {}
|
||
|
||
QString childPropertyString() const;
|
||
void setChildPropertyString(const QString &childPropertyString);
|
||
|
||
QList<QSharedPointer<TestPerson> > childPropertyPersons() const;
|
||
void setChildPropertyPersons(const QList<QSharedPointer<TestPerson> > &childPropertyPersons);
|
||
|
||
virtual const QHash<QString, CuteEntityManager::Relation> getRelations() const override;
|
||
virtual InheritanceStrategy getInheritanceStrategy() const override { return InheritanceStrategy::JOINED_TABLE; }
|
||
|
||
signals:
|
||
|
||
public slots:
|
||
private:
|
||
QString m_childPropertyString = "m_childPropertyString";
|
||
QList<QSharedPointer<TestPerson>> m_childPropertyPersons = QList<QSharedPointer<TestPerson>>();
|
||
|
||
};
|
||
|
||
#endif // TESTPUPILCHILD_H
|
tests/model/testpupilgrandchild.cpp | ||
---|---|---|
#include "testpupilgrandchild.h"
|
||
|
||
TestPupilGrandChild::TestPupilGrandChild() : TestPupilChild()
|
||
{
|
||
}
|
||
|
||
QString TestPupilGrandChild::grandChildPropertyString() const
|
||
{
|
||
return m_grandChildPropertyString;
|
||
}
|
||
|
||
void TestPupilGrandChild::setGrandChildPropertyString(const QString &grandChildPropertyString)
|
||
{
|
||
m_grandChildPropertyString = grandChildPropertyString;
|
||
}
|
||
|
||
QList<QSharedPointer<TestPerson> > TestPupilGrandChild::grandChildPropertyPersons() const
|
||
{
|
||
return m_grandChildPropertyPersons;
|
||
}
|
||
|
||
void TestPupilGrandChild::setGrandChildPropertyPersons(const QList<QSharedPointer<TestPerson> > &grandChildPropertyPersons)
|
||
{
|
||
m_grandChildPropertyPersons = grandChildPropertyPersons;
|
||
}
|
||
|
||
const QHash<QString, Relation> TestPupilGrandChild::getRelations() const
|
||
{
|
||
auto hash = TestPupilChild::getRelations();
|
||
hash.insert("grandChildPropertyPersons", Relation("grandChildPropertyPersons",RelationType::MANY_TO_MANY));
|
||
return hash;
|
||
}
|
tests/model/testpupilgrandchild.h | ||
---|---|---|
#ifndef TESTPUPILGRANDCHILD_H
|
||
#define TESTPUPILGRANDCHILD_H
|
||
|
||
#include <QObject>
|
||
#include "testpupilchild.h"
|
||
#include "entitymanager.h"
|
||
#include "testpupilchild.h"
|
||
|
||
class TestPupilGrandChild : public TestPupilChild
|
||
{
|
||
Q_OBJECT
|
||
Q_PROPERTY(QString grandChildPropertyString READ grandChildPropertyString WRITE setGrandChildPropertyString)
|
||
Q_PROPERTY(QList<QSharedPointer<TestPerson>> grandChildPropertyPersons READ grandChildPropertyPersons WRITE setGrandChildPropertyPersons)
|
||
|
||
|
||
public:
|
||
EM_MACRO(TestPupilGrandChild)
|
||
Q_INVOKABLE TestPupilGrandChild();
|
||
virtual ~TestPupilGrandChild() override {}
|
||
|
||
QString grandChildPropertyString() const;
|
||
void setGrandChildPropertyString(const QString &grandChildPropertyString);
|
||
|
||
QList<QSharedPointer<TestPerson> > grandChildPropertyPersons() const;
|
||
void setGrandChildPropertyPersons(const QList<QSharedPointer<TestPerson> > &grandChildPropertyPersons);
|
||
|
||
virtual const QHash<QString, CuteEntityManager::Relation> getRelations() const override;
|
||
virtual InheritanceStrategy getInheritanceStrategy() const override { return InheritanceStrategy::JOINED_TABLE; }
|
||
|
||
private:
|
||
QString m_grandChildPropertyString = "m_grandChildPropertyString";
|
||
QList<QSharedPointer<TestPerson>> m_grandChildPropertyPersons = QList<QSharedPointer<TestPerson>>();
|
||
|
||
};
|
||
|
||
#endif // TESTPUPILGRANDCHILD_H
|
tests/model/testpupilgreatgrandchild.cpp | ||
---|---|---|
#include "testpupilgreatgrandchild.h"
|
||
|
||
TestPupilGreatGrandChild::TestPupilGreatGrandChild() : TestPupilGrandChild()
|
||
{
|
||
}
|
||
|
||
QString TestPupilGreatGrandChild::greatGrandChildPropertyString() const
|
||
{
|
||
return m_greatGrandChildPropertyString;
|
||
}
|
||
|
||
void TestPupilGreatGrandChild::setGreatGrandChildPropertyString(const QString &greatGrandChildPropertyString)
|
||
{
|
||
m_greatGrandChildPropertyString = greatGrandChildPropertyString;
|
||
}
|
||
|
||
QList<QSharedPointer<TestPerson> > TestPupilGreatGrandChild::greatGrandChildPropertyPersons() const
|
||
{
|
||
return m_greatGrandChildPropertyPersons;
|
||
}
|
||
|
||
void TestPupilGreatGrandChild::setGreatGrandChildPropertyPersons(const QList<QSharedPointer<TestPerson> > &greatGrandChildPropertyPersons)
|
||
{
|
||
m_greatGrandChildPropertyPersons = greatGrandChildPropertyPersons;
|
||
}
|
||
|
||
const QHash<QString, Relation> TestPupilGreatGrandChild::getRelations() const
|
||
{
|
||
auto hash = TestPupilGrandChild::getRelations();
|
||
// hash.insert("greatGrandChildPropertyPersons", Relation("greatGrandChildPropertyPersons",RelationType::MANY_TO_MANY));
|
||
return hash;
|
||
}
|
||
|
tests/model/testpupilgreatgrandchild.h | ||
---|---|---|
#ifndef TESTPUPILGREATGRANDCHILD_H
|
||
#define TESTPUPILGREATGRANDCHILD_H
|
||
|
||
#include <QObject>
|
||
#include "testpupilgrandchild.h"
|
||
#include "entitymanager.h"
|
||
|
||
class TestPupilGreatGrandChild : public TestPupilGrandChild
|
||
{
|
||
Q_OBJECT
|
||
Q_PROPERTY(QString greatGrandChildPropertyString READ greatGrandChildPropertyString WRITE setGreatGrandChildPropertyString)
|
||
|
||
public:
|
||
EM_MACRO(TestPupilGreatGrandChild)
|
||
Q_INVOKABLE TestPupilGreatGrandChild();
|
||
virtual ~TestPupilGreatGrandChild() override {}
|
||
|
||
QString greatGrandChildPropertyString() const;
|
||
void setGreatGrandChildPropertyString(const QString &greatGrandChildPropertyString);
|
||
|
||
// not used with Q_PROPERTY, nor in getRelations
|
||
QList<QSharedPointer<TestPerson> > greatGrandChildPropertyPersons() const;
|
||
void setGreatGrandChildPropertyPersons(const QList<QSharedPointer<TestPerson> > &greatGrandChildPropertyPersons);
|
||
|
||
virtual const QHash<QString, CuteEntityManager::Relation> getRelations() const override;
|
||
virtual InheritanceStrategy getInheritanceStrategy() const override { return InheritanceStrategy::JOINED_TABLE; }
|
||
|
||
signals:
|
||
|
||
public slots:
|
||
private:
|
||
QString m_greatGrandChildPropertyString = "m_greatGrandChildPropertyString";
|
||
QList<QSharedPointer<TestPerson>> m_greatGrandChildPropertyPersons;
|
||
};
|
||
|
||
|
||
#endif // TESTPUPILGREATGRANDCHILD_H
|
Auch abrufbar als: Unified diff
Added testcases for deep heritage