Revision 67639b75
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
samples/example/main.cpp | ||
---|---|---|
"Mustermann", Person::Gender::MALE));
|
||
gPtr->setMainTeacher(mainTeacher);
|
||
//Persons will also persisted
|
||
e->create(groupPtr, true, true);
|
||
//e->create(groupPtr, true, true);
|
||
|
||
/** ---------------------------------
|
||
* FIND
|
||
* FIND Group
|
||
* ---------------------------------
|
||
*/
|
||
QSharedPointer<Entity> groupFindPtr = e->findById<Group *>(1);
|
||
... | ... | |
qDebug()<< "Group:" << groupFindPtr->toString();
|
||
qDebug() << "PersonSize:" << grp->getPersons().size();
|
||
qDebug() << "MainTeacher:" << grp->getMainTeacher()->toString();
|
||
|
||
/** ---------------------------------
|
||
* FIND Person
|
||
* ---------------------------------
|
||
*/
|
||
QSharedPointer<Entity> personFindPtr = e->findById(1,QString("Person*"));
|
||
e->refresh(personFindPtr);
|
||
QSharedPointer<Person> pers = personFindPtr.objectCast<Person>();
|
||
qDebug()<< "MainTeacher:" << personFindPtr->toString();
|
||
qDebug() << "GroupSize:" << pers->getGroupsMainTeacher().size();
|
||
|
||
|
||
|
||
qDebug() << "Duration:" << t.elapsed();
|
||
return 0;
|
||
}
|
samples/example/models/person.cpp | ||
---|---|---|
auto hash = QHash<QString, CuteEntityManager::Relation>();
|
||
hash.insert("groups", CuteEntityManager::Relation("groups", MANY_TO_MANY,
|
||
QString("persons")));
|
||
hash.insert("groupsMainTeacher",
|
||
CuteEntityManager::Relation("groupsMainTeacher",
|
||
ONE_TO_MANY, "mainTeacher"));
|
||
return hash;
|
||
}
|
||
|
||
... | ... | |
void Person::addAddress(Address *address) {
|
||
this->addresses.append(QSharedPointer<Address>(address));
|
||
}
|
||
QList<QSharedPointer<Group> > Person::getGroupsMainTeacher() const {
|
||
return groupsMainTeacher;
|
||
}
|
||
|
||
void Person::setGroupsMainTeacher(const QList<QSharedPointer<Group> > &value) {
|
||
groupsMainTeacher = value;
|
||
}
|
||
|
samples/example/models/person.h | ||
---|---|---|
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>> groupsMainTeacher READ getGroupsMainTeacher WRITE setGroupsMainTeacher)
|
||
|
||
public:
|
||
enum class Gender {MALE, FEMALE, UNKNOWNGENDER};
|
||
... | ... | |
void addContact(Contact *contact);
|
||
void addAddress(Address *address);
|
||
|
||
protected:
|
||
QList<QSharedPointer<Group> > getGroupsMainTeacher() const;
|
||
void setGroupsMainTeacher(const QList<QSharedPointer<Group> > &value);
|
||
|
||
protected:
|
||
QString firstName;
|
||
QString familyName;
|
||
QString namePrefix;
|
||
... | ... | |
QList <QSharedPointer<Contact>> contacts;
|
||
QList <QSharedPointer<Address>> addresses;
|
||
QList <QSharedPointer<Group>> groups;
|
||
QList <QSharedPointer<Group>> groupsMainTeacher;
|
||
};
|
||
|
||
|
Auch abrufbar als: Unified diff
not working example, caused by a bug in em