Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Implemented LANG using ContactDataObject.
[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).
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).
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).
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);
226                 
227         // Process the languages (LANG).
228         
229         LoadData(&ContactEditorData.GeneralLanguageList,
230                 &ContactEditorData.GeneralLanguageListPref,
231                 lboLanguages,
232                 &ContactEditorData.HomeLanguageList,
233                 &ContactEditorData.HomeLanguageListPref,
234                 lboHomeLanguages,
235                 &ContactEditorData.BusinessLanguageList,
236                 &ContactEditorData.BusinessLanguageListPref,
237                 lboBusinessLanguages,
238                 &LangCount);
240         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
241          iter != ContactFileLines.end(); ++iter){
242         
243                 // Find the colon which splits the start bit from the data part.
244                 
245                 ContactLine = iter->second;
246                 
247                 while (ExtraLineSeek == TRUE){
248                 
249                         // Check if there is extra data on the next line 
250                         // (indicated by space or tab at the start) and add data.
251                 
252                         iter++;
253                         
254                         if (iter == ContactFileLines.end()){
255                         
256                                 iter--;
257                                 break;
258                         
259                         }                       
260                 
261                         wxSPropertyNextLine = iter->second;
262                         
263                 
264                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
265                 
266                                 wxSPropertyNextLine.Remove(0, 1);
267                                 //wxSPropertyNextLine.Trim(FALSE);
268                                 //ContactLine.Trim();
269                                 ContactLine.Append(wxSPropertyNextLine);
270                 
271                         } else {
272                         
273                                 iter--;
274                                 ExtraLineSeek = FALSE;
275                         
276                         }
277                 
278                 }
280                 ContactLineLen = ContactLine.Len();
281                 
282                 // Make sure we are not in quotation mode.
283                 // Make sure colon does not have \ or \\ before it.
284                 
285                 for (int i = 0; i <= ContactLineLen; i++){
286                 
287                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
288                         
289                                 PropertyFind = FALSE;
290                         
291                         } else if (PropertyFind == TRUE){
292                         
293                                 wxSProperty.Append(ContactLine.Mid(i, 1));
294                         
295                         }               
296                 
297                         if (ContactLine.Mid(i, 1) == wxT("\"")){
298                         
299                                 if (QuoteMode == TRUE){
300                                 
301                                         QuoteMode = FALSE;
302                                 
303                                 } else {
304                         
305                                         QuoteMode = TRUE;
306                                         
307                                 }
308                         
309                         }
310                         
311                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
312                         
313                                 QuoteBreakPoint = i;
314                                 break;
315                         
316                         }
317                 
318                 }
319                 
320                 // Split that line at the point into two variables (ignore the colon).
321                 
322                 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
323                 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
324                 
325                 // Add the data into the contact editor depending on what it is.                                
326                 
327                 if (wxSProperty == wxT("VERSION") && VersionProcessed == FALSE){
328                 
329                         // Check if version is 4.0, otherwise don't
330                         // load.
331                         
332                         if (wxSPropertySeg2 != wxT("4.0")){
333                                 wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
334                                         _("Contact not supported"), wxICON_ERROR);
335                                 this->Close();
336                                 return FALSE;
337                         }
338                         
339                         VersionProcessed = TRUE;
340                 
341                 }/* if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
342                 
343                         // See frmContactEditor-LoadGroup.cpp
344                 
345                         LoadKind(wxSPropertySeg2);
346                 
347                 }/* else if (wxSProperty == wxT("MEMBER")){
349                         // See frmContactEditor-LoadGroup.cpp
351                         LoadMember(wxSPropertySeg2, &GroupCount);               
352                 
353                 }*/ else if (wxSProperty == wxT("FN")){
354                 
355                         // See frmContactEditor-LoadName.cpp
356                 
357                         LoadFN(wxSPropertySeg1, wxSPropertySeg2, &FNCount, &FNProcessed, &ContactData);
358                 
359                 }/* else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
360                 
361                         // See frmContactEditor-LoadName.cpp
362                 
363                         LoadN(wxSPropertySeg1, wxSPropertySeg2, &NameProcessed, &ContactData);
364                 
365                 } else if (wxSProperty == wxT("NICKNAME")){
366                         
367                         // See frmContactEditor-LoadNickname.cpp
368                         
369                         LoadNickname(wxSPropertySeg1, wxSPropertySeg2, &NicknameCount, &ContactData);
370                         
371                 } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
372                 
373                         // See frmContactEditor-LoadGender.cpp
374                 
375                         LoadGender(wxSPropertySeg1, wxSPropertySeg2, &GenderProcessed, &ContactData);
376                 
377                 } else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
379                         // See frmContactEditor-LoadBADays.cpp
381                         LoadBDay(wxSPropertySeg1, wxSPropertySeg2, &BirthdayProcessed);
382                 
383                 } else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
384                         
385                         // See frmContactEditor-LoadBADays.cpp
386                         
387                         LoadAnniversary(wxSPropertySeg1, wxSPropertySeg2, &AnniversaryProcessed);
388                 
389                 } else if (wxSProperty == wxT("TZ")){
390                 
391                         // See frmContactEditor-LoadTimeZone.cpp
392                 
393                         LoadTimeZone(wxSPropertySeg1, wxSPropertySeg2, &TZCount);       
394                 
395                 }  else if (wxSProperty == wxT("ADR")){
396                         
397                         // See frmContactEditor-LoadAddress.cpp
398                 
399                         LoadADR(wxSPropertySeg1, wxSPropertySeg2, &ADRCount);
400                 
401                 } else if (wxSProperty == wxT("EMAIL")){
402                 
403                         // See frmContactEditor-LoadEmail.cpp
404                         
405                         LoadEmail(wxSPropertySeg1, wxSPropertySeg2, &EmailCount);       
406                 
407                 }*/ else if (wxSProperty == wxT("IMPP")){
408                 
409                         // See frmContactEditor-LoadIM.cpp
410                 
411                         LoadIM(wxSPropertySeg1, wxSPropertySeg2, &IMPPCount);
412                 
413                 } else if (wxSProperty == wxT("TEL")){
414                 
415                         // See frmContactEditor-LoadTelephone.cpp
416                 
417                         LoadTelephone(wxSPropertySeg1, wxSPropertySeg2, &TelCount);
418                 
419                 }/* else if (wxSProperty == wxT("LANG")){
420                 
421                         // See frmContactEditor-LoadLanguage.cpp
422                         
423                         LoadLanguage(wxSPropertySeg1, wxSPropertySeg2, &LangCount);
424                 
425                 }*/ else if (wxSProperty == wxT("GEO")){
426                 
427                         // See frmContactEditor-LoadGeo.cpp
428                         
429                         LoadGeo(wxSPropertySeg1, wxSPropertySeg2, &GeoCount);   
430                 
431                 } else if (wxSProperty == wxT("RELATED")){
432                         
433                         // See fromContactEditor-LoadRelated.cpp
434                         
435                         LoadRelated(wxSPropertySeg1, wxSPropertySeg2, &RelatedCount);           
436                 
437                 } else if (wxSProperty == wxT("URL")){
439                         // See frmContactEditor-LoadURL.cpp
440                 
441                         LoadURL(wxSPropertySeg1, wxSPropertySeg2, &URLCount);
442                 
443                 } else if (wxSProperty == wxT("TITLE")) {
444                 
445                         // See frmContactEditor-LoadTitle.cpp
446                         
447                         LoadTitle(wxSPropertySeg1, wxSPropertySeg2, &TitleCount);
448                         
449                 } else if (wxSProperty == wxT("ROLE")) {
451                         // See frmContactEditor-LoadRole.cpp
452                 
453                         LoadRole(wxSPropertySeg1, wxSPropertySeg2, &RoleCount);
454                         
455                 } else if (wxSProperty == wxT("ORG")) {
456                 
457                         // See frmContactEditor-LoadOrg.cpp
458                         
459                         LoadOrg(wxSPropertySeg1, wxSPropertySeg2, &OrgCount);
460                         
461                 } else if (wxSProperty == wxT("NOTE")) {
463                         // See frmContactEditor-LoadNote.cpp
465                         LoadNote(wxSPropertySeg1, wxSPropertySeg2, &NoteCount); 
466                         
467                 } else if (wxSProperty == wxT("CATEGORIES")) {
468                 
469                         // See frmContactEditor-LoadCategory.cpp
470                 
471                         LoadCategory(wxSPropertySeg1, wxSPropertySeg2, &CategoryCount); 
472                         
473                 } else if (wxSProperty == wxT("PHOTO")) {
474                 
475                         // See frmContactEditor-LoadPhoto.cpp
476                         
477                         LoadPhoto(wxSPropertySeg1, wxSPropertySeg2, &PhotoCount);
479                 } else if (wxSProperty == wxT("LOGO")) {
480                 
481                         // See frmContactEditor-LoadLogo.cpp
482                 
483                         LoadLogo(wxSPropertySeg1, wxSPropertySeg2, &LogoCount);
484                         
485                 } else if (wxSProperty == wxT("SOUND")) {
486                 
487                         // See frmContactEditor-LoadSound.cpp
488                         
489                         LoadSound(wxSPropertySeg1, wxSPropertySeg2, &SoundCount);
490                         
491                 } else if (wxSProperty == wxT("CALURI")){
493                         // See frmContactEditor-LoadCalendar.cpp
494                         
495                         LoadCalURI(wxSPropertySeg1, wxSPropertySeg2, &CalAdrCount);
496                 
497                 } else if (wxSProperty == wxT("CALADRURI")){
499                         // See frmContactEditor-LoadCalendar.cpp
500                         
501                         LoadCalAdrURI(wxSPropertySeg1, wxSPropertySeg2, &CalReqAdrCount);
502                 
503                 } else if (wxSProperty == wxT("FBURL")){
505                         // See frmContactEditor-LoadCalendar.cpp
507                         LoadCalFreeBusy(wxSPropertySeg1, wxSPropertySeg2, &FreeBusyCount);
509                 } else if (wxSProperty == wxT("KEY")){
510                 
511                         // See frmContactEditor-LoadKey.cpp
512                         
513                         LoadKey(wxSPropertySeg1, wxSPropertySeg2, &KeyCount);
514                 
515                 }/* else if (wxSProperty == wxT("UID") && UIDProcessed == FALSE){
516                 
517                         UIDToken = wxSPropertySeg2;
518                         UIDProcessed = TRUE;
519                 
520                 }*/ else if (wxSProperty.Mid(0, 3) == wxT("VND")){
521                 
522                         // Split the Vendor three ways.
523                         
524                         wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
525                         
526                         wxString wxSVNDID;
527                         wxString wxSVNDPropName;
528                         long ListCtrlIndex;                     
530                         while (wSTVendorDetails.HasMoreTokens() == TRUE){
531                         
532                                 wSTVendorDetails.GetNextToken();
533                                 wxSVNDID = wSTVendorDetails.GetNextToken();
534                                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
535                                 break;
536                         
537                         }
538                         
539                         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
540                         
541                                 // Setup the values for later processing.
542                         
543                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
544                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
545                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));
546                         
547                                 // Add the data to the vendor variables.
548                         
549                                 wxListItem coldata;
550                 
551                                 coldata.SetId(intValueSeek);
552                                 coldata.SetData(intValueSeek);
553                                 coldata.SetText(wxSVNDID + wxT("-") + wxSVNDPropName);
555                                 ListCtrlIndex = lboVendorNamespace->InsertItem(coldata);
556                                 
557                                 VendorList.erase(intValueSeek);
558                                 VendorListPEN.erase(intValueSeek);
559                                 VendorListElement.erase(intValueSeek);
560                         
561                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
562                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
563                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));                         
564                         
565                                 VendorCount++;
566                                 intValueSeek++;
567                         
568                         }       
569                 
570                 } else if (wxSProperty.Mid(0, 2) == wxT("X-")){
571                 
572                         long ListCtrlIndex;
573                         
574                         XTokenList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
575                         XTokenListTokens.insert(std::make_pair(intValueSeek, wxSPropertySeg1.Mid(2)));
576                         
577                         // Add to the form.
578                         
579                         wxListItem coldata;
580                 
581                         coldata.SetId(intValueSeek);
582                         coldata.SetData(intValueSeek);
583                         coldata.SetText(wxSPropertySeg1.Mid(2));
585                         ListCtrlIndex = lboXToken->InsertItem(coldata);
586                         
587                         XTokenCount++;
588                         intValueSeek++;
589                         
590                 
591                 }
592                 
593                 // Reset the variables.
594                 
595                 QuoteMode = FALSE;
596                 PropertyFind = TRUE;
597                 ExtraLineSeek = TRUE;
598                 ContactLineLen = 0;
599                 QuoteBreakPoint = 0;
600                 ContactLine.Clear();
601                 wxSProperty.Clear();    
602         
603         }
604         
605         FMTimer.SetFilename(Filename);
606         FMTimer.Start(10000, FALSE);
607         
608         EditMode = TRUE;
609         
610         return TRUE;
613 void frmContactEditor::SplitValues(wxString *PropertyLine, 
614         std::map<int,int> *SplitPoints, 
615         std::map<int,int> *SplitLength, 
616         int intSize){
617         
618         size_t intPropertyLen = PropertyLine->Len();
619         int intSplitsFound = 0;
620         int intSplitSize = 0;
621         int intSplitSeek = 0;
622         
623         for (int i = intSize; i <= intPropertyLen; i++){
625                 intSplitSize++;
626         
627                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
628                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
629            
630                     if (intSplitsFound == 0){
631             
632                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
633           
634                     } else {
635            
636                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
637             
638                     }
639             
640                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
641             
642                     intSplitsFound++;
643                     intSplitSeek = i;
644                     intSplitSize = 0;
645             
646                 }
648         }
650         if (intSplitsFound == 0){
652                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
653                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
655         } else {
657                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
658                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
660         }
664 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
665                 std::map<int, int> *GeneralListPref,
666                 wxListCtrl *GeneralListCtrl,
667                 std::map<int, wxString> *HomeList,
668                 std::map<int, int> *HomeListPref,
669                 wxListCtrl *HomeListCtrl,
670                 std::map<int, wxString> *BusinessList,
671                 std::map<int, int> *BusinessListPref,
672                 wxListCtrl *BusinessListCtrl,
673                 int *DataCount){
675         long ListCtrlIndex = -1;
677         // Deal with the general addresses.
678         
679         for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
680                 Iter != GeneralList->end();
681                 Iter++){
682         
683                 wxListItem coldata;
685                 coldata.SetId(*DataCount);
686                 coldata.SetData(*DataCount);
687                 coldata.SetText(Iter->second);
688                 
689                 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
691                 if (MapDataExists(DataCount, GeneralListPref)){
692                 
693                         GeneralListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
694                 
695                 }
696         
697                 (*DataCount)++;
698         
699         }
700         
701         // Deal with the home addresses.
702         
703         for (std::map<int,wxString>::iterator Iter = HomeList->begin();
704                 Iter != HomeList->end();
705                 Iter++){
706         
707                 wxListItem coldata;
709                 coldata.SetId(*DataCount);
710                 coldata.SetData(*DataCount);
711                 coldata.SetText(Iter->second);
712                 
713                 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
715                 if (MapDataExists(DataCount, HomeListPref)){
716                 
717                         HomeListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
718                 
719                 }
720         
721                 (*DataCount)++;
722         
723         }
724         
725         // Deal with the work addresses.
726         
727         for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
728                 Iter != BusinessList->end();
729                 Iter++){
730         
731                 wxListItem coldata;
733                 coldata.SetId(*DataCount);
734                 coldata.SetData(*DataCount);
735                 coldata.SetText(Iter->second);
736                 
737                 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
738                                 
739                 if (MapDataExists(DataCount, BusinessListPref)){
740                 
741                         BusinessListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
742                 
743                 }
744         
745                 (*DataCount)++;
746         
747         }
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