X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=f6a3da2d3fe464fd2316b82929b0858885098a4c;hb=9d51c004d7508cdb1caee7f3faa953247c8a0867;hp=ffca4603a8bd88aae2ed7336a80b9fef1355606b;hpb=6cd8a887c1e346fef41e94e6593248246cf3c729;p=xestiaab%2F.git diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index ffca460..f6a3da2 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -611,24 +611,8 @@ void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySe } 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){ - - SourceListPref.erase(*SourceCount); - SourceListPref.insert(std::make_pair(*SourceCount, PriorityNumber)); + ProcessIntegerValue(this, &SourceListPref, &PropertyValue, SourceCount); - } - } else if (PropertyName == wxT("MEDIATYPE")){ SourceListMediatype.erase(*SourceCount); @@ -785,23 +769,7 @@ void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySe } 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){ - - GroupsListPref.erase(*GroupCount); - GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber)); - - } + ProcessIntegerValue(this, &GroupsListPref, &PropertyValue, GroupCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -898,23 +866,7 @@ void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, } 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){ - - FullNamesListPref.erase(*FNCount); - FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber)); - - } + ProcessIntegerValue(this, &FullNamesListPref, &PropertyValue, FNCount); } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){ @@ -1274,23 +1226,7 @@ void ContactDataObject::ProcessNickname(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){ - - NicknamesListPref->erase(*NicknameCount); - NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber)); - - } + ProcessIntegerValue(this, NicknamesListPref, &PropertyValue, NicknameCount); } else if (PropertyName == wxT("LANGUAGE")){ @@ -1765,23 +1701,7 @@ void ContactDataObject::ProcessTimeZone(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){ - - TZListPref->erase(*TimeZoneCount); - TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber)); - - } + ProcessIntegerValue(this, TZListPref, &PropertyValue, TimeZoneCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -5877,6 +5797,31 @@ void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySe } +void ProcessIntegerValue(ContactDataObject *ContactData, + std::map *PrefPtr, + wxString *PropertyValue, + int *ItemCount){ + + int PriorityNumber = 0; + bool ValidNumber = TRUE; + + try{ + PriorityNumber = std::stoi(PropertyValue->ToStdString()); + } + + catch(std::invalid_argument &e){ + ValidNumber = FALSE; + } + + if (ValidNumber == TRUE){ + + PrefPtr->erase(*ItemCount); + PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber)); + + } + +} + void SplitValues(wxString *PropertyLine, std::map *SplitPoints, std::map *SplitLength,