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-LoadTitle.cpp
1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadTitle(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *TitleCount){
5         std::map<int, int> SplitPoints;
6         std::map<int, int> SplitLength;
7         std::map<int, int>::iterator SLiter;                    
8         wxString PropertyData;
9         wxString PropertyName;
10         wxString PropertyValue;
11         wxString PropertyTokens;
12         bool FirstToken = TRUE;
13         int intPrevValue = 7;
14         int intPref = 0;                        
15         int intType = 0;
16         long ListCtrlIndex;
17         
18         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
19         
20         intPrevValue = 6;
21         
22         // Look for type before continuing.
23         
24         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
25         intiter != SplitPoints.end(); ++intiter){
26         
27                 SLiter = SplitLength.find(intiter->first);
28         
29                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
30                 
31                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
32                 PropertyName = PropertyElement.GetNextToken();                          
33                 PropertyValue = PropertyElement.GetNextToken();
34                 
35                 intPrevValue = intiter->second;
36                 
37                 if (PropertyName == wxT("TYPE")){
38                 
39                         if (PropertyValue == wxT("work")){
40                         
41                                 intType = 2;                                    
42                         
43                         } else if (PropertyValue == wxT("home")){
45                                 intType = 1;
46                         
47                         } else {
48                         
49                                 intType = 0;
50                         
51                         }
52                 
53                 }
54         
55         }
56         
57         // Setup blank lines for later on.
58         
59         if (intType == 0){
60         
61                 GeneralTitleList.insert(std::make_pair(intValueSeek, wxT("")));
62                 GeneralTitleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
63                 GeneralTitleListPID.insert(std::make_pair(intValueSeek, wxT("")));
64                 GeneralTitleListPref.insert(std::make_pair(intValueSeek, 0));
65                 GeneralTitleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
66                 GeneralTitleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
68         } else if (intType == 1){
69         
70                 HomeTitleList.insert(std::make_pair(intValueSeek, wxT("")));
71                 HomeTitleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
72                 HomeTitleListPID.insert(std::make_pair(intValueSeek, wxT("")));
73                 HomeTitleListPref.insert(std::make_pair(intValueSeek, 0));
74                 HomeTitleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
75                 HomeTitleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));                            
76         
77         } else if (intType == 2){
79                 BusinessTitleList.insert(std::make_pair(intValueSeek, wxT("")));
80                 BusinessTitleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
81                 BusinessTitleListPID.insert(std::make_pair(intValueSeek, wxT("")));
82                 BusinessTitleListPref.insert(std::make_pair(intValueSeek, 0));
83                 BusinessTitleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
84                 BusinessTitleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));                                
85         
86         }
87         
88         intPrevValue = 6;
89         
90         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
91         intiter != SplitPoints.end(); ++intiter){
92         
93                 SLiter = SplitLength.find(intiter->first);
94         
95                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
96                 
97                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
98                 PropertyName = PropertyElement.GetNextToken();                          
99                 PropertyValue = PropertyElement.GetNextToken();
100                 
101                 intPrevValue = intiter->second;
102                 
103                 // Process properties.
104                 
105                 size_t intPropertyValueLen = PropertyValue.Len();
106                 
107                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
108                         
109                         PropertyValue.Trim();
110                         PropertyValue.RemoveLast();
111                         
112                 }                               
113                 
114                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
115                         
116                         PropertyValue.Remove(0, 1);
117                         
118                 }                               
119                 
120                 ProcessCaptureStrings(&PropertyValue);
121                 
122                 if (PropertyName == wxT("ALTID")){
124                         if (intType == 0){ GeneralTitleListAltID.erase(intValueSeek); GeneralTitleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
125                         else if (intType == 1){ HomeTitleListAltID.erase(intValueSeek); HomeTitleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
126                         else if (intType == 2){ BusinessTitleListAltID.erase(intValueSeek); BusinessTitleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
127                 
128                 } else if (PropertyName == wxT("PID")){
130                         if (intType == 0){ GeneralTitleListPID.erase(intValueSeek); GeneralTitleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
131                         else if (intType == 1){ HomeTitleListPID.erase(intValueSeek); HomeTitleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
132                         else if (intType == 2){ BusinessTitleListPID.erase(intValueSeek); BusinessTitleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
133                 
134                 } else if (PropertyName == wxT("PREF")){
135                         
136                         intPref = wxAtoi(PropertyValue);
137                 
138                         if (intType == 0){ GeneralTitleListPref.erase(intValueSeek); GeneralTitleListPref.insert(std::make_pair(intValueSeek, intPref)); }
139                         else if (intType == 1){ HomeTitleListPref.erase(intValueSeek); HomeTitleListPref.insert(std::make_pair(intValueSeek, intPref)); }
140                         else if (intType == 2){ BusinessTitleListPref.erase(intValueSeek); BusinessTitleListPref.insert(std::make_pair(intValueSeek, intPref)); }
141                 
142                 } else if (PropertyName == wxT("LANGUAGE")){
143                 
144                         if (intType == 0){ GeneralTitleListLanguage.erase(intValueSeek); GeneralTitleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
145                         else if (intType == 1){ HomeTitleListLanguage.erase(intValueSeek); HomeTitleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
146                         else if (intType == 2){ BusinessTitleListLanguage.erase(intValueSeek); BusinessTitleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
147                 
148                 } else {
149                 
150                         // Something else we don't know about so append
151                         // to the tokens variable.
152                 
153                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
154                 
155                                 if (FirstToken == TRUE){
156                         
157                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
158                                         FirstToken = FALSE;
159                         
160                                 } else {
161                         
162                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
163                         
164                                 }
165                 
166                         }
167                 
168                 }
169         
170         }
171         
172         // Add the data to the General/Home/Work address variables.
173         
174         ProcessCaptureStrings(&wxSPropertySeg2);
175         
176         wxListItem coldata;
178         coldata.SetId(intValueSeek);
179         coldata.SetData(intValueSeek);
180         coldata.SetText(wxSPropertySeg2);
181         
182         if (intType == 0){
183         
184                 ListCtrlIndex = lboTitles->InsertItem(coldata);
185                 
186                 if (intPref > 0 && intPref < 101){
187                 
188                         lboTitles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
189                         
190                 }
191                 
192                 GeneralTitleList.erase(intValueSeek);
193                 GeneralTitleListType.erase(intValueSeek);
194                 GeneralTitleListTokens.erase(intValueSeek);
195                 GeneralTitleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
196                 GeneralTitleListType.insert(std::make_pair(intValueSeek, wxT("")));
197                 GeneralTitleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
198         
199         } else if (intType == 1){ 
200         
201                 ListCtrlIndex = lboHomeTitles->InsertItem(coldata);
203                 if (intPref > 0 && intPref < 101){
204                 
205                         lboHomeTitles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
206                         
207                 }
209                 HomeTitleList.erase(intValueSeek);
210                 HomeTitleListType.erase(intValueSeek);
211                 HomeTitleListTokens.erase(intValueSeek);                                
212                 HomeTitleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
213                 HomeTitleListType.insert(std::make_pair(intValueSeek, wxT("home")));
214                 HomeTitleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
215         
216         } else if (intType == 2){ 
217         
218                 ListCtrlIndex = lboBusinessTitles->InsertItem(coldata);
220                 if (intPref > 0 && intPref < 101){
221                 
222                         lboBusinessTitles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
223                         
224                 }
226                 BusinessTitleList.erase(intValueSeek);
227                 BusinessTitleListType.erase(intValueSeek);
228                 BusinessTitleListTokens.erase(intValueSeek);                            
229                 BusinessTitleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
230                 BusinessTitleListType.insert(std::make_pair(intValueSeek, wxT("work")));
231                 BusinessTitleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                           
232         
233         }
234         
235         TitleCount++;
236         intValueSeek++;
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