| 1 |
|
/** |
| 2 |
|
Copyright 2002 Cyril Picard |
| 3 |
|
|
| 4 |
|
This file is part of the GEDCOMViewer tool |
| 5 |
|
(developed within the Genealogy Free Software Tools project). |
| 6 |
|
|
| 7 |
|
The GEDCOMViewer tool is free software; you can redistribute it and/or modify |
| 8 |
|
it under the terms of the GNU General Public License as published by |
| 9 |
|
the Free Software Foundation; either version 2 of the License, or |
| 10 |
|
(at your option) any later version. |
| 11 |
|
|
| 12 |
|
The GEDCOMViewer tool is distributed in the hope that it will be useful, |
| 13 |
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
|
GNU General Public License for more details. |
| 16 |
|
|
| 17 |
|
You should have received a copy of the GNU General Public License |
| 18 |
|
along with the GEDCOMViewer tool ; if not, write to the Free Software |
| 19 |
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 |
|
|
| 21 |
|
**/ |
| 22 |
#include "BakeryGateway/ViewTreeBrowser.hh" |
#include "BakeryGateway/ViewTreeBrowser.hh" |
| 23 |
|
|
| 24 |
BakeryGateway::ViewTreeBrowser::ViewTreeBrowser(void) |
BakeryGateway::ViewTreeBrowser::ViewTreeBrowser(void) |
| 27 |
return; |
return; |
| 28 |
} |
} |
| 29 |
|
|
| 30 |
void BakeryGateway::ViewTreeBrowser::AddParentInTree(SmartPtr< GEDCOMParser::IndividualRecord > const &child, SmartPtr< GEDCOMParser::IndividualRecord > const & parent, GEDCOMParser::IndividualRecords_t * children) |
void BakeryGateway::ViewTreeBrowser::AddParentInTree(GEDCOMParser::IndividualRecord const * const child, GEDCOMParser::IndividualRecord * const parent, std::vector<GEDCOMParser::IndividualRecord *> * children) |
| 31 |
{ |
{ |
| 32 |
std::string individu_name; |
std::string individu_name; |
| 33 |
|
|
| 34 |
if (!(parent.Null())) |
if (parent != 0) |
| 35 |
{ |
{ |
| 36 |
individu_name = getIndividualName(parent); |
individu_name = getIndividualName(parent); |
| 37 |
if (_mmi_browser.addParent(child->getId(), parent->getId(), individu_name) == 1) |
if (_mmi_browser.addParent(child->getId(), parent->getId(), individu_name) == 1) |
| 38 |
{ |
{ |
| 39 |
(*children)[parent->getId()] = parent; |
children->push_back(parent); |
| 40 |
} |
} |
| 41 |
} |
} |
| 42 |
return; |
return; |
| 43 |
} |
} |
| 44 |
|
|
| 45 |
std::string const BakeryGateway::ViewTreeBrowser::getIndividualName(SmartPtr<GEDCOMParser::IndividualRecord> const & individual) |
std::string const BakeryGateway::ViewTreeBrowser::getIndividualName(GEDCOMParser::IndividualRecord const * const individual) |
| 46 |
{ |
{ |
| 47 |
std::string individual_name; |
std::string individual_name; |
| 48 |
if (individual->getPersonalNames().size() > 0) |
if (individual->getPersonalNames().size() > 0) |
| 60 |
{ |
{ |
| 61 |
_mmi_browser.clear(); |
_mmi_browser.clear(); |
| 62 |
GEDCOMParser::IndividualRecords_t individuals = _local_document->getIndividualRecords(); |
GEDCOMParser::IndividualRecords_t individuals = _local_document->getIndividualRecords(); |
| 63 |
|
std::vector<GEDCOMParser::IndividualRecord *> children; |
| 64 |
|
std::vector<GEDCOMParser::IndividualRecord *> * tmp_children = 0; |
| 65 |
if (individuals.size() > 0) |
if (individuals.size() > 0) |
| 66 |
{ |
{ |
| 67 |
GEDCOMParser::IndividualRecords_t children; |
if (_parent_entity != 0) |
| 68 |
GEDCOMParser::IndividualRecords_t * tmp_children = 0; |
{ |
| 69 |
|
GEDCOMParser::IndividualRecord * child = _parent_entity; |
| 70 |
std::string individu_name; |
std::string individu_name; |
| 71 |
|
|
| 72 |
children = get_document()->getRootIndividuals(); |
individu_name = getIndividualName(child); |
| 73 |
SmartPtr<GEDCOMParser::IndividualRecord> parent; |
_mmi_browser.addParent("", child->getId(), individu_name); |
| 74 |
|
children.push_back(child); |
| 75 |
|
|
| 76 |
for (GEDCOMParser::IndividualRecords_t::const_iterator child_iter = children.begin(); child_iter != children.end() ; child_iter++) |
SmartPtr<GEDCOMParser::IndividualRecord> parent; |
| 77 |
{ |
while (children.size() > 0) |
|
individu_name = getIndividualName(child_iter->second); |
|
|
_mmi_browser.addParent("", child_iter->second->getId(), individu_name); |
|
|
} |
|
|
while (children.size() > 0) |
|
|
{ |
|
|
tmp_children = new GEDCOMParser::IndividualRecords_t; |
|
|
for (GEDCOMParser::IndividualRecords_t::const_iterator child_iter = children.begin(); child_iter != children.end() ; child_iter++) |
|
| 78 |
{ |
{ |
| 79 |
parent = get_document()->getIndividualParent(child_iter->second.getPtr(), GEDCOMParser::LineageLinkageGedcom::e_Husband); |
tmp_children = new std::vector<GEDCOMParser::IndividualRecord *>; |
| 80 |
AddParentInTree(child_iter->second, parent, tmp_children); |
for (std::vector<GEDCOMParser::IndividualRecord *>::const_iterator child_iter = children.begin(); child_iter != children.end() ; child_iter++) |
| 81 |
|
{ |
| 82 |
parent = get_document()->getIndividualParent(child_iter->second.getPtr(), GEDCOMParser::LineageLinkageGedcom::e_Wife); |
parent = get_document()->getIndividualParent(*child_iter, GEDCOMParser::LineageLinkageGedcom::e_Husband); |
| 83 |
AddParentInTree(child_iter->second, parent, tmp_children); |
if (!parent.Null()) |
| 84 |
} |
{ |
| 85 |
children = (*tmp_children); |
AddParentInTree(*child_iter, parent.getPtr(), tmp_children); |
| 86 |
delete tmp_children; tmp_children = 0; |
} |
| 87 |
} |
|
| 88 |
|
parent = get_document()->getIndividualParent(*child_iter, GEDCOMParser::LineageLinkageGedcom::e_Wife); |
| 89 |
|
if (!parent.Null()) |
| 90 |
|
{ |
| 91 |
|
AddParentInTree(*child_iter, parent.getPtr(), tmp_children); |
| 92 |
|
} |
| 93 |
|
} |
| 94 |
|
children = (*tmp_children); |
| 95 |
|
delete tmp_children; tmp_children = 0; |
| 96 |
|
} |
| 97 |
|
} |
| 98 |
} |
} |
| 99 |
_mmi_browser.show(); |
_mmi_browser.show(); |
| 100 |
return; |
return; |