X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=bc45c48371885f7a33630b79a942d2191c5f0f71;hb=ad53475636b679dbc91d6d516c7a5f68ac2ef418;hp=23c53f3999116a01fe7332b5962439067289d744;hpb=0a749c36a873e196f41a5f8c7da3f09592bf24fb;p=xestiaab%2F.git diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index 23c53f3..bc45c48 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -611,7 +611,7 @@ void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySe } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, &SourceListPref, &PropertyValue, SourceCount); + ProcessIntegerValue(&SourceListPref, &PropertyValue, SourceCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -769,7 +769,7 @@ void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySe } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, &GroupsListPref, &PropertyValue, GroupCount); + ProcessIntegerValue(&GroupsListPref, &PropertyValue, GroupCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -866,7 +866,7 @@ void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, &FullNamesListPref, &PropertyValue, FNCount); + ProcessIntegerValue(&FullNamesListPref, &PropertyValue, FNCount); } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){ @@ -1226,7 +1226,7 @@ void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString Property } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, NicknamesListPref, &PropertyValue, NicknameCount); + ProcessIntegerValue(NicknamesListPref, &PropertyValue, NicknameCount); } else if (PropertyName == wxT("LANGUAGE")){ @@ -1701,7 +1701,7 @@ void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString Property } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, TZListPref, &PropertyValue, TimeZoneCount); + ProcessIntegerValue(TZListPref, &PropertyValue, TimeZoneCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -1918,7 +1918,7 @@ void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertyS } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, AddressListPref, &PropertyValue, AddressCount); + ProcessIntegerValue(AddressListPref, &PropertyValue, AddressCount); } else { @@ -2183,7 +2183,7 @@ void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, EmailListPref, &PropertyValue, EmailCount); + ProcessIntegerValue(EmailListPref, &PropertyValue, EmailCount); } else { @@ -2318,7 +2318,7 @@ void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, IMListPref, &PropertyValue, IMCount); + ProcessIntegerValue(IMListPref, &PropertyValue, IMCount); } else { @@ -2611,24 +2611,8 @@ void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString Propert TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - TelephoneListPref->erase(*TelephoneCount); - TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber)); - - } + ProcessIntegerValue(TelephoneListPref, &PropertyValue, TelephoneCount); } else { @@ -2754,23 +2738,7 @@ void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString Property } else if (PropertyName == wxT("PREF")){ - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - LanguageListPref->erase(*LanguageCount); - LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber)); - - } + ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount); } else { @@ -2903,24 +2871,8 @@ void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString Proper GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - if (ValidNumber == TRUE){ - - GeopositionListPref->erase(*GeographicCount); - GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber)); - - } + ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount); } else { @@ -3155,9 +3107,8 @@ void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertyS } } else if (PropertyName == wxT("LANGUAGE")){ - - GeneralRelatedListLanguage.erase(*RelatedCount); - GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue)); + + ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount); } else if (PropertyName != wxT("TYPE")) { @@ -3308,25 +3259,9 @@ void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - WebsiteListPref->erase(*URLCount); - WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber)); - } - + ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount); + } else if (PropertyName == wxT("MEDIATYPE")){ WebsiteListMediatype->erase(*URLCount); @@ -3482,25 +3417,9 @@ void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - TitleListPref->erase(*TitleCount); - TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber)); - } - + ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount); + } else if (PropertyName == wxT("LANGUAGE")){ TitleListLanguage->erase(*TitleCount); @@ -3656,25 +3575,9 @@ void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - RoleListPref->erase(*RoleCount); - RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber)); - - } - + ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount); + } else if (PropertyName == wxT("LANGUAGE")){ RoleListLanguage->erase(*RoleCount); @@ -3839,25 +3742,9 @@ void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString Prop OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - OrganisationsListPref->erase(*OrganisationCount); - OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber)); - } - + ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount); + } else if (PropertyName == wxT("LANGUAGE")){ OrganisationsListLanguage->erase(*OrganisationCount); @@ -4013,25 +3900,9 @@ void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - if (ValidNumber == TRUE){ - - NoteListPref->erase(*NoteCount); - NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber)); - - } - + ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount); + } else if (PropertyName == wxT("LANGUAGE")){ NoteListLanguage->erase(*NoteCount); @@ -4158,25 +4029,9 @@ void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString Property CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - if (ValidNumber == TRUE){ - - CategoriesListPref.erase(*CategoryCount); - CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber)); - - } - + ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount); + } else if (PropertyName == wxT("LANGUAGE")){ CategoriesListLanguage.erase(*CategoryCount); @@ -4447,24 +4302,8 @@ void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - PicturesListPref.erase(*PhotoCount); - PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber)); - } + ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -4664,24 +4503,8 @@ void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - if (ValidNumber == TRUE){ - - LogosListPref.erase(*LogoCount); - LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber)); - - } + ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -4881,24 +4704,8 @@ void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - SoundsListPref.erase(*SoundCount); - SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber)); - } + ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -5103,24 +4910,8 @@ void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString Prope CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - CalendarListPref.erase(*CalURICount); - CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber)); - } + ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -5255,24 +5046,8 @@ void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxStrin CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - if (ValidNumber == TRUE){ - - CalendarRequestListPref.erase(*CalAdrURICount); - CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber)); - - } + ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -5407,24 +5182,8 @@ void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - FreeBusyListPref.erase(*FreeBusyAddressCount); - FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber)); - } + ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -5558,24 +5317,8 @@ void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - KeyListPref.erase(*KeyCount); - KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber)); - - } + ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount); } else { @@ -5749,8 +5492,20 @@ void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySe } -void ProcessIntegerValue(ContactDataObject *ContactData, - std::map *PrefPtr, +void ProcessStringValue(wxString *PropertyName, + wxString PropertyNameMatch, + std::map *MapPtr, + wxString *PropertyValue, + int *ItemCount){ + + if (*PropertyName == PropertyNameMatch){ + MapPtr->erase(*ItemCount); + MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue)); + } + +} + +void ProcessIntegerValue(std::map *PrefPtr, wxString *PropertyValue, int *ItemCount){