Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Implemented LoadData for even better simplification.
[xestiaab/.git] / source / contacteditor / frmContactEditor-Load.cpp
1 // frmContactEditor-Load.cpp - frmContactEditor load contact 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 <map>
21 #include <wx/ffile.h>
22 #include <wx/tokenzr.h>
23 #include <wx/datetime.h>
24 #include <wx/dir.h>
26 #include "frmContactEditor.h"
28 #include "../enums.h"
29 #include "../version.h"
30 #include "../vcard/vcard.h"
31 #include "../common/textprocessing.h"
32 #include "../common/dirs.h"
33 #include "cdo/ContactDataObject.h"
35 bool frmContactEditor::LoadContact(wxString Filename){
37         // Load the contact into the contact editor.
38         
39         wxFFile ContactFile;
40         wxString wxSContactString;
41         wxString ContactLine;
42         vCard ContactData;
43         XABViewMode XVMData;
44         if (StartupEditMode == FALSE){
45                 XVMData = MainPtr->GetViewMode();
46         }
47         
48         wxSContactFilename = Filename;
49         
50         // Check if we are using wxWidgets version 2.8 or less and
51         // execute the required command accordingly.
52         
53 #if wxABI_VERSION < 20900
54         ContactFile.Open(Filename.c_str(), wxT("r"));
55 #else
56         ContactFile.Open(Filename, wxT("r"));
57 #endif  
58         
59         if (ContactFile.IsOpened() == FALSE){
60         
61                 return FALSE;
62         
63         }
64         
65         ContactEditorData.LoadFile(Filename);
66         
67         ContactFile.ReadAll(&wxSContactString, wxConvAuto());
68         
69         // Split the lines.
70         
71         std::map<int, wxString> ContactFileLines;
72         std::map<int, wxString>::iterator striter;
73         
74         wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
76         int ContactLineSeek = 0;
78         while (wSTContactFileLines.HasMoreTokens() == TRUE){
80                 ContactLine = wSTContactFileLines.GetNextToken();
81                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
82                 ContactLineSeek++;              
83         
84         }
86         // Get the line.
88         bool QuoteMode = FALSE;
89         bool PropertyFind = TRUE;
90         bool HasExtraNicknames = FALSE;
91         bool IgnoreGender = FALSE;
92         bool ExtraLineSeek = TRUE;
93         //bool BirthdayProcessed = FALSE;
94         //bool AnniversaryProcessed = FALSE;
95         bool FNProcessed = FALSE;
96         bool GenderProcessed = FALSE;
97         bool NameProcessed = FALSE;
98         //bool UIDProcessed = FALSE;
99         //bool KindProcessed = FALSE;
100         bool ETagFound = FALSE;
101         bool ETagOrigFound = FALSE;
102         bool VersionProcessed = FALSE;
103         int intExtraNickname = 0;
104         wxString wxSProperty;
105         wxString wxSPropertySeg1;
106         wxString wxSPropertySeg2;
107         wxString wxSPropertyNextLine;
108         size_t ContactLineLen = 0;
109         int QuoteBreakPoint = 0;
110         int FNCount = 0;
111         int NameCount = 0;
112         int NicknameCount = 0;
113         int ADRCount = 0;
114         int EmailCount = 0;
115         int IMPPCount = 0;
116         int TelCount = 0;
117         int LangCount = 0;
118         int TZCount = 0;
119         int GeoCount = 0;
120         int URLCount = 0;
121         int RelatedCount = 0;
122         int TitleCount = 0;
123         int RoleCount = 0;
124         int OrgCount = 0;
125         int NoteCount = 0;
126         int CategoryCount = 0;
127         int GroupCount = 0;
128         int PhotoCount = 0;
129         int LogoCount = 0;
130         int SoundCount = 0;
131         int CalAdrCount = 0;
132         int CalReqAdrCount = 0;
133         int FreeBusyCount = 0;
134         int KeyCount = 0;
135         int VendorCount = 0;
136         int XTokenCount = 0;
137         //int intValueSeek = 1;
139         // Process the unique ID (UID)
140         
141         UIDToken = ContactEditorData.UIDToken;
143         // Process the contact type (KIND) (frmContactEditor-LoadGroup.cpp)
145         LoadKind(&ContactEditorData.ContactKind);
147         // Process the Birthday (BDAY) (frmContactEditor-LoadBADays.cpp)
148         
149         LoadBirthday(&ContactEditorData.Birthday, &ContactEditorData.BirthdayText);
151         // Process the Anniversary (ANNIVERSARY) (frmContactEditor-LoadBADays.cpp)
152         
153         LoadAnniversary(&ContactEditorData.Anniversary, &ContactEditorData.AnniversaryText);
155         // Process the Gender (GENDER) (frmContactEditor-LoadGender.cpp)
156         
157         LoadGender(&ContactEditorData.Gender, &ContactEditorData.GenderDetails);
158         
159         // Process the Name (N) (frmContactEditor-LoadName.cpp)
160         
161         LoadName(&ContactEditorData.NameTitle, &ContactEditorData.NameForename,
162                 &ContactEditorData.NameSurname, &ContactEditorData.NameOtherNames,
163                 &ContactEditorData.NameSuffix);
164                 
165         // Process the group members (MEMBER) (frmContactEditor-LoadGroup.cpp)
166                 
167         LoadMember(&ContactEditorData.GroupsList);
169         // Process the addresses (ADR) (frmContactEditor-LoadAddress.cpp)
170         
171         LoadAddress(&ContactEditorData.GeneralAddressList,
172                 &ContactEditorData.GeneralAddressListTown,
173                 &ContactEditorData.GeneralAddressListCounty,
174                 &ContactEditorData.GeneralAddressListPostCode,
175                 &ContactEditorData.GeneralAddressListPref,
176                 &ContactEditorData.HomeAddressList,
177                 &ContactEditorData.HomeAddressListTown,
178                 &ContactEditorData.HomeAddressListCounty,
179                 &ContactEditorData.HomeAddressListPostCode,
180                 &ContactEditorData.HomeAddressListPref,
181                 &ContactEditorData.BusinessAddressList,
182                 &ContactEditorData.BusinessAddressListTown,
183                 &ContactEditorData.BusinessAddressListCounty,
184                 &ContactEditorData.BusinessAddressListPostCode,
185                 &ContactEditorData.BusinessAddressListPref,
186                 &ADRCount);
188         // Process the timezones (TZ) (frmContactEditor-LoadTimeZone.cpp)
189         
190         LoadData(&ContactEditorData.GeneralTZList,
191                 &ContactEditorData.GeneralTZListPref,
192                 lboTimezones,
193                 &ContactEditorData.HomeTZList,
194                 &ContactEditorData.HomeTZListPref,
195                 lboHomeTimezones,
196                 &ContactEditorData.BusinessTZList,
197                 &ContactEditorData.BusinessTZListPref,
198                 lboBusinessTimezones,
199                 &TZCount);
200                 
201         // Process the emails (EMAIL) (frmContactEditor-LoadEmail.cpp)
202         
203         LoadData(&ContactEditorData.GeneralEmailList,
204                 &ContactEditorData.GeneralEmailListPref,
205                 lboEmails,
206                 &ContactEditorData.HomeEmailList,
207                 &ContactEditorData.HomeEmailListPref,
208                 lboHomeEmails,
209                 &ContactEditorData.BusinessEmailList,
210                 &ContactEditorData.BusinessEmailListPref,
211                 lboBusinessEmail,
212                 &EmailCount);
214         // Process the nicknames (NICKNAME) (frmContactEditor-LoadNickname.cpp)
215         
216         LoadData(&ContactEditorData.GeneralNicknamesList,
217                 &ContactEditorData.GeneralNicknamesListPref,
218                 lboNicknames,
219                 &ContactEditorData.HomeNicknamesList,
220                 &ContactEditorData.HomeNicknamesListPref,
221                 lboHomeNicknames,
222                 &ContactEditorData.BusinessNicknamesList,
223                 &ContactEditorData.BusinessNicknamesListPref,
224                 lboBusinessNicknames,
225                 &NicknameCount);
227         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
228          iter != ContactFileLines.end(); ++iter){
229         
230                 // Find the colon which splits the start bit from the data part.
231                 
232                 ContactLine = iter->second;
233                 
234                 while (ExtraLineSeek == TRUE){
235                 
236                         // Check if there is extra data on the next line 
237                         // (indicated by space or tab at the start) and add data.
238                 
239                         iter++;
240                         
241                         if (iter == ContactFileLines.end()){
242                         
243                                 iter--;
244                                 break;
245                         
246                         }                       
247                 
248                         wxSPropertyNextLine = iter->second;
249                         
250                 
251                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
252                 
253                                 wxSPropertyNextLine.Remove(0, 1);
254                                 //wxSPropertyNextLine.Trim(FALSE);
255                                 //ContactLine.Trim();
256                                 ContactLine.Append(wxSPropertyNextLine);
257                 
258                         } else {
259                         
260                                 iter--;
261                                 ExtraLineSeek = FALSE;
262                         
263                         }
264                 
265                 }
267                 ContactLineLen = ContactLine.Len();
268                 
269                 // Make sure we are not in quotation mode.
270                 // Make sure colon does not have \ or \\ before it.
271                 
272                 for (int i = 0; i <= ContactLineLen; i++){
273                 
274                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
275                         
276                                 PropertyFind = FALSE;
277                         
278                         } else if (PropertyFind == TRUE){
279                         
280                                 wxSProperty.Append(ContactLine.Mid(i, 1));
281                         
282                         }               
283                 
284                         if (ContactLine.Mid(i, 1) == wxT("\"")){
285                         
286                                 if (QuoteMode == TRUE){
287                                 
288                                         QuoteMode = FALSE;
289                                 
290                                 } else {
291                         
292                                         QuoteMode = TRUE;
293                                         
294                                 }
295                         
296                         }
297                         
298                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
299                         
300                                 QuoteBreakPoint = i;
301                                 break;
302                         
303                         }
304                 
305                 }
306                 
307                 // Split that line at the point into two variables (ignore the colon).
308                 
309                 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
310                 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
311                 
312                 // Add the data into the contact editor depending on what it is.                                
313                 
314                 if (wxSProperty == wxT("VERSION") && VersionProcessed == FALSE){
315                 
316                         // Check if version is 4.0, otherwise don't
317                         // load.
318                         
319                         if (wxSPropertySeg2 != wxT("4.0")){
320                                 wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
321                                         _("Contact not supported"), wxICON_ERROR);
322                                 this->Close();
323                                 return FALSE;
324                         }
325                         
326                         VersionProcessed = TRUE;
327                 
328                 }/* if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
329                 
330                         // See frmContactEditor-LoadGroup.cpp
331                 
332                         LoadKind(wxSPropertySeg2);
333                 
334                 }/* else if (wxSProperty == wxT("MEMBER")){
336                         // See frmContactEditor-LoadGroup.cpp
338                         LoadMember(wxSPropertySeg2, &GroupCount);               
339                 
340                 }*/ else if (wxSProperty == wxT("FN")){
341                 
342                         // See frmContactEditor-LoadName.cpp
343                 
344                         LoadFN(wxSPropertySeg1, wxSPropertySeg2, &FNCount, &FNProcessed, &ContactData);
345                 
346                 }/* else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
347                 
348                         // See frmContactEditor-LoadName.cpp
349                 
350                         LoadN(wxSPropertySeg1, wxSPropertySeg2, &NameProcessed, &ContactData);
351                 
352                 } else if (wxSProperty == wxT("NICKNAME")){
353                         
354                         // See frmContactEditor-LoadNickname.cpp
355                         
356                         LoadNickname(wxSPropertySeg1, wxSPropertySeg2, &NicknameCount, &ContactData);
357                         
358                 } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
359                 
360                         // See frmContactEditor-LoadGender.cpp
361                 
362                         LoadGender(wxSPropertySeg1, wxSPropertySeg2, &GenderProcessed, &ContactData);
363                 
364                 } else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
366                         // See frmContactEditor-LoadBADays.cpp
368                         LoadBDay(wxSPropertySeg1, wxSPropertySeg2, &BirthdayProcessed);
369                 
370                 } else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
371                         
372                         // See frmContactEditor-LoadBADays.cpp
373                         
374                         LoadAnniversary(wxSPropertySeg1, wxSPropertySeg2, &AnniversaryProcessed);
375                 
376                 } else if (wxSProperty == wxT("TZ")){
377                 
378                         // See frmContactEditor-LoadTimeZone.cpp
379                 
380                         LoadTimeZone(wxSPropertySeg1, wxSPropertySeg2, &TZCount);       
381                 
382                 }  else if (wxSProperty == wxT("ADR")){
383                         
384                         // See frmContactEditor-LoadAddress.cpp
385                 
386                         LoadADR(wxSPropertySeg1, wxSPropertySeg2, &ADRCount);
387                 
388                 } else if (wxSProperty == wxT("EMAIL")){
389                 
390                         // See frmContactEditor-LoadEmail.cpp
391                         
392                         LoadEmail(wxSPropertySeg1, wxSPropertySeg2, &EmailCount);       
393                 
394                 }*/ else if (wxSProperty == wxT("IMPP")){
395                 
396                         // See frmContactEditor-LoadIM.cpp
397                 
398                         LoadIM(wxSPropertySeg1, wxSPropertySeg2, &IMPPCount);
399                 
400                 } else if (wxSProperty == wxT("TEL")){
401                 
402                         // See frmContactEditor-LoadTelephone.cpp
403                 
404                         LoadTelephone(wxSPropertySeg1, wxSPropertySeg2, &TelCount);
405                 
406                 } else if (wxSProperty == wxT("LANG")){
407                 
408                         // See frmContactEditor-LoadLanguage.cpp
409                         
410                         LoadLanguage(wxSPropertySeg1, wxSPropertySeg2, &LangCount);
411                 
412                 } else if (wxSProperty == wxT("GEO")){
413                 
414                         // See frmContactEditor-LoadGeo.cpp
415                         
416                         LoadGeo(wxSPropertySeg1, wxSPropertySeg2, &GeoCount);   
417                 
418                 } else if (wxSProperty == wxT("RELATED")){
419                         
420                         // See fromContactEditor-LoadRelated.cpp
421                         
422                         LoadRelated(wxSPropertySeg1, wxSPropertySeg2, &RelatedCount);           
423                 
424                 } else if (wxSProperty == wxT("URL")){
426                         // See frmContactEditor-LoadURL.cpp
427                 
428                         LoadURL(wxSPropertySeg1, wxSPropertySeg2, &URLCount);
429                 
430                 } else if (wxSProperty == wxT("TITLE")) {
431                 
432                         // See frmContactEditor-LoadTitle.cpp
433                         
434                         LoadTitle(wxSPropertySeg1, wxSPropertySeg2, &TitleCount);
435                         
436                 } else if (wxSProperty == wxT("ROLE")) {
438                         // See frmContactEditor-LoadRole.cpp
439                 
440                         LoadRole(wxSPropertySeg1, wxSPropertySeg2, &RoleCount);
441                         
442                 } else if (wxSProperty == wxT("ORG")) {
443                 
444                         // See frmContactEditor-LoadOrg.cpp
445                         
446                         LoadOrg(wxSPropertySeg1, wxSPropertySeg2, &OrgCount);
447                         
448                 } else if (wxSProperty == wxT("NOTE")) {
450                         // See frmContactEditor-LoadNote.cpp
452                         LoadNote(wxSPropertySeg1, wxSPropertySeg2, &NoteCount); 
453                         
454                 } else if (wxSProperty == wxT("CATEGORIES")) {
455                 
456                         // See frmContactEditor-LoadCategory.cpp
457                 
458                         LoadCategory(wxSPropertySeg1, wxSPropertySeg2, &CategoryCount); 
459                         
460                 } else if (wxSProperty == wxT("PHOTO")) {
461                 
462                         // See frmContactEditor-LoadPhoto.cpp
463                         
464                         LoadPhoto(wxSPropertySeg1, wxSPropertySeg2, &PhotoCount);
466                 } else if (wxSProperty == wxT("LOGO")) {
467                 
468                         // See frmContactEditor-LoadLogo.cpp
469                 
470                         LoadLogo(wxSPropertySeg1, wxSPropertySeg2, &LogoCount);
471                         
472                 } else if (wxSProperty == wxT("SOUND")) {
473                 
474                         // See frmContactEditor-LoadSound.cpp
475                         
476                         LoadSound(wxSPropertySeg1, wxSPropertySeg2, &SoundCount);
477                         
478                 } else if (wxSProperty == wxT("CALURI")){
480                         // See frmContactEditor-LoadCalendar.cpp
481                         
482                         LoadCalURI(wxSPropertySeg1, wxSPropertySeg2, &CalAdrCount);
483                 
484                 } else if (wxSProperty == wxT("CALADRURI")){
486                         // See frmContactEditor-LoadCalendar.cpp
487                         
488                         LoadCalAdrURI(wxSPropertySeg1, wxSPropertySeg2, &CalReqAdrCount);
489                 
490                 } else if (wxSProperty == wxT("FBURL")){
492                         // See frmContactEditor-LoadCalendar.cpp
494                         LoadCalFreeBusy(wxSPropertySeg1, wxSPropertySeg2, &FreeBusyCount);
496                 } else if (wxSProperty == wxT("KEY")){
497                 
498                         // See frmContactEditor-LoadKey.cpp
499                         
500                         LoadKey(wxSPropertySeg1, wxSPropertySeg2, &KeyCount);
501                 
502                 }/* else if (wxSProperty == wxT("UID") && UIDProcessed == FALSE){
503                 
504                         UIDToken = wxSPropertySeg2;
505                         UIDProcessed = TRUE;
506                 
507                 }*/ else if (wxSProperty.Mid(0, 3) == wxT("VND")){
508                 
509                         // Split the Vendor three ways.
510                         
511                         wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
512                         
513                         wxString wxSVNDID;
514                         wxString wxSVNDPropName;
515                         long ListCtrlIndex;                     
517                         while (wSTVendorDetails.HasMoreTokens() == TRUE){
518                         
519                                 wSTVendorDetails.GetNextToken();
520                                 wxSVNDID = wSTVendorDetails.GetNextToken();
521                                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
522                                 break;
523                         
524                         }
525                         
526                         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
527                         
528                                 // Setup the values for later processing.
529                         
530                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
531                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
532                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));
533                         
534                                 // Add the data to the vendor variables.
535                         
536                                 wxListItem coldata;
537                 
538                                 coldata.SetId(intValueSeek);
539                                 coldata.SetData(intValueSeek);
540                                 coldata.SetText(wxSVNDID + wxT("-") + wxSVNDPropName);
542                                 ListCtrlIndex = lboVendorNamespace->InsertItem(coldata);
543                                 
544                                 VendorList.erase(intValueSeek);
545                                 VendorListPEN.erase(intValueSeek);
546                                 VendorListElement.erase(intValueSeek);
547                         
548                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
549                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
550                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));                         
551                         
552                                 VendorCount++;
553                                 intValueSeek++;
554                         
555                         }       
556                 
557                 } else if (wxSProperty.Mid(0, 2) == wxT("X-")){
558                 
559                         long ListCtrlIndex;
560                         
561                         XTokenList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
562                         XTokenListTokens.insert(std::make_pair(intValueSeek, wxSPropertySeg1.Mid(2)));
563                         
564                         // Add to the form.
565                         
566                         wxListItem coldata;
567                 
568                         coldata.SetId(intValueSeek);
569                         coldata.SetData(intValueSeek);
570                         coldata.SetText(wxSPropertySeg1.Mid(2));
572                         ListCtrlIndex = lboXToken->InsertItem(coldata);
573                         
574                         XTokenCount++;
575                         intValueSeek++;
576                         
577                 
578                 }
579                 
580                 // Reset the variables.
581                 
582                 QuoteMode = FALSE;
583                 PropertyFind = TRUE;
584                 ExtraLineSeek = TRUE;
585                 ContactLineLen = 0;
586                 QuoteBreakPoint = 0;
587                 ContactLine.Clear();
588                 wxSProperty.Clear();    
589         
590         }
591         
592         FMTimer.SetFilename(Filename);
593         FMTimer.Start(10000, FALSE);
594         
595         EditMode = TRUE;
596         
597         return TRUE;
600 void frmContactEditor::SplitValues(wxString *PropertyLine, 
601         std::map<int,int> *SplitPoints, 
602         std::map<int,int> *SplitLength, 
603         int intSize){
604         
605         size_t intPropertyLen = PropertyLine->Len();
606         int intSplitsFound = 0;
607         int intSplitSize = 0;
608         int intSplitSeek = 0;
609         
610         for (int i = intSize; i <= intPropertyLen; i++){
612                 intSplitSize++;
613         
614                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
615                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
616            
617                     if (intSplitsFound == 0){
618             
619                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
620           
621                     } else {
622            
623                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
624             
625                     }
626             
627                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
628             
629                     intSplitsFound++;
630                     intSplitSeek = i;
631                     intSplitSize = 0;
632             
633                 }
635         }
637         if (intSplitsFound == 0){
639                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
640                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
642         } else {
644                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
645                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
647         }
651 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
652                 std::map<int, int> *GeneralListPref,
653                 wxListCtrl *GeneralListCtrl,
654                 std::map<int, wxString> *HomeList,
655                 std::map<int, int> *HomeListPref,
656                 wxListCtrl *HomeListCtrl,
657                 std::map<int, wxString> *BusinessList,
658                 std::map<int, int> *BusinessListPref,
659                 wxListCtrl *BusinessListCtrl,
660                 int *DataCount){
662         long ListCtrlIndex = -1;
664         // Deal with the general addresses.
665         
666         for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
667                 Iter != GeneralList->end();
668                 Iter++){
669         
670                 wxListItem coldata;
672                 coldata.SetId(*DataCount);
673                 coldata.SetData(*DataCount);
674                 coldata.SetText(Iter->second);
675                 
676                 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
678                 if (MapDataExists(DataCount, GeneralListPref)){
679                 
680                         GeneralListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
681                 
682                 }
683         
684                 (*DataCount)++;
685         
686         }
687         
688         // Deal with the home addresses.
689         
690         for (std::map<int,wxString>::iterator Iter = HomeList->begin();
691                 Iter != HomeList->end();
692                 Iter++){
693         
694                 wxListItem coldata;
696                 coldata.SetId(*DataCount);
697                 coldata.SetData(*DataCount);
698                 coldata.SetText(Iter->second);
699                 
700                 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
702                 if (MapDataExists(DataCount, HomeListPref)){
703                 
704                         HomeListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
705                 
706                 }
707         
708                 (*DataCount)++;
709         
710         }
711         
712         // Deal with the work addresses.
713         
714         for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
715                 Iter != BusinessList->end();
716                 Iter++){
717         
718                 wxListItem coldata;
720                 coldata.SetId(*DataCount);
721                 coldata.SetData(*DataCount);
722                 coldata.SetText(Iter->second);
723                 
724                 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
725                                 
726                 if (MapDataExists(DataCount, BusinessListPref)){
727                 
728                         BusinessListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
729                 
730                 }
731         
732                 (*DataCount)++;
733         
734         }
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