Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Implemented CATEGORIES with ContactDataObject.
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadGender.cpp
1 // frmContactEditor-LoadGender.cpp - frmContactEditor load gender 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::LoadGender(wxString *GenderComponent, wxString *GenderIdentity){
23         // Deal with the Gender Component.
24         
25         if (*GenderComponent == wxT("M")){
26                 
27                 // Gender is Male.
28                         
29                 cmbGender->SetSelection(1);
30                 
31         } else if (*GenderComponent == wxT("F")){
32                 
33                 // Gender is Female.
34                         
35                 cmbGender->SetSelection(2);                                     
36                 
37         } else if (*GenderComponent == wxT("O")){
38                 
39                 // Gender is Other.
40                         
41                 cmbGender->SetSelection(3);
42                 
43         } else if (*GenderComponent == wxT("N")){
44                 
45                 // Gender is None/Not Applicable.
46                 
47                 cmbGender->SetSelection(4);                                     
48                 
49         } else if (*GenderComponent == wxT("U")){
50                 
51                 // Gender is Unknown.
52                         
53                 cmbGender->SetSelection(5);                                     
54                 
55         }
56         
57         // Deal with the Gender Identity.
59         txtGenderDescription->SetValue(*GenderIdentity);
61 }
63 void frmContactEditor::LoadGender(wxString wxSPropertySeg1, wxString wxSPropertySeg2, bool *GenderProcessed, vCard *ContactData){
65         std::map<int, int> SplitPoints;
66         std::map<int, int> SplitLength;
67         std::map<int, int>::iterator SLiter;                    
68         wxString PropertyData;
69         wxString PropertyName;
70         wxString PropertyValue;
71         wxString PropertyTokens;
72         bool FirstToken = TRUE;
73         int intPrevValue = 8;
75         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
76         
77         intPrevValue = 7;                       
78         
79         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
80         intiter != SplitPoints.end(); ++intiter){
81         
82                 SLiter = SplitLength.find(intiter->first);
83         
84                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
85                 
86                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
87                 PropertyName = PropertyElement.GetNextToken();                          
88                 PropertyValue = PropertyElement.GetNextToken();
89                 
90                 intPrevValue = intiter->second;
91                 
92                 // Process properties.
93                 
94                 size_t intPropertyValueLen = PropertyValue.Len();
95                 
96                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
97                         
98                         PropertyValue.Trim();
99                         PropertyValue.RemoveLast();
100                         
101                 }                               
102                 
103                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
104                         
105                         PropertyValue.Remove(0, 1);
106                         
107                 }                               
108                 
109                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
111                         if (FirstToken == TRUE){
112         
113                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
114                                 FirstToken = FALSE;
115         
116                         } else {
117         
118                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
119         
120                         }
122                 }
123         
124         }       
126         wxStringTokenizer GenderDetails (wxSPropertySeg2, wxT(";"));
127         
128         wxString GenderComponent;
129         wxString GenderIdentity;
130         
131         if (GenderDetails.CountTokens() >= 2){
132         
133                 GenderComponent = GenderDetails.GetNextToken();
134                 GenderIdentity = GenderDetails.GetString();
135         
136                 ProcessCaptureStrings(&GenderIdentity);
137         
138                 txtGenderDescription->SetValue(ContactData->Convert(GenderIdentity, TRUE));
139                                                 
140         } else {
141         
142                 GenderComponent = GenderDetails.GetNextToken();
143         
144         }
145                 
146         if (GenderComponent == wxT("M")){
147                 
148                 // Gender is Male.
149                         
150                 cmbGender->SetSelection(1);
151                 
152         } else if (GenderComponent == wxT("F")){
153                 
154                 // Gender is Female.
155                         
156                 cmbGender->SetSelection(2);                                     
157                 
158         } else if (GenderComponent == wxT("O")){
159                 
160                 // Gender is Other.
161                         
162                 cmbGender->SetSelection(3);
163                 
164         } else if (GenderComponent == wxT("N")){
165                 
166                 // Gender is None/Not Applicable.
167                 
168                 cmbGender->SetSelection(4);                                     
169                 
170         } else if (GenderComponent == wxT("U")){
171                 
172                 // Gender is Unknown.
173                         
174                 cmbGender->SetSelection(5);                                     
175                 
176         }
177         
178         GenderTokens = PropertyTokens;
179         *GenderProcessed = TRUE;
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