#include "BakeryGateway/ViewChildToFamilyLink.hh" #include "BakeryGateway/ViewFamilyRecordNoteFactory.hh" BakeryGateway::ViewChildToFamilyLink::ViewChildToFamilyLink(MMIChildToFamilyLink * mmi) : _mmi_childtofamilylink(mmi) { return; } BakeryGateway::ViewChildToFamilyLink::~ViewChildToFamilyLink(void) { return; } void BakeryGateway::ViewChildToFamilyLink::load_from_document(void) { _mmi_childtofamilylink->Clear(); delete_subscribed_views(); if ((_parent_entity != 0) && (get_document() != 0)) { GEDCOMParser::ChildToFamilyLinks_t links = _parent_entity->getChildToFamilyLinks(); GEDCOMParser::FamilyRecords_t families = get_document()->getFamilyRecords(); GEDCOMParser::IndividualRecords_t individuals = get_document()->getIndividualRecords(); std::string father; std::string mother; for (GEDCOMParser::ChildToFamilyLinks_t::const_iterator iter = links.begin(); iter != links.end(); iter++) { std::string famc_id = (*iter)->getRawFamcXref(); GEDCOMParser::FamilyRecords_t::const_iterator famc_iter = families.find(famc_id); if (famc_iter != families.end()) { std::string * father_id = new std::string((*famc_iter).second->getHusb()); std::string * mother_id = new std::string((*famc_iter).second->getWife()); father = get_name_individual(individuals, *father_id); mother = get_name_individual(individuals, *mother_id); SigC::Slot0 * slot_father = new SigC::Slot0(SigC::bind(SigC::slot(this, &BakeryGateway::ViewChildToFamilyLink::Navigate), father_id)); SigC::Slot0 * slot_mother = new SigC::Slot0(SigC::bind(SigC::slot(this, &BakeryGateway::ViewChildToFamilyLink::Navigate), mother_id)); OneChildToFamilyLink * new_family_link = _mmi_childtofamilylink->addChildToFamilyLink(father, mother, slot_father, slot_mother); Bakery::View * note_view = _view_factory->createView(new_family_link->OneChildToFamilyLinkNote); subscribe_view(note_view); BakeryExtras::View_Linked < BakeryGateway::Document, GEDCOMParser::ChildToFamilyLink > * tmp = dynamic_cast < BakeryExtras::View_Linked < BakeryGateway::Document, GEDCOMParser::ChildToFamilyLink > * > (note_view); tmp->set_parent_entity((*iter).getPtr()); BakeryGateway::ViewFamilyRecordNoteFactory familyrecord_note_factory; Bakery::View * family_note_view = familyrecord_note_factory.createView(new_family_link->MMIParentsFamilyNote); subscribe_view(family_note_view); BakeryExtras::View_Linked < BakeryGateway::Document, GEDCOMParser::FamilyRecord > * tmp2 = dynamic_cast < BakeryExtras::View_Linked < BakeryGateway::Document, GEDCOMParser::FamilyRecord > * > (family_note_view); tmp2->set_parent_entity(famc_iter->second.getPtr()); } } } return; } void BakeryGateway::ViewChildToFamilyLink::Navigate(std::string const * key) { BakeryExtras::View_Navigator::Navigate(*key); return; } std::string BakeryGateway::ViewChildToFamilyLink::get_name_individual(GEDCOMParser::IndividualRecords_t const &individuals, std::string const &individual_id) const { std::string * individual_name = new std::string(); GEDCOMParser::IndividualRecords_t::const_iterator iter = individuals.find(individual_id); if (iter != individuals.end()) { if ((*iter).second->getPersonalNames().size() > 0) { if (!((*iter).second->getPersonalNames()[0]).Null()) { delete individual_name; individual_name = new std::string ((*iter).second->getPersonalNames()[0]->getName()); } } } return *individual_name; }