Revision af84b9c4
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
samples/example/models/address.cpp | ||
---|---|---|
#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;
|
||
}
|
||
|
||
|
samples/example/models/address.h | ||
---|---|---|
#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
|
samples/example/models/contact.cpp | ||
---|---|---|
#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;
|
||
}
|
||
... | ... | |
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;
|
||
}
|
samples/example/models/contact.h | ||
---|---|---|
#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);
|
||
... | ... | |
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
|
samples/example/models/group.cpp | ||
---|---|---|
#include "group.h"
|
||
#include "person.h"
|
||
#include "contact.h"
|
||
#include "pupil.h"
|
||
#include <QDebug>
|
||
|
||
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;
|
samples/example/models/group.h | ||
---|---|---|
#ifndef GROUP_H
|
||
#define GROUP_H
|
||
|
||
#include "entity.h"
|
||
#include "contact.h"
|
||
#include "pupil.h"
|
||
#include <QDebug>
|
||
//#include <QQuickView>
|
||
|
||
|
||
|
||
class Teacher;
|
||
class Person;
|
||
... | ... | |
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);
|
||
... | ... | |
void addPerson(Person *person);
|
||
void setPersons(const QList<QSharedPointer<Person> > &value);
|
||
|
||
protected:
|
||
protected:
|
||
QList<QSharedPointer<Pupil>> pupils;
|
||
QList<QSharedPointer<Person>> persons;
|
||
QSharedPointer<Person> mainTeacher;
|
samples/example/models/person.cpp | ||
---|---|---|
#include "person.h"
|
||
#include "contact.h"
|
||
#include "address.h"
|
||
|
||
Person::Person(QObject *parent): Entity(parent) {
|
||
}
|
||
... | ... | |
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;
|
||
}
|
||
|
samples/example/models/person.h | ||
---|---|---|
#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
|
||
... | ... | |
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};
|
samples/example/models/pupil.cpp | ||
---|---|---|
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;
|
||
}
|
||
|
||
|
||
|
samples/example/models/pupil.h | ||
---|---|---|
|
||
QString getLegalGuardianNote() const;
|
||
void setLegalGuardianNote(const QString &value);
|
||
virtual const QHash<QString, CuteEntityManager::Relation> getRelations() const;
|
||
|
||
QString getForm() const;
|
||
void setForm(const QString &value);
|
Auch abrufbar als: Unified diff
example update