Herunterladen als
root/samples/example/models/person.cpp @ 5baea70c
b7446f4c | Christian Ehringfeld | #include "person.h"
|
|
af84b9c4 | Christian Ehringfeld | #include "contact.h"
|
|
#include "address.h"
|
|||
b7446f4c | Christian Ehringfeld | ||
Person::Person(QObject *parent): Entity(parent) {
|
|||
}
|
|||
5c3d9487 | Christian Ehringfeld | Person::Person(QString firstName, QString familyName, Gender gender,
|
|
b7446f4c | Christian Ehringfeld | 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>();
|
|||
da565582 | Christian Ehringfeld | hash.insert("groups", CuteEntityManager::Relation("groups",
|
|
RelationType::MANY_TO_MANY,
|
|||
b7446f4c | Christian Ehringfeld | QString("persons")));
|
|
da565582 | Christian Ehringfeld | hash.insert("maintainedGroups", CuteEntityManager::Relation("maintainedGroups",
|
|
RelationType::ONE_TO_MANY,
|
|||
QString("mainTeacher")));
|
|||
f682a8cb | Christian Ehringfeld | hash.insert("contacts", CuteEntityManager::Relation("contacts",
|
|
RelationType::MANY_TO_MANY));
|
|||
hash.insert("addresses", CuteEntityManager::Relation("addresses",
|
|||
RelationType::MANY_TO_MANY));
|
|||
b7446f4c | Christian Ehringfeld | return hash;
|
|
}
|
|||
5c3d9487 | Christian Ehringfeld | QString Person::fullName(NameOrder nameOrder) const {
|
|
b7446f4c | Christian Ehringfeld | QString name = QString();
|
|
5c3d9487 | Christian Ehringfeld | if (nameOrder == NameOrder::FAMILY_FIRST_NAME_ORDER) {
|
|
b7446f4c | Christian Ehringfeld | 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;
|
|||
}
|
|||
5c3d9487 | Christian Ehringfeld | Person::Gender Person::getGender() const {
|
|
b7446f4c | Christian Ehringfeld | return gender;
|
|
}
|
|||
5c3d9487 | Christian Ehringfeld | void Person::setGender(const Gender &value) {
|
|
b7446f4c | Christian Ehringfeld | gender = value;
|
|
}
|
|||
QString Person::getCustomPictureFileName() const {
|
|||
return customPictureFileName;
|
|||
}
|
|||
void Person::setCustomPictureFileName(const QString &value) {
|
|||
customPictureFileName = value;
|
|||
}
|
|||
QList<QSharedPointer<Contact> > Person::getContacts() const {
|
|||
return contacts;
|
|||
}
|
|||
void Person::setContacts(const QList<QSharedPointer<Contact> > &value) {
|
|||
contacts = value;
|
|||
}
|
|||
QList<QSharedPointer<Address> > Person::getAddresses() const {
|
|||
return addresses;
|
|||
}
|
|||
void Person::setAddresses(const QList<QSharedPointer<Address> > &value) {
|
|||
addresses = 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));
|
|||
}
|
|||
38a2aaf2 | Christian Ehringfeld | ||
QList<QSharedPointer<Group> > Person::getMaintainedGroups() const {
|
|||
da565582 | Christian Ehringfeld | return maintainedGroups;
|
|
}
|
|||
38a2aaf2 | Christian Ehringfeld | void Person::setMaintainedGroups(const QList<QSharedPointer<Group> > &value) {
|
|
da565582 | Christian Ehringfeld | maintainedGroups = value;
|
|
38a2aaf2 | Christian Ehringfeld | ||
da565582 | Christian Ehringfeld | }
|