From 97ebb2bdd18e21f4ed3e7a99e91b411cf5827324 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Tue, 29 Dec 2015 00:14:23 +0000 Subject: [PATCH] Implemented ADR to use ContactDataObject. --- .../contacteditor/frmContactEditor-Load.cpp | 23 ++- .../frmContactEditor-LoadAddress.cpp | 147 ++++++++++++++++++ source/contacteditor/frmContactEditor.h | 16 ++ 3 files changed, 184 insertions(+), 2 deletions(-) diff --git a/source/contacteditor/frmContactEditor-Load.cpp b/source/contacteditor/frmContactEditor-Load.cpp index ef9f4f4..56e4b9f 100644 --- a/source/contacteditor/frmContactEditor-Load.cpp +++ b/source/contacteditor/frmContactEditor-Load.cpp @@ -166,6 +166,25 @@ bool frmContactEditor::LoadContact(wxString Filename){ LoadMember(&ContactEditorData.GroupsList); + // Process the address (ADR) (frmContactEditor-LoadAddress.cpp) + + LoadAddress(&ContactEditorData.GeneralAddressList, + &ContactEditorData.GeneralAddressListTown, + &ContactEditorData.GeneralAddressListCounty, + &ContactEditorData.GeneralAddressListPostCode, + &ContactEditorData.GeneralAddressListPref, + &ContactEditorData.HomeAddressList, + &ContactEditorData.HomeAddressListTown, + &ContactEditorData.HomeAddressListCounty, + &ContactEditorData.HomeAddressListPostCode, + &ContactEditorData.HomeAddressListPref, + &ContactEditorData.BusinessAddressList, + &ContactEditorData.BusinessAddressListTown, + &ContactEditorData.BusinessAddressListCounty, + &ContactEditorData.BusinessAddressListPostCode, + &ContactEditorData.BusinessAddressListPref, + &ADRCount); + for (std::map::iterator iter = ContactFileLines.begin(); iter != ContactFileLines.end(); ++iter){ @@ -321,13 +340,13 @@ bool frmContactEditor::LoadContact(wxString Filename){ LoadTimeZone(wxSPropertySeg1, wxSPropertySeg2, &TZCount); - } else if (wxSProperty == wxT("ADR")){ + }/* else if (wxSProperty == wxT("ADR")){ // See frmContactEditor-LoadAddress.cpp LoadADR(wxSPropertySeg1, wxSPropertySeg2, &ADRCount); - } else if (wxSProperty == wxT("EMAIL")){ + }*/ else if (wxSProperty == wxT("EMAIL")){ // See frmContactEditor-LoadEmail.cpp diff --git a/source/contacteditor/frmContactEditor-LoadAddress.cpp b/source/contacteditor/frmContactEditor-LoadAddress.cpp index e3d5f13..e4a9870 100644 --- a/source/contacteditor/frmContactEditor-LoadAddress.cpp +++ b/source/contacteditor/frmContactEditor-LoadAddress.cpp @@ -18,6 +18,153 @@ #include "frmContactEditor.h" +void frmContactEditor::LoadAddress(std::map *GeneralAddressList, + std::map *GeneralAddressListTown, + std::map *GeneralAddressListCounty, + std::map *GeneralAddressListPostCode, + std::map *GeneralAddressListPref, + std::map *HomeAddressList, + std::map *HomeAddressListTown, + std::map *HomeAddressListCounty, + std::map *HomeAddressListPostCode, + std::map *HomeAddressListPref, + std::map *BusinessAddressList, + std::map *BusinessAddressListTown, + std::map *BusinessAddressListCounty, + std::map *BusinessAddressListPostCode, + std::map *BusinessAddressListPref, + int *AddressCount){ + + long ListCtrlIndex = -1; + + // Deal with the general addresses. + + for (std::map::iterator GenAdrListIter = GeneralAddressList->begin(); + GenAdrListIter != GeneralAddressList->end(); + GenAdrListIter++){ + + wxListItem coldata; + + coldata.SetId(*AddressCount); + coldata.SetData(*AddressCount); + coldata.SetText(GenAdrListIter->second); + + ListCtrlIndex = lboAddresses->InsertItem(coldata); + + if (MapDataExists(AddressCount, GeneralAddressListTown)){ + + lboAddresses->SetItem(ListCtrlIndex, 1, GeneralAddressListTown->find(*AddressCount)->second); + + } + + if (MapDataExists(AddressCount, GeneralAddressListCounty)){ + + lboAddresses->SetItem(ListCtrlIndex, 2, GeneralAddressListCounty->find(*AddressCount)->second); + + } + + if (MapDataExists(AddressCount, GeneralAddressListPostCode)){ + + lboAddresses->SetItem(ListCtrlIndex, 3, GeneralAddressListPostCode->find(*AddressCount)->second); + + } + + if (MapDataExists(AddressCount, GeneralAddressListPref)){ + + lboAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", GeneralAddressListPref->find(*AddressCount)->second)); + + } + + (*AddressCount)++; + + } + + // Deal with the home addresses. + + for (std::map::iterator GenAdrListIter = HomeAddressList->begin(); + GenAdrListIter != HomeAddressList->end(); + GenAdrListIter++){ + + wxListItem coldata; + + coldata.SetId(*AddressCount); + coldata.SetData(*AddressCount); + coldata.SetText(GenAdrListIter->second); + + ListCtrlIndex = lboHomeAddresses->InsertItem(coldata); + + if (MapDataExists(AddressCount, HomeAddressListTown)){ + + lboHomeAddresses->SetItem(ListCtrlIndex, 1, HomeAddressListTown->find(*AddressCount)->second); + + } + + if (MapDataExists(AddressCount, HomeAddressListCounty)){ + + lboHomeAddresses->SetItem(ListCtrlIndex, 2, HomeAddressListCounty->find(*AddressCount)->second); + + } + + if (MapDataExists(AddressCount, HomeAddressListPostCode)){ + + lboHomeAddresses->SetItem(ListCtrlIndex, 3, HomeAddressListPostCode->find(*AddressCount)->second); + + } + + if (MapDataExists(AddressCount, HomeAddressListPref)){ + + lboHomeAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", HomeAddressListPref->find(*AddressCount)->second)); + + } + + (*AddressCount)++; + + } + + // Deal with the work addresses. + + for (std::map::iterator GenAdrListIter = BusinessAddressList->begin(); + GenAdrListIter != BusinessAddressList->end(); + GenAdrListIter++){ + + wxListItem coldata; + + coldata.SetId(*AddressCount); + coldata.SetData(*AddressCount); + coldata.SetText(GenAdrListIter->second); + + ListCtrlIndex = lboBusinessAddresses->InsertItem(coldata); + + if (MapDataExists(AddressCount, BusinessAddressListTown)){ + + lboBusinessAddresses->SetItem(ListCtrlIndex, 1, BusinessAddressListTown->find(*AddressCount)->second); + + } + + if (MapDataExists(AddressCount, BusinessAddressListCounty)){ + + lboBusinessAddresses->SetItem(ListCtrlIndex, 2, BusinessAddressListCounty->find(*AddressCount)->second); + + } + + if (MapDataExists(AddressCount, BusinessAddressListPostCode)){ + + lboBusinessAddresses->SetItem(ListCtrlIndex, 3, BusinessAddressListPostCode->find(*AddressCount)->second); + + } + + if (MapDataExists(AddressCount, BusinessAddressListPref)){ + + lboBusinessAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", BusinessAddressListPref->find(*AddressCount)->second)); + + } + + (*AddressCount)++; + + } + +} + void frmContactEditor::LoadADR(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *ADRCount){ size_t intPropertyLen = wxSPropertySeg1.Len(); diff --git a/source/contacteditor/frmContactEditor.h b/source/contacteditor/frmContactEditor.h index 38f0de3..8c05165 100644 --- a/source/contacteditor/frmContactEditor.h +++ b/source/contacteditor/frmContactEditor.h @@ -647,6 +647,22 @@ class frmContactEditor : public frmContactEditorADT wxString *NameSurname, wxString *NameOtherNames, wxString *NameSuffix); void LoadMember(std::map *GroupsList); + void LoadAddress(std::map *GeneralAddressList, + std::map *GeneralAddressListTown, + std::map *GeneralAddressListCounty, + std::map *GeneralAddressListPostCode, + std::map *GeneralAddressListPref, + std::map *HomeAddressList, + std::map *HomeAddressListTown, + std::map *HomeAddressListCounty, + std::map *HomeAddressListPostCode, + std::map *HomeAddressListPref, + std::map *BusinessAddressList, + std::map *BusinessAddressListTown, + std::map *BusinessAddressListCounty, + std::map *BusinessAddressListPostCode, + std::map *BusinessAddressListPref, + int *AddressCount); int intValueSeek = 1; bool IsGroup = FALSE; -- 2.39.5