Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added copyright and license header to the C++ source and header files in the contacte...
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadRelated.cpp
1 // frmContactEditor-LoadRelated.cpp - frmContactEditor load related subroutines.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "frmContactEditor.h"
21 void frmContactEditor::LoadRelated(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *RelatedCount){
23         size_t intPropertyLen = wxSPropertySeg1.Len();
24         std::map<int, int> SplitPoints;
25         std::map<int, int> SplitLength;
26         std::map<int, int>::iterator SLiter;                    
27         wxString PropertyData;
28         wxString PropertyName;
29         wxString PropertyValue;
30         wxString PropertyTokens;
31         wxString RelatedType;
32         wxString RelatedTypeOriginal;                   
33         wxString RelatedName;
34         bool FirstToken = TRUE;                 
35         int intSplitsFound = 0;
36         int intSplitSize = 0;
37         int intPrevValue = 9;
38         int intPref = 0;
39         long ListCtrlIndex;
40         
41         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
42         
43         intPrevValue = 8;
44         
45         // Look for type before continuing.
46         
47         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
48         intiter != SplitPoints.end(); ++intiter){
49         
50                 SLiter = SplitLength.find(intiter->first);
51         
52                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
53                 
54                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
55                 PropertyName = PropertyElement.GetNextToken();                          
56                 PropertyValue = PropertyElement.GetNextToken();
57                 
58                 intPrevValue = intiter->second;
59                 
60                 // Process these.
61                 
62                 RelatedTypeOriginal = PropertyValue;
63                 
64                 if (PropertyName == wxT("TYPE")){
65                 
66                         if (PropertyValue == wxT("contact")){
68                                 RelatedType = _("Contact");
70                         } else if (PropertyValue == wxT("acquaintance")){
72                                 RelatedType = _("Acquaintance");
74                         } else if (PropertyValue == wxT("friend")){
76                                 RelatedType = _("Friend");
78                         } else if (PropertyValue == wxT("met")){
80                                 RelatedType = _("Met");
82                         } else if (PropertyValue == wxT("co-worker")){
84                                 RelatedType = _("Co-worker");
86                         } else if (PropertyValue == wxT("colleague")){
88                                 RelatedType = _("Colleague");
90                         } else if (PropertyValue == wxT("co-resident")){
92                                 RelatedType = _("Co-resident");
94                         } else if (PropertyValue == wxT("neighbor")){
96                                 RelatedType = _("Neighbour");
98                         } else if (PropertyValue == wxT("child")){
100                                 RelatedType = _("Child");
102                         } else if (PropertyValue == wxT("parent")){
104                                 RelatedType = _("Parent");
106                         } else if (PropertyValue == wxT("sibling")){
108                                 RelatedType = _("Sibling");
110                         } else if (PropertyValue == wxT("spouse")){
112                                 RelatedType = _("Spouse");
114                         } else if (PropertyValue == wxT("kin")){
116                                 RelatedType = _("Kin");
118                         } else if (PropertyValue == wxT("muse")){
120                                 RelatedType = _("Muse");
122                         } else if (PropertyValue == wxT("crush")){
124                                 RelatedType = _("Crush");
126                         } else if (PropertyValue == wxT("date")){
128                                 RelatedType = _("Date");
130                         } else if (PropertyValue == wxT("sweetheart")){
132                                 RelatedType = _("Sweetheart");
134                         } else if (PropertyValue == wxT("me")){
136                                 RelatedType = _("Me");
138                         } else if (PropertyValue == wxT("agent")){
140                                 RelatedType = _("Agent");
142                         } else if (PropertyValue == wxT("emergency")){
144                                 RelatedType = _("Emergency");
146                         } else {
148                                 RelatedType = PropertyValue;
150                         }
151                 
152                 }
153         
154         }
155         
156         intPrevValue = 8;                       
157         
158         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
159         intiter != SplitPoints.end(); ++intiter){
160         
161                 SLiter = SplitLength.find(intiter->first);
162         
163                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
164                 
165                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
166                 PropertyName = PropertyElement.GetNextToken();                          
167                 PropertyValue = PropertyElement.GetNextToken();
168                 
169                 intPrevValue = intiter->second;
170                 
171                 // Process properties.
172                 
173                 size_t intPropertyValueLen = PropertyValue.Len();
174                 
175                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
176                         
177                         PropertyValue.Trim();
178                         PropertyValue.RemoveLast();
179                         
180                 }                               
181                 
182                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
183                         
184                         PropertyValue.Remove(0, 1);
185                         
186                 }
187                 
188                 ProcessCaptureStrings(&PropertyValue);                  
189                 
190                 if (PropertyName == wxT("ALTID")){
192                         GeneralRelatedListAltID.erase(intValueSeek);
193                         GeneralRelatedListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
194                 
195                 } else if (PropertyName == wxT("PID")){
197                         GeneralRelatedListPID.erase(intValueSeek);
198                         GeneralRelatedListPID.insert(std::make_pair(intValueSeek, PropertyValue));
199                 
200                 } else if (PropertyName == wxT("PREF")){
201                         
202                         intPref = wxAtoi(PropertyValue);
203                 
204                         if (intPref > 0 && intPref < 101){
205                 
206                                 GeneralRelatedListPref.erase(intValueSeek);
207                                 GeneralRelatedListPref.insert(std::make_pair(intValueSeek, intPref));
209                         
210                         }
211                 
212                 } else if (PropertyName == wxT("LANGUAGE")){
213                 
214                         GeneralRelatedListLanguage.erase(intValueSeek);
215                         GeneralRelatedListLanguage.insert(std::make_pair(intValueSeek, PropertyValue));
216                 
217                 } else {
218                 
219                         // Something else we don't know about so append
220                         // to the tokens variable.
221                 
222                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
223                 
224                                 if (FirstToken == TRUE){
225                         
226                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
227                                         FirstToken = FALSE;
228                         
229                                 } else {
230                         
231                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
232                         
233                                 }
234                 
235                         }
236                 
237                 }
238         
239         }                                       
240         
241         // Split the address. 
243         //std::map<int, int>::iterator SLiter;
244         intPropertyLen = wxSPropertySeg2.Len();
245         SplitPoints.clear();
246         SplitLength.clear();
247         intSplitsFound = 0;
248         intSplitSize = 0;
249         intPrevValue = 0;
250         
251         // Add the data to the General/Home/Work address variables.
252         
253         wxListItem coldata;
255         coldata.SetId(intValueSeek);
256         coldata.SetData(intValueSeek);
257         coldata.SetText(RelatedType);
258         
259         ProcessCaptureStrings(&wxSPropertySeg2);
261         ListCtrlIndex = lboRelated->InsertItem(coldata);
263         lboRelated->SetItem(ListCtrlIndex, 1, wxSPropertySeg2);
265         if (intPref > 0 && intPref < 101){
266                 
267                 lboRelated->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
268                         
269         }
270                 
271         GeneralRelatedList.erase(intValueSeek);
272         GeneralRelatedListRelType.erase(intValueSeek);
273         GeneralRelatedListType.erase(intValueSeek);
274         GeneralRelatedListTokens.erase(intValueSeek);
275         GeneralRelatedList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
276         GeneralRelatedListRelType.insert(std::make_pair(intValueSeek, RelatedTypeOriginal));                    
277         GeneralRelatedListType.insert(std::make_pair(intValueSeek, RelatedTypeOriginal));
278         GeneralRelatedListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
279         
280         RelatedCount++;
281         intValueSeek++;
283
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