Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Replaced the PREF code in PHOTO with ProcessIntergerValue.
[xestiaab/.git] / source / contacteditor / ContactDataObject.cpp
index 3d408c9..55cce69 100644 (file)
@@ -1701,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")){
 
@@ -1933,24 +1917,8 @@ void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertyS
                        AddressListMediatype->insert(std::make_pair(*AddressCount, 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){
 
-                               AddressListPref->erase(*AddressCount);
-                               AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
-
-                       }
+                       ProcessIntegerValue(this, AddressListPref, &PropertyValue, AddressCount);
                
                } else {
                
@@ -2215,23 +2183,7 @@ void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg
                
                } 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){
-
-                               EmailListPref->erase(*EmailCount);
-                               EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
-
-                       }
+                       ProcessIntegerValue(this, EmailListPref, &PropertyValue, EmailCount);
                
                } else {
                
@@ -2366,23 +2318,7 @@ void ContactDataObject::ProcessIM(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){
-
-                               IMListPref->erase(*IMCount);
-                               IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
-
-                       }
+                       ProcessIntegerValue(this, IMListPref, &PropertyValue, IMCount);
                
                } else {
                
@@ -2675,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(this, TelephoneListPref, &PropertyValue, TelephoneCount);
                
                } else {
                
@@ -2818,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(this, LanguageListPref, &PropertyValue, LanguageCount);
                
                } else {
                
@@ -2967,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(this, GeopositionListPref, &PropertyValue, GeographicCount);
                
                } else {
                
@@ -3219,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(this, &GeneralRelatedListPref, &PropertyValue, RelatedCount);
                
                } else if (PropertyName != wxT("TYPE")) {
                
@@ -3372,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(this, WebsiteListPref, &PropertyValue, URLCount);
+                                                       
                } else if (PropertyName == wxT("MEDIATYPE")){
                
                        WebsiteListMediatype->erase(*URLCount);
@@ -3546,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(this, TitleListPref, &PropertyValue, TitleCount);
+                       
                } else if (PropertyName == wxT("LANGUAGE")){
                
                        TitleListLanguage->erase(*TitleCount);
@@ -3720,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(this, RoleListPref, &PropertyValue, RoleCount);
+                               
                } else if (PropertyName == wxT("LANGUAGE")){
                
                        RoleListLanguage->erase(*RoleCount);
@@ -3903,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(this, OrganisationsListPref, &PropertyValue, OrganisationCount);
+                       
                } else if (PropertyName == wxT("LANGUAGE")){
                
                        OrganisationsListLanguage->erase(*OrganisationCount);
@@ -4077,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(this, NoteListPref, &PropertyValue, NoteCount);
+               
                } else if (PropertyName == wxT("LANGUAGE")){
                
                        NoteListLanguage->erase(*NoteCount);
@@ -4222,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(this, &CategoriesListPref, &PropertyValue, CategoryCount);
+                       
                } else if (PropertyName == wxT("LANGUAGE")){
                
                        CategoriesListLanguage.erase(*CategoryCount);
@@ -4511,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(this, &PicturesListPref, &PropertyValue, PhotoCount);
                
                } else if (PropertyName == wxT("MEDIATYPE")){
                
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy