From 5482d15a8b8fa45ff634f183fa3af669de55e4b9 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Wed, 30 Dec 2015 00:04:57 +0000 Subject: [PATCH] Implemented LoadData for even better simplification. --- .../contacteditor/frmContactEditor-Load.cpp | 118 +++++++++++++++++- source/contacteditor/frmContactEditor.h | 11 ++ 2 files changed, 123 insertions(+), 6 deletions(-) diff --git a/source/contacteditor/frmContactEditor-Load.cpp b/source/contacteditor/frmContactEditor-Load.cpp index aa5b0e9..a48d0a3 100644 --- a/source/contacteditor/frmContactEditor-Load.cpp +++ b/source/contacteditor/frmContactEditor-Load.cpp @@ -187,23 +187,42 @@ bool frmContactEditor::LoadContact(wxString Filename){ // Process the timezones (TZ) (frmContactEditor-LoadTimeZone.cpp) - LoadTimeZone(&ContactEditorData.GeneralTZList, + LoadData(&ContactEditorData.GeneralTZList, &ContactEditorData.GeneralTZListPref, + lboTimezones, &ContactEditorData.HomeTZList, &ContactEditorData.HomeTZListPref, + lboHomeTimezones, &ContactEditorData.BusinessTZList, &ContactEditorData.BusinessTZListPref, + lboBusinessTimezones, &TZCount); - // Process the emails (frmContactEditor-LoadEmail.cpp) + // Process the emails (EMAIL) (frmContactEditor-LoadEmail.cpp) - LoadEmail(&ContactEditorData.GeneralEmailList, + LoadData(&ContactEditorData.GeneralEmailList, &ContactEditorData.GeneralEmailListPref, + lboEmails, &ContactEditorData.HomeEmailList, &ContactEditorData.HomeEmailListPref, + lboHomeEmails, &ContactEditorData.BusinessEmailList, &ContactEditorData.BusinessEmailListPref, - &EmailCount); + lboBusinessEmail, + &EmailCount); + + // Process the nicknames (NICKNAME) (frmContactEditor-LoadNickname.cpp) + + LoadData(&ContactEditorData.GeneralNicknamesList, + &ContactEditorData.GeneralNicknamesListPref, + lboNicknames, + &ContactEditorData.HomeNicknamesList, + &ContactEditorData.HomeNicknamesListPref, + lboHomeNicknames, + &ContactEditorData.BusinessNicknamesList, + &ContactEditorData.BusinessNicknamesListPref, + lboBusinessNicknames, + &NicknameCount); for (std::map::iterator iter = ContactFileLines.begin(); iter != ContactFileLines.end(); ++iter){ @@ -330,13 +349,13 @@ bool frmContactEditor::LoadContact(wxString Filename){ LoadN(wxSPropertySeg1, wxSPropertySeg2, &NameProcessed, &ContactData); - }*/ else if (wxSProperty == wxT("NICKNAME")){ + } else if (wxSProperty == wxT("NICKNAME")){ // See frmContactEditor-LoadNickname.cpp LoadNickname(wxSPropertySeg1, wxSPropertySeg2, &NicknameCount, &ContactData); - }/* else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){ + } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){ // See frmContactEditor-LoadGender.cpp @@ -627,4 +646,91 @@ void frmContactEditor::SplitValues(wxString *PropertyLine, } +} + +void frmContactEditor::LoadData(std::map *GeneralList, + std::map *GeneralListPref, + wxListCtrl *GeneralListCtrl, + std::map *HomeList, + std::map *HomeListPref, + wxListCtrl *HomeListCtrl, + std::map *BusinessList, + std::map *BusinessListPref, + wxListCtrl *BusinessListCtrl, + int *DataCount){ + + long ListCtrlIndex = -1; + + // Deal with the general addresses. + + for (std::map::iterator Iter = GeneralList->begin(); + Iter != GeneralList->end(); + Iter++){ + + wxListItem coldata; + + coldata.SetId(*DataCount); + coldata.SetData(*DataCount); + coldata.SetText(Iter->second); + + ListCtrlIndex = GeneralListCtrl->InsertItem(coldata); + + if (MapDataExists(DataCount, GeneralListPref)){ + + GeneralListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", GeneralListPref->find(*DataCount)->second)); + + } + + (*DataCount)++; + + } + + // Deal with the home addresses. + + for (std::map::iterator Iter = HomeList->begin(); + Iter != HomeList->end(); + Iter++){ + + wxListItem coldata; + + coldata.SetId(*DataCount); + coldata.SetData(*DataCount); + coldata.SetText(Iter->second); + + ListCtrlIndex = HomeListCtrl->InsertItem(coldata); + + if (MapDataExists(DataCount, HomeListPref)){ + + HomeListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", HomeListPref->find(*DataCount)->second)); + + } + + (*DataCount)++; + + } + + // Deal with the work addresses. + + for (std::map::iterator Iter = BusinessList->begin(); + Iter != BusinessList->end(); + Iter++){ + + wxListItem coldata; + + coldata.SetId(*DataCount); + coldata.SetData(*DataCount); + coldata.SetText(Iter->second); + + ListCtrlIndex = BusinessListCtrl->InsertItem(coldata); + + if (MapDataExists(DataCount, BusinessListPref)){ + + BusinessListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", BusinessListPref->find(*DataCount)->second)); + + } + + (*DataCount)++; + + } + } \ No newline at end of file diff --git a/source/contacteditor/frmContactEditor.h b/source/contacteditor/frmContactEditor.h index a9f0ab5..a0cf860 100644 --- a/source/contacteditor/frmContactEditor.h +++ b/source/contacteditor/frmContactEditor.h @@ -639,6 +639,17 @@ class frmContactEditor : public frmContactEditorADT void LoadCalFreeBusy(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *FreeBusyCount); void LoadKey(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *KeyCount); + void LoadData(std::map *GeneralList, + std::map *GeneralListPref, + wxListCtrl *GeneralListCtrl, + std::map *HomeList, + std::map *HomeListPref, + wxListCtrl *HomeListCtrl, + std::map *BusinessList, + std::map *BusinessTZPref, + wxListCtrl *BusinessListCtrl, + int *DataCount); + void LoadGender(wxString *GenderComponent, wxString *GenderIdentity); void LoadBirthday(wxString *BirthdayData, bool *BirthdayText); void LoadAnniversary(wxString *AnniversaryData, bool *AnniversaryText); -- 2.39.5