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-LoadNote.cpp
1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadNote(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *NoteCount){
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 = 6;
14         int intPref = 0;                        
15         int intType = 0;
16         long ListCtrlIndex;
17         
18         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
19         
20         intPrevValue = 5;
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                 GeneralNoteList.insert(std::make_pair(intValueSeek, wxT("")));
62                 GeneralNoteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
63                 GeneralNoteListPID.insert(std::make_pair(intValueSeek, wxT("")));
64                 GeneralNoteListPref.insert(std::make_pair(intValueSeek, 0));
65                 GeneralNoteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
66                 GeneralNoteListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
68         } else if (intType == 1){
69         
70                 HomeNoteList.insert(std::make_pair(intValueSeek, wxT("")));
71                 HomeNoteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
72                 HomeNoteListPID.insert(std::make_pair(intValueSeek, wxT("")));
73                 HomeNoteListPref.insert(std::make_pair(intValueSeek, 0));
74                 HomeNoteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
75                 HomeNoteListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
76         
77         } else if (intType == 2){
79                 BusinessNoteList.insert(std::make_pair(intValueSeek, wxT("")));
80                 BusinessNoteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
81                 BusinessNoteListPID.insert(std::make_pair(intValueSeek, wxT("")));
82                 BusinessNoteListPref.insert(std::make_pair(intValueSeek, 0));
83                 BusinessNoteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
84                 BusinessNoteListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
85         
86         }
87         
88         intPrevValue = 5;                       
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){ GeneralNoteListAltID.erase(intValueSeek); GeneralNoteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
125                         else if (intType == 1){ HomeNoteListAltID.erase(intValueSeek); HomeNoteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
126                         else if (intType == 2){ BusinessNoteListAltID.erase(intValueSeek); BusinessNoteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
127                 
128                 } else if (PropertyName == wxT("PID")){
130                         if (intType == 0){ GeneralNoteListPID.erase(intValueSeek); GeneralNoteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
131                         else if (intType == 1){ HomeNoteListPID.erase(intValueSeek); HomeNoteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
132                         else if (intType == 2){ BusinessNoteListPID.erase(intValueSeek); BusinessNoteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
133                 
134                 } else if (PropertyName == wxT("PREF")){
135                         
136                         intPref = wxAtoi(PropertyValue);
137                 
138                         if (intType == 0){ GeneralNoteListPref.erase(intValueSeek); GeneralNoteListPref.insert(std::make_pair(intValueSeek, intPref)); }
139                         else if (intType == 1){ HomeNoteListPref.erase(intValueSeek); HomeNoteListPref.insert(std::make_pair(intValueSeek, intPref)); }
140                         else if (intType == 2){ BusinessNoteListPref.erase(intValueSeek); BusinessNoteListPref.insert(std::make_pair(intValueSeek, intPref)); }
141                 
142                 } else if (PropertyName == wxT("LANGUAGE")){
143                 
144                         if (intType == 0){ GeneralNoteListLanguage.erase(intValueSeek); GeneralNoteListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
145                         else if (intType == 1){ HomeNoteListLanguage.erase(intValueSeek); HomeNoteListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
146                         else if (intType == 2){ BusinessNoteListLanguage.erase(intValueSeek); BusinessNoteListLanguage.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         
181         if (intType == 0){
182         
183                 GeneralNoteList.erase(intValueSeek);
184                 GeneralNoteListType.erase(intValueSeek);
185                 GeneralNoteListTokens.erase(intValueSeek);
186                 GeneralNoteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
187                 GeneralNoteListType.insert(std::make_pair(intValueSeek, wxT("")));
188                 GeneralNoteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                     
189         
190                 //CaptureString(&wxSPropertySeg2, FALSE);
192                 coldata.SetText(wxSPropertySeg2);
193         
194                 ListCtrlIndex = lboNotes->InsertItem(coldata);
195                 
196                 if (intPref > 0 && intPref < 101){
197                 
198                         lboNotes->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
199                         
200                 }
201         
202         } else if (intType == 1){ 
203         
204                 HomeNoteList.erase(intValueSeek);
205                 HomeNoteListType.erase(intValueSeek);
206                 HomeNoteListTokens.erase(intValueSeek);                         
207                 HomeNoteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
208                 HomeNoteListType.insert(std::make_pair(intValueSeek, wxT("home")));
209                 HomeNoteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                        
210         
211                 CaptureString(&wxSPropertySeg2, FALSE);
213                 coldata.SetText(wxSPropertySeg2);                       
214         
215                 ListCtrlIndex = lboHomeNotes->InsertItem(coldata);
217                 if (intPref > 0 && intPref < 101){
218                 
219                         lboHomeNotes->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
220                         
221                 }
222         
223         } else if (intType == 2){ 
224         
225                 BusinessNoteList.erase(intValueSeek);
226                 BusinessNoteListType.erase(intValueSeek);
227                 BusinessNoteListTokens.erase(intValueSeek);                             
228                 BusinessNoteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
229                 BusinessNoteListType.insert(std::make_pair(intValueSeek, wxT("work")));
230                 BusinessNoteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                    
231         
232                 CaptureString(&wxSPropertySeg2, FALSE);
234                 coldata.SetText(wxSPropertySeg2);
235         
236                 ListCtrlIndex = lboBusinessNotes->InsertItem(coldata);
238                 if (intPref > 0 && intPref < 101){
239                 
240                         lboBusinessNotes->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
241                         
242                 }                               
243         
244         }
245         
246         NoteCount++;
247         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