You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#include "campservice.h"
|
|
|
|
|
|
|
|
CampService::CampService()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CampService::addPerson(CampDataPtr data, AddressbookDataPtr address)
|
|
|
|
{
|
|
|
|
AddressItemPtr addrItem(new AddressItem);
|
|
|
|
|
|
|
|
addrItem->setAdbItem(address);
|
|
|
|
addrItem->setAddress(address->toString());
|
|
|
|
addrItem->setFirstName(address->firstName());
|
|
|
|
addrItem->setLastName(address->lastName());
|
|
|
|
addrItem->setCampData(data);
|
|
|
|
|
|
|
|
if (data->people().isEmpty())
|
|
|
|
{
|
|
|
|
setOwner(data, addrItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
data->addPerson(addrItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CampService::setOwner(CampDataPtr data, AddressItemPtr person)
|
|
|
|
{
|
|
|
|
foreach (AddressItemPtr p, data->people()) {
|
|
|
|
p->setOwner(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
person->setOwner(true);
|
|
|
|
|
|
|
|
data->setOwnerFirstame(person->firstName());
|
|
|
|
data->setOwnerLastname(person->lastName());
|
|
|
|
data->setOwnerAddress(person->address());
|
|
|
|
}
|
|
|
|
|
|
|
|
CampDataPtr CampService::create()
|
|
|
|
{
|
|
|
|
CampDataPtr data(new CampData);
|
|
|
|
data->setStart(QDate::currentDate());
|
|
|
|
data->setEnd(QDate::currentDate());
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|