1 // frmContactEditor-LoadGender.cpp - frmContactEditor load gender subroutines.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
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.
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.
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.
25 if (*GenderComponent == wxT("M")){
29 cmbGender->SetSelection(1);
31 } else if (*GenderComponent == wxT("F")){
35 cmbGender->SetSelection(2);
37 } else if (*GenderComponent == wxT("O")){
41 cmbGender->SetSelection(3);
43 } else if (*GenderComponent == wxT("N")){
45 // Gender is None/Not Applicable.
47 cmbGender->SetSelection(4);
49 } else if (*GenderComponent == wxT("U")){
53 cmbGender->SetSelection(5);
57 // Deal with the Gender Identity.
59 txtGenderDescription->SetValue(*GenderIdentity);
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;
75 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
79 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
80 intiter != SplitPoints.end(); ++intiter){
82 SLiter = SplitLength.find(intiter->first);
84 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
86 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
87 PropertyName = PropertyElement.GetNextToken();
88 PropertyValue = PropertyElement.GetNextToken();
90 intPrevValue = intiter->second;
92 // Process properties.
94 size_t intPropertyValueLen = PropertyValue.Len();
96 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
99 PropertyValue.RemoveLast();
103 if (PropertyValue.Mid(0, 1) == wxT("\"")){
105 PropertyValue.Remove(0, 1);
109 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
111 if (FirstToken == TRUE){
113 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
118 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
126 wxStringTokenizer GenderDetails (wxSPropertySeg2, wxT(";"));
128 wxString GenderComponent;
129 wxString GenderIdentity;
131 if (GenderDetails.CountTokens() >= 2){
133 GenderComponent = GenderDetails.GetNextToken();
134 GenderIdentity = GenderDetails.GetString();
136 ProcessCaptureStrings(&GenderIdentity);
138 txtGenderDescription->SetValue(ContactData->Convert(GenderIdentity, TRUE));
142 GenderComponent = GenderDetails.GetNextToken();
146 if (GenderComponent == wxT("M")){
150 cmbGender->SetSelection(1);
152 } else if (GenderComponent == wxT("F")){
156 cmbGender->SetSelection(2);
158 } else if (GenderComponent == wxT("O")){
162 cmbGender->SetSelection(3);
164 } else if (GenderComponent == wxT("N")){
166 // Gender is None/Not Applicable.
168 cmbGender->SetSelection(4);
170 } else if (GenderComponent == wxT("U")){
172 // Gender is Unknown.
174 cmbGender->SetSelection(5);
178 GenderTokens = PropertyTokens;
179 *GenderProcessed = TRUE;