/[ghosts]/ghosts/gedcomviewer/src/BakeryGateway/ViewChildToFamilyLink.cpp
ViewVC logotype

Diff of /ghosts/gedcomviewer/src/BakeryGateway/ViewChildToFamilyLink.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by cpcp, Sun Mar 2 20:26:53 2003 UTC revision 1.9 by cpcp, Mon Mar 3 21:39:24 2003 UTC
# Line 20  Line 20 
20    
21  **/  **/
22  #include "BakeryGateway/ViewChildToFamilyLink.hh"  #include "BakeryGateway/ViewChildToFamilyLink.hh"
 #include "BakeryGateway/ViewFamilyRecordNoteFactory.hh"  
23  #include "OneFamilyLinkHandler.hh"  #include "OneFamilyLinkHandler.hh"
24  #include "OneChildToFamilyLink.hh"  #include "OneChildToFamilyLink.hh"
25  #include "OneChildToFamilyLinkHandler.hh"  #include "OneChildToFamilyLinkHandler.hh"
# Line 88  void BakeryGateway::ViewChildToFamilyLin Line 87  void BakeryGateway::ViewChildToFamilyLin
87    if ((_parent_entity != 0) && (get_document() != 0))    if ((_parent_entity != 0) && (get_document() != 0))
88      {      {
89        GEDCOMParser::ChildToFamilyLinks_t links = _parent_entity->getChildToFamilyLinks();          GEDCOMParser::ChildToFamilyLinks_t links = _parent_entity->getChildToFamilyLinks();  
       GEDCOMParser::FamilyRecords_t families = get_document()->getFamilyRecords();  
90        GEDCOMParser::IndividualRecords_t individuals = get_document()->getIndividualRecords();        GEDCOMParser::IndividualRecords_t individuals = get_document()->getIndividualRecords();
91        std::string father;        GEDCOMParser::FamilyRecords_t families = get_document()->getFamilyRecords();
       std::string mother;  
         
92        for (GEDCOMParser::ChildToFamilyLinks_t::const_iterator iter = links.begin(); iter != links.end(); iter++)        for (GEDCOMParser::ChildToFamilyLinks_t::const_iterator iter = links.begin(); iter != links.end(); iter++)
93          {          {
94            std::string famc_id = (*iter)->getRawFamcXref();            std::string famc_id = (*iter)->getRawFamcXref();
95            GEDCOMParser::FamilyRecords_t::const_iterator famc_iter = families.find(famc_id);            GEDCOMParser::FamilyRecord * familyrecord = 0;
96            if (famc_iter != families.end())            OneFamilyLinkHandler * familylink_handler = 0;
97              if (ManageFamilyLinkHandler(famc_id, families, individuals, &familyrecord, &familylink_handler))
98              {              {
99                std::string * father_id = new std::string((*famc_iter).second->getHusb());                OneFamilyLink * new_family_link = _mmi_childtofamilylink->addFamilyLink(*familylink_handler);
100                std::string * mother_id = new std::string((*famc_iter).second->getWife());                ManageFamilyLinkNote(new_family_link, (*iter).getPtr());
101                father = get_name_individual(individuals, *father_id);                ManageFamilyRecordNote(new_family_link, familyrecord);
               mother = get_name_individual(individuals, *mother_id);  
               OneFamilyLinkHandler::SlotHandler_t * slot_father = new OneFamilyLinkHandler::SlotHandler_t(SigC::bind(SigC::slot(this, &BakeryGateway::ViewChildToFamilyLink::ButtonPressed), father_id));  
               OneFamilyLinkHandler::SlotHandler_t * slot_mother = new OneFamilyLinkHandler::SlotHandler_t(SigC::bind(SigC::slot(this, &BakeryGateway::ViewChildToFamilyLink::ButtonPressed), mother_id));  
               OneChildToFamilyLinkHandler new_handler(father, mother, slot_father, slot_mother);  
               OneFamilyLink * new_family_link;  
               new_family_link = _mmi_childtofamilylink->addFamilyLink(new_handler);  
               Bakery::View<BakeryGateway::Document> * note_view = _view_factory->createView(new_family_link->getFamilyLinkNote());  
               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<BakeryGateway::Document> * family_note_view = familyrecord_note_factory.createView(new_family_link->getFamilyRecordNote());  
               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());              
102              }              }
103          }            }  
104      }      }
# Line 126  void BakeryGateway::ViewChildToFamilyLin Line 106  void BakeryGateway::ViewChildToFamilyLin
106    return;    return;
107  }  }
108    
109    void BakeryGateway::ViewChildToFamilyLink::ManageFamilyLinkNote(OneFamilyLink * family_link, GEDCOMParser::ChildToFamilyLink * gedcom_family_link)
110    {
111      Bakery::View<BakeryGateway::Document> * familylink_note_view = _view_factory->createView(family_link->getFamilyLinkNote());
112      subscribe_view(familylink_note_view);
113      BakeryExtras::View_Linked < BakeryGateway::Document, GEDCOMParser::ChildToFamilyLink > * tmp =  dynamic_cast < BakeryExtras::View_Linked < BakeryGateway::Document, GEDCOMParser::ChildToFamilyLink > * > (familylink_note_view);
114      tmp->set_parent_entity(gedcom_family_link);
115      return;
116    }
117    
118    bool BakeryGateway::ViewChildToFamilyLink::ManageFamilyLinkHandler(std::string const &family_record_id, GEDCOMParser::FamilyRecords_t const &families, GEDCOMParser::IndividualRecords_t const &individuals, GEDCOMParser::FamilyRecord ** familyrecord, OneFamilyLinkHandler ** familylink_handler)
119    {
120      
121      bool res;
122      GEDCOMParser::FamilyRecords_t::const_iterator family_iter = families.find(family_record_id);
123      if (family_iter != families.end())
124        {
125          res = true;
126          *familyrecord = (*family_iter).second.getPtr();
127          std::string * father_id = new std::string((*family_iter).second->getHusb());
128          std::string * mother_id = new std::string((*family_iter).second->getWife());
129          std::string father = get_name_individual(individuals, *father_id);
130          std::string mother = get_name_individual(individuals, *mother_id);
131          OneFamilyLinkHandler::SlotHandler_t * slot_father = getSlotHandler(father_id);
132          OneFamilyLinkHandler::SlotHandler_t * slot_mother = getSlotHandler(mother_id);    
133          OneFamilyLinkHandler * familylink_handler_tmp = new OneChildToFamilyLinkHandler(father, mother, slot_father, slot_mother);
134          *familylink_handler = familylink_handler_tmp;
135        }
136      else
137        {
138          res = false;
139        }
140      return res;
141    }
142    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26