Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added SaveTitle function to the ContactDataObject
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Tue, 28 Jun 2016 21:51:36 +0000 (22:51 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Tue, 28 Jun 2016 21:51:36 +0000 (22:51 +0100)
source/contacteditor/cdo/ContactDataObject-Save.cpp
source/contacteditor/cdo/ContactDataObject.h

index 01af8ed..2a436cb 100644 (file)
@@ -118,14 +118,18 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
        
        // Process TITLE.
 
-       for (std::map<int, wxString>::iterator TitleIter = GeneralTitleList.begin();
-               TitleIter != GeneralTitleList.end(); TitleIter++){
-               
-               SaveData->Append("TITLE:");
-               SaveData->Append(TitleIter->second);
-               SaveData->Append("\n");
-                       
-       }
+       SaveTitle(&GeneralTitleList, &GeneralTitleListLanguage,
+               &GeneralTitleListAltID, &GeneralTitleListPID,
+               &GeneralTitleListType, &GeneralTitleListPref,
+               &GeneralTitleListTokens, SaveData, "");
+       SaveTitle(&HomeTitleList, &HomeTitleListLanguage,
+               &HomeTitleListAltID, &HomeTitleListPID,
+               &HomeTitleListType, &HomeTitleListPref,
+               &HomeTitleListTokens, SaveData, "home");
+       SaveTitle(&BusinessTitleList, &BusinessTitleListLanguage,
+               &BusinessTitleListAltID, &BusinessTitleListPID,
+               &BusinessTitleListType, &BusinessTitleListPref,
+               &BusinessTitleListTokens, SaveData, "work");
        
        // Write the end part of the vCard data file.
        
@@ -135,4 +139,83 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
        
        return SaveDataStatus;
        
+}
+
+void ContactDataObject::SaveTitle(map<int, wxString> *TitleList, map<int, wxString> *TitleListLanguage,
+       map<int, wxString> *TitleListAltID, map<int, wxString> *TitleListPID,
+       map<int, wxString> *TitleListType, map<int, int> *TitleListPref,
+       map<int, wxString> *TitleListTokens, wxString *SaveData, wxString DataType){
+
+       wxString ProcessData = "";
+               
+       for (std::map<int, wxString>::iterator TitleIter = TitleList->begin();
+               TitleIter != TitleList->end(); TitleIter++){
+
+               ProcessData.Append("TITLE");
+                       
+               // Check if there is a value for TYPE.
+               
+               if (DataType.size() > 0){
+               
+                       ProcessData.Append(";TYPE=");
+                       ProcessData.Append(DataType);
+                       
+               }
+               
+               // Check if there is a value for ALTID.
+               
+               if ((*TitleListAltID)[TitleIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*TitleListAltID)[TitleIter->first]);
+                       
+               }
+
+               // Check if there is a value for LANGUAGE.
+               
+               if ((*TitleListLanguage)[TitleIter->first].size() > 0){
+               
+                       ProcessData.Append(";LANGUAGE=");
+                       ProcessData.Append((*TitleListLanguage)[TitleIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*TitleListPID)[TitleIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*TitleListPID)[TitleIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*TitleListPref)[TitleIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*TitleListPref)[TitleIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*TitleListTokens)[TitleIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*TitleListTokens)[TitleIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append(TitleIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+                       
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
 }
\ No newline at end of file
index cc7d3d9..b9bfdf1 100644 (file)
@@ -27,6 +27,8 @@
 #include "../../vcard/vcard.h"
 #include "../../common/textprocessing.h"
 
+using namespace std;
+
 enum ContactLoadStatus{
        CONTACTLOAD_UNITTESTFAIL = -1,
        CONTACTLOAD_OK,
@@ -93,6 +95,13 @@ class ContactDataObject{
        void ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount);
        void ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount);
        void ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount);
+       
+       // Save functions
+       
+       void SaveTitle(map<int, wxString> *TitleList, map<int, wxString> *TitleListLanguage,
+               map<int, wxString> *TitleListAltID, map<int, wxString> *TitleListPID,
+               map<int, wxString> *TitleListType, map<int, int> *TitleListPref,
+               map<int, wxString> *TitleListTokens, wxString *SaveData, wxString DataType);
 
        public:
 
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