operator ^ for last defined person

This commit is contained in:
Venelin
2024-06-15 13:48:08 +03:00
committed by vrd
parent a096a2a34c
commit 4d61963dae
8 changed files with 91 additions and 63 deletions
+32 -48
View File
@@ -175,66 +175,50 @@ namespace
person_id selectLeftSibSpouse(const Tree& t, person_id selected) /* todo: return a value and split */
{
person_id leftSib = Nobody;
if(t.findRelation(selected, t.focused()) == Child) // todo: why not just the else?
{
auto siblings = t.findChildren(t.focused());
for(auto it = siblings.begin()+1; it < siblings.end(); ++it)
{
if(*it == selected)
{
leftSib = *(it-1);
break;
}
}
}
else if(person_id sel_par = t.findParent(selected, M); sel_par != Nobody)
{
auto siblings = t.findChildren(sel_par);
for(auto it = siblings.begin()+1; it < siblings.end(); ++it)
{
if(*it == selected)
{
leftSib = *(it-1);
break;
}
}
}
person_id sel_par = t.findParent(selected, M);
if( sel_par == Nobody )
sel_par = t.findParent(selected, F);
if( sel_par == Nobody )
return selected;
if(leftSib != Nobody)
auto siblings = t.findChildren(sel_par);
person_id left_sib = Nobody;
for(auto it = siblings.begin()+1; it < siblings.end(); ++it)
{
person_id leftSibSpouse = t.findSpouse(leftSib);
selected = (leftSibSpouse != Nobody) ? leftSibSpouse : leftSib;
if(*it == selected)
{
left_sib = *(it-1);
person_id sib_spouse = t.findSpouse(left_sib);
if(sib_spouse != Nobody)
selected = sib_spouse;
else
selected = left_sib;
break;
}
}
return selected;
}
person_id selectRightSib(const Tree& t, person_id selected)
{
if(t.findRelation(selected, t.focused()) == Child)
person_id sel_par = t.findParent(selected, M);
if( sel_par == Nobody )
sel_par = t.findParent(selected, F);
if( sel_par == Nobody )
return selected;
auto siblings = t.findChildren(sel_par);
for(auto it = siblings.begin(); it < siblings.end()-1; ++it)
{
auto siblings = t.findChildren(t.focused());
for(auto it = siblings.begin(); it < siblings.end()-1; ++it)
if(*it == selected)
{
if(*it == selected)
{
selected = *(it+1);
break;
}
}
}
else if(person_id sel_par = t.findParent(selected, M); sel_par != Nobody)
{
auto siblings = t.findChildren(sel_par);
for(auto it = siblings.begin(); it < siblings.end()-1; ++it)
{
if(*it == selected)
{
selected = *(it+1);
break;
}
selected = *(it+1);
break;
}
}
return selected;
}
}