Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Split frmContactEditor-Load.cpp into 24 files to make it more manageable.
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadRelated.cpp
1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadRelated(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *RelatedCount){
5         size_t intPropertyLen = wxSPropertySeg1.Len();
6         std::map<int, int> SplitPoints;
7         std::map<int, int> SplitLength;
8         std::map<int, int>::iterator SLiter;                    
9         wxString PropertyData;
10         wxString PropertyName;
11         wxString PropertyValue;
12         wxString PropertyTokens;
13         wxString RelatedType;
14         wxString RelatedTypeOriginal;                   
15         wxString RelatedName;
16         bool FirstToken = TRUE;                 
17         int intSplitsFound = 0;
18         int intSplitSize = 0;
19         int intPrevValue = 9;
20         int intPref = 0;
21         long ListCtrlIndex;
22         
23         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
24         
25         intPrevValue = 8;
26         
27         // Look for type before continuing.
28         
29         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
30         intiter != SplitPoints.end(); ++intiter){
31         
32                 SLiter = SplitLength.find(intiter->first);
33         
34                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
35                 
36                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
37                 PropertyName = PropertyElement.GetNextToken();                          
38                 PropertyValue = PropertyElement.GetNextToken();
39                 
40                 intPrevValue = intiter->second;
41                 
42                 // Process these.
43                 
44                 RelatedTypeOriginal = PropertyValue;
45                 
46                 if (PropertyName == wxT("TYPE")){
47                 
48                         if (PropertyValue == wxT("contact")){
50                                 RelatedType = _("Contact");
52                         } else if (PropertyValue == wxT("acquaintance")){
54                                 RelatedType = _("Acquaintance");
56                         } else if (PropertyValue == wxT("friend")){
58                                 RelatedType = _("Friend");
60                         } else if (PropertyValue == wxT("met")){
62                                 RelatedType = _("Met");
64                         } else if (PropertyValue == wxT("co-worker")){
66                                 RelatedType = _("Co-worker");
68                         } else if (PropertyValue == wxT("colleague")){
70                                 RelatedType = _("Colleague");
72                         } else if (PropertyValue == wxT("co-resident")){
74                                 RelatedType = _("Co-resident");
76                         } else if (PropertyValue == wxT("neighbor")){
78                                 RelatedType = _("Neighbour");
80                         } else if (PropertyValue == wxT("child")){
82                                 RelatedType = _("Child");
84                         } else if (PropertyValue == wxT("parent")){
86                                 RelatedType = _("Parent");
88                         } else if (PropertyValue == wxT("sibling")){
90                                 RelatedType = _("Sibling");
92                         } else if (PropertyValue == wxT("spouse")){
94                                 RelatedType = _("Spouse");
96                         } else if (PropertyValue == wxT("kin")){
98                                 RelatedType = _("Kin");
100                         } else if (PropertyValue == wxT("muse")){
102                                 RelatedType = _("Muse");
104                         } else if (PropertyValue == wxT("crush")){
106                                 RelatedType = _("Crush");
108                         } else if (PropertyValue == wxT("date")){
110                                 RelatedType = _("Date");
112                         } else if (PropertyValue == wxT("sweetheart")){
114                                 RelatedType = _("Sweetheart");
116                         } else if (PropertyValue == wxT("me")){
118                                 RelatedType = _("Me");
120                         } else if (PropertyValue == wxT("agent")){
122                                 RelatedType = _("Agent");
124                         } else if (PropertyValue == wxT("emergency")){
126                                 RelatedType = _("Emergency");
128                         } else {
130                                 RelatedType = PropertyValue;
132                         }
133                 
134                 }
135         
136         }
137         
138         intPrevValue = 8;                       
139         
140         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
141         intiter != SplitPoints.end(); ++intiter){
142         
143                 SLiter = SplitLength.find(intiter->first);
144         
145                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
146                 
147                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
148                 PropertyName = PropertyElement.GetNextToken();                          
149                 PropertyValue = PropertyElement.GetNextToken();
150                 
151                 intPrevValue = intiter->second;
152                 
153                 // Process properties.
154                 
155                 size_t intPropertyValueLen = PropertyValue.Len();
156                 
157                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
158                         
159                         PropertyValue.Trim();
160                         PropertyValue.RemoveLast();
161                         
162                 }                               
163                 
164                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
165                         
166                         PropertyValue.Remove(0, 1);
167                         
168                 }
169                 
170                 ProcessCaptureStrings(&PropertyValue);                  
171                 
172                 if (PropertyName == wxT("ALTID")){
174                         GeneralRelatedListAltID.erase(intValueSeek);
175                         GeneralRelatedListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
176                 
177                 } else if (PropertyName == wxT("PID")){
179                         GeneralRelatedListPID.erase(intValueSeek);
180                         GeneralRelatedListPID.insert(std::make_pair(intValueSeek, PropertyValue));
181                 
182                 } else if (PropertyName == wxT("PREF")){
183                         
184                         intPref = wxAtoi(PropertyValue);
185                 
186                         if (intPref > 0 && intPref < 101){
187                 
188                                 GeneralRelatedListPref.erase(intValueSeek);
189                                 GeneralRelatedListPref.insert(std::make_pair(intValueSeek, intPref));
191                         
192                         }
193                 
194                 } else if (PropertyName == wxT("LANGUAGE")){
195                 
196                         GeneralRelatedListLanguage.erase(intValueSeek);
197                         GeneralRelatedListLanguage.insert(std::make_pair(intValueSeek, PropertyValue));
198                 
199                 } else {
200                 
201                         // Something else we don't know about so append
202                         // to the tokens variable.
203                 
204                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
205                 
206                                 if (FirstToken == TRUE){
207                         
208                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
209                                         FirstToken = FALSE;
210                         
211                                 } else {
212                         
213                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
214                         
215                                 }
216                 
217                         }
218                 
219                 }
220         
221         }                                       
222         
223         // Split the address. 
225         //std::map<int, int>::iterator SLiter;
226         intPropertyLen = wxSPropertySeg2.Len();
227         SplitPoints.clear();
228         SplitLength.clear();
229         intSplitsFound = 0;
230         intSplitSize = 0;
231         intPrevValue = 0;
232         
233         // Add the data to the General/Home/Work address variables.
234         
235         wxListItem coldata;
237         coldata.SetId(intValueSeek);
238         coldata.SetData(intValueSeek);
239         coldata.SetText(RelatedType);
240         
241         ProcessCaptureStrings(&wxSPropertySeg2);
243         ListCtrlIndex = lboRelated->InsertItem(coldata);
245         lboRelated->SetItem(ListCtrlIndex, 1, wxSPropertySeg2);
247         if (intPref > 0 && intPref < 101){
248                 
249                 lboRelated->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
250                         
251         }
252                 
253         GeneralRelatedList.erase(intValueSeek);
254         GeneralRelatedListRelType.erase(intValueSeek);
255         GeneralRelatedListType.erase(intValueSeek);
256         GeneralRelatedListTokens.erase(intValueSeek);
257         GeneralRelatedList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
258         GeneralRelatedListRelType.insert(std::make_pair(intValueSeek, RelatedTypeOriginal));                    
259         GeneralRelatedListType.insert(std::make_pair(intValueSeek, RelatedTypeOriginal));
260         GeneralRelatedListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
261         
262         RelatedCount++;
263         intValueSeek++;
265
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