| 21 |
**/ |
**/ |
| 22 |
#include "BakeryGateway/ViewIndividualRecord.hh" |
#include "BakeryGateway/ViewIndividualRecord.hh" |
| 23 |
#include "options/Options.hh" |
#include "options/Options.hh" |
| 24 |
|
#include <gtk--/menu.h> |
| 25 |
|
#include <gtk--/menushell.h> |
| 26 |
|
|
| 27 |
BakeryGateway::ViewIndividualRecord::ViewIndividualRecord(MMIIndividualRecord * mmi) : |
BakeryGateway::ViewIndividualRecord::ViewIndividualRecord(MMIIndividualRecord * mmi) : |
| 28 |
_mmi_individual_record(mmi), |
_mmi_individual_record(mmi), |
| 29 |
_individuals(), |
_individuals(), |
| 30 |
_current_individu(), |
_current_individu(), |
| 31 |
_local_document(0) |
_local_document(0), |
| 32 |
|
_during_load(false), |
| 33 |
|
_during_save(false) |
| 34 |
{ |
{ |
| 35 |
|
|
| 36 |
|
Gtk::Menu * menu = _mmi_individual_record->getSexWidget()->get_menu(); |
| 37 |
|
Gtk::Menu_Helpers::MenuList items = menu->items(); |
| 38 |
|
for (Gtk::Menu_Helpers::MenuList::iterator iter = items.begin(); |
| 39 |
|
iter != items.end(); iter++) |
| 40 |
|
{ |
| 41 |
|
(*iter)->activate.connect(SigC::slot(this, &ViewIndividualRecord::save_to_document)); |
| 42 |
|
} |
| 43 |
return; |
return; |
| 44 |
} |
} |
| 45 |
|
|
| 46 |
|
void BakeryGateway::ViewIndividualRecord::save_to_document(void) |
| 47 |
|
{ |
| 48 |
|
if ((!_during_load) && (!_during_save)) |
| 49 |
|
{ |
| 50 |
|
_during_save = true; |
| 51 |
|
MMIIndividualRecord::enumSex mmi_sex = _mmi_individual_record->getSex(); |
| 52 |
|
std::string new_sex; |
| 53 |
|
switch (mmi_sex) { |
| 54 |
|
case MMIIndividualRecord::e_Man: |
| 55 |
|
new_sex = "M"; |
| 56 |
|
break; |
| 57 |
|
case MMIIndividualRecord::e_Woman: |
| 58 |
|
new_sex = "F"; |
| 59 |
|
break; |
| 60 |
|
default: |
| 61 |
|
new_sex = _entity->getSex(); |
| 62 |
|
} |
| 63 |
|
if (new_sex != _entity->getSex()) |
| 64 |
|
{ |
| 65 |
|
_entity->setSex(new_sex); |
| 66 |
|
} |
| 67 |
|
_during_save = false; |
| 68 |
|
} |
| 69 |
|
return; |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
|
| 73 |
BakeryGateway::ViewIndividualRecord::~ViewIndividualRecord(void) |
BakeryGateway::ViewIndividualRecord::~ViewIndividualRecord(void) |
| 74 |
{ |
{ |
| 75 |
return; |
return; |
| 77 |
|
|
| 78 |
void BakeryGateway::ViewIndividualRecord::load_from_document(void) |
void BakeryGateway::ViewIndividualRecord::load_from_document(void) |
| 79 |
{ |
{ |
| 80 |
|
_during_load = true; |
| 81 |
if (_local_document != get_document()) |
if (_local_document != get_document()) |
| 82 |
{ |
{ |
| 83 |
_local_document = get_document(); |
_local_document = get_document(); |
| 99 |
LoadCurrentIndividu(); |
LoadCurrentIndividu(); |
| 100 |
notify_subscribees(); |
notify_subscribees(); |
| 101 |
} |
} |
| 102 |
|
_during_load = false; |
| 103 |
return; |
return; |
| 104 |
} |
} |
| 105 |
|
|