Revision 57853172
Von Sebastian Diel vor fast 8 Jahren hinzugefügt
samples/simple/group.cpp | ||
---|---|---|
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("pupils", CuteEntityManager::Relation("pupils",
|
||
RelationType::MANY_TO_MANY, QString("groups")));
|
||
hash.insert("mainTeacher", CuteEntityManager::Relation("mainTeacher",
|
||
RelationType::MANY_TO_ONE));
|
||
... | ... | |
void Group::setName(const QString &value) {
|
||
name = value;
|
||
}
|
||
QList<QSharedPointer<Pupil> > Group::getPupils() const {
|
||
return pupils;
|
||
}
|
||
|
||
void Group::setPupils(const QList<QSharedPointer<Pupil> > &value) {
|
||
pupils = value;
|
||
}
|
||
|
||
void Group::addPupil(Pupil *pupil) {
|
||
this->pupils.append(QSharedPointer<Pupil>(pupil));
|
||
}
|
||
|
||
QSharedPointer<Pupil> Group::pupilAt(int i) {
|
||
return this->pupils.at(i);
|
||
}
|
||
|
||
QSharedPointer<Person> Group::getMainTeacher() const {
|
||
return mainTeacher;
|
samples/simple/group.h | ||
---|---|---|
class Group: public CuteEntityManager::Entity {
|
||
Q_OBJECT
|
||
EM_MACRO(Group)
|
||
Q_PROPERTY(QList<QSharedPointer<Pupil>> pupils READ getPupils WRITE setPupils)
|
||
Q_PROPERTY(QList<QSharedPointer<Person>> persons READ getPersons WRITE
|
||
setPersons)
|
||
Q_PROPERTY(QString name READ getName WRITE setName)
|
||
... | ... | |
QString getName() const;
|
||
void setName(const QString &value);
|
||
|
||
QList<QSharedPointer<Pupil> > getPupils() const;
|
||
void setPupils(const QList<QSharedPointer<Pupil> > &value);
|
||
void addPupil(Pupil *pupil);
|
||
QSharedPointer<Pupil> pupilAt(int i);
|
||
|
||
QSharedPointer<Person> getMainTeacher() const;
|
||
QSharedPointer<Person> getMainTeacher() const;
|
||
void setMainTeacher(const QSharedPointer<Person> &value);
|
||
|
||
QList<QSharedPointer<Person> > getPersons() const;
|
||
... | ... | |
void setPersons(const QList<QSharedPointer<Person> > &value);
|
||
|
||
protected:
|
||
QList<QSharedPointer<Pupil>> pupils;
|
||
QList<QSharedPointer<Person>> persons;
|
||
QSharedPointer<Person> mainTeacher;
|
||
QString name;
|
samples/simple/main.cpp | ||
---|---|---|
EntityInstanceFactory::registerClass<Person>();
|
||
EntityInstanceFactory::registerClass<Pupil>();
|
||
EntityInstanceFactory::registerClass<Group>();
|
||
EntityInstanceFactory::registerClass<Occasion>();
|
||
EntityInstanceFactory::registerClass<Incident>();
|
||
EntityInstanceFactory::registerClass<RatingMarkDefinition>();
|
||
EntityInstanceFactory::registerClass<RatingMarkIncident>();
|
||
EntityInstanceFactory::registerClass<RatingMarkSystem>();
|
||
// EntityInstanceFactory::registerClass<Occasion>();
|
||
// EntityInstanceFactory::registerClass<Incident>();
|
||
// EntityInstanceFactory::registerClass<RatingMarkDefinition>();
|
||
// EntityInstanceFactory::registerClass<RatingMarkIncident>();
|
||
// EntityInstanceFactory::registerClass<RatingMarkSystem>();
|
||
|
||
|
||
|
||
... | ... | |
CuteEntityManager::EntityManager("QSQLITE",
|
||
QDir::currentPath() + "/db.sqlite"));
|
||
qDebug()<<QDir::currentPath();
|
||
QStringList inits = QStringList() << "Address" << "Contact" << "Person" << "Pupil" << "Group" << "Incident" << "Occasion" << "RatingMarkDefinition" << "RatingMarkIncident" << "RatingMarkSystem";
|
||
QStringList inits = QStringList() << "Address" << "Contact" << "Person" << "Pupil" << "Group";
|
||
|
||
// << "Incident" << "Occasion" << "RatingMarkDefinition" << "RatingMarkIncident" << "RatingMarkSystem";
|
||
e->startup("0.1", inits);
|
||
|
||
|
||
auto entities = DataCreation::createRatingEntities();
|
||
e->save(entities);
|
||
// auto entities = DataCreation::createRatingEntities();
|
||
// e->save(entities);
|
||
|
||
// QSharedPointer<Pupil> pupil = QSharedPointer<Pupil>(new Pupil("Vorname","Nachname","","","Keks"));
|
||
// e->save(pupil);
|
||
|
||
QSharedPointer<Pupil> pupil = QSharedPointer<Pupil>(new Pupil());
|
||
pupil->setLegalGuardianNote("note");
|
||
e->save(pupil);
|
||
|
||
try {
|
||
e->save(QList<QSharedPointer<Entity>>()<<pupil);
|
||
} catch(QString s) {
|
||
qDebug()<<s;
|
||
}
|
||
// QSharedPointer<Person> person = QSharedPointer<Person>(new Person("Vorname","Nachname","","","Keks"));
|
||
// e->save(person);
|
||
|
||
|
||
/*
|
||
|
||
QSharedPointer<Occasion> occasion = QSharedPointer<Occasion>(new Occasion("IrgendeinAnlass"));
|
||
QSharedPointer<RatingMarkIncident> inc = QSharedPointer<RatingMarkIncident>(new RatingMarkIncident());
|
||
... | ... | |
e->save(inc);
|
||
|
||
|
||
|
||
*/
|
||
return 0;
|
||
}
|
samples/simple/person.cpp | ||
---|---|---|
hash.insert("groups", CuteEntityManager::Relation("groups",
|
||
RelationType::MANY_TO_MANY,
|
||
QString("persons")));
|
||
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",
|
||
... | ... | |
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;
|
||
|
||
}
|
||
|
samples/simple/person.h | ||
---|---|---|
setCustomPictureFileName)
|
||
Q_PROPERTY(QDate birthday READ getBirthday WRITE setBirthday)
|
||
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
|
||
... | ... | |
void addContact(Contact *contact);
|
||
void addAddress(Address *address);
|
||
|
||
QList<QSharedPointer<Group> > getMaintainedGroups() const;
|
||
void setMaintainedGroups(const QList<QSharedPointer<Group> > &value);
|
||
|
||
|
||
protected:
|
||
QString firstName;
|
||
... | ... | |
QList <QSharedPointer<Contact>> contacts;
|
||
QList <QSharedPointer<Address>> addresses;
|
||
QList <QSharedPointer<Group>> groups;
|
||
QList <QSharedPointer<Group>> maintainedGroups;
|
||
|
||
};
|
||
|
Auch abrufbar als: Unified diff
Pupil persisting problem