Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
031876279e0597ee18437392fd15f9762e42400b
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadBADays.cpp
1 // frmContactEditor-LoadBADays.cpp - frmContactEditor load birthday/anniversary 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::LoadBDay(wxString wxSPropertySeg1, wxString wxSPropertySeg2, bool *BirthdayProcessed){
23         // Process date. Preserve the remainder in the string.
25         std::map<int, int> SplitPoints;
26         std::map<int, int> SplitLength;
27         std::map<int, int>::iterator SLiter;                    
28         wxString PropertyData;
29         wxString PropertyName;
30         wxString PropertyValue;
31         wxString PropertyTokens;
32         bool BirthdayText = FALSE;
33         int intPrevValue = 6;
35         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
37         intPrevValue = 5;
39         // Look for type before continuing.
41         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
42         intiter != SplitPoints.end(); ++intiter){
44                 SLiter = SplitLength.find(intiter->first);
46                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
47         
48                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
49                 PropertyName = PropertyElement.GetNextToken();                          
50                 PropertyValue = PropertyElement.GetNextToken();
51         
52                 intPrevValue = intiter->second;
53         
54                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
55         
56                         ProcessCaptureStrings(&wxSPropertySeg2);
57                         txtBirthday->SetValue(wxSPropertySeg2);
58                         Birthday = wxSPropertySeg2;
59                         BirthdayText = TRUE;
60         
61                 }
63         }
65         // Setup blank lines for later on.
66         
67         intPrevValue = 5;
69         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
70         intiter != SplitPoints.end(); ++intiter){
72                 SLiter = SplitLength.find(intiter->first);
74                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
75         
76                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
77                 PropertyName = PropertyElement.GetNextToken();                          
78                 PropertyValue = PropertyElement.GetNextToken();
79         
80                 intPrevValue = intiter->second;
81         
82                 // Process properties.
83         
84                 ProcessCaptureStrings(&PropertyValue);
85         
86                 size_t intPropertyValueLen = PropertyValue.Len();
87         
88                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
89                 
90                         PropertyValue.Trim();
91                         PropertyValue.RemoveLast();
92                 
93                 }                               
94         
95                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
96                 
97                         PropertyValue.Remove(0, 1);
98                 
99                 }                               
100         
101                 if (PropertyName == wxT("ALTID")){
103                         BirthdayAltID = PropertyValue;
104         
105                 } else if (PropertyName == wxT("CALSCALE")){
106         
107                         BirthdayCalScale = PropertyValue;
108         
109                 } else if (PropertyName != wxT("VALUE")) {
110         
111                         // Something else we don't know about so append
112                         // to the tokens variable.
113                 
114                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
115                 
116                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
117                                 
118                         }
119                         
120                 }
122         }       
124         // Add the data to the variables and form.
125         
126         if (BirthdayText == FALSE){
127         
128                 Birthday = wxSPropertySeg2;
129                 int DateYear = 0;
130                 wxDateTime::Month DateMonth;
131                 unsigned int DateDay;
132                 
133                 wxString wxSData;
134                 
135                 if (Birthday.Mid(0, 2) == wxT("--")){
136                 
137                         // Skip year.
138                 
139                 } else {
140                 
141                         DateYear = wxAtoi(Birthday.Mid(0,4));
142                 
143                 }
144                 
145                 DateMonth = (wxDateTime::Month)(wxAtoi(Birthday.Mid(4,2)) - 1);
146                 DateDay = wxAtoi(Birthday.Mid(6,2));
147         
148                 wxDateTime BDayDate(DateDay,DateMonth,DateYear);
149         
150                 /*BDayDate.SetDay(DateDay);
151                 BDayDate.SetMonth(wxDateTime::Month::Jan);
152                 BDayDate.SetYear(DateYear);*/
153         
154                 dapBirthday->SetValue(BDayDate);                                
155         
156         }
157         
158         BirthdayTokens = PropertyTokens;
159         
160         *BirthdayProcessed = TRUE;
164 void frmContactEditor::LoadAnniversary(wxString wxSPropertySeg1, wxString wxSPropertySeg2, bool *AnniversaryProcessed){
166         // Process date. Preserve the remainder in the string.
167                 
168         std::map<int, int> SplitPoints;
169         std::map<int, int> SplitLength;
170         std::map<int, int>::iterator SLiter;                    
171         wxString PropertyData;
172         wxString PropertyName;
173         wxString PropertyValue;
174         wxString PropertyTokens;
175         bool AnniversaryText = FALSE;
176         int intPrevValue = 13;
178         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
180         intPrevValue = 12;
182         // Look for type before continuing.
184         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
185         intiter != SplitPoints.end(); ++intiter){
187                 SLiter = SplitLength.find(intiter->first);
189                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
190         
191                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
192                 PropertyName = PropertyElement.GetNextToken();                          
193                 PropertyValue = PropertyElement.GetNextToken();
194         
195                 intPrevValue = intiter->second;
196         
197                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
198         
199                         ProcessCaptureStrings(&wxSPropertySeg2);
200                         txtAnniversary->SetValue(wxSPropertySeg2);
201                         Anniversary = wxSPropertySeg2;
202                         AnniversaryText = TRUE;
203         
204                 }
206         }
208         // Setup blank lines for later on.
210         intPrevValue = 12;
212         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
213         intiter != SplitPoints.end(); ++intiter){
215                 SLiter = SplitLength.find(intiter->first);
217                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
218         
219                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
220                 PropertyName = PropertyElement.GetNextToken();                          
221                 PropertyValue = PropertyElement.GetNextToken();
222         
223                 intPrevValue = intiter->second;
224         
225                 // Process properties.
226         
227                 size_t intPropertyValueLen = PropertyValue.Len();
228         
229                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
230                 
231                         PropertyValue.Trim();
232                         PropertyValue.RemoveLast();
233                 
234                 }                               
235         
236                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
237                 
238                         PropertyValue.Remove(0, 1);
239                 
240                 }
241                 
242                 ProcessCaptureStrings(&PropertyValue);          
243         
244                 if (PropertyName == wxT("ALTID")){
246                         AnniversaryAltID = PropertyValue;
247         
248                 } else if (PropertyName == wxT("CALSCALE")){
249         
250                         AnniversaryCalScale = PropertyValue;
251         
252                 } else if (PropertyName != wxT("VALUE")) {
253         
254                         // Something else we don't know about so append
255                         // to the tokens variable.
256                         
257                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
258                 
259                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
260                                 
261                         }
262         
263                 }
265         }       
267         // Add the data to the variables and form.
268         
269         if (AnniversaryText == FALSE){
270         
271                 Anniversary = wxSPropertySeg2;
272                 int DateYear = 0;
273                 wxDateTime::Month DateMonth;
274                 int DateDay;
275                 
276                 wxString wxSData;
277                 
278                 if (Anniversary.Mid(0, 2) == wxT("--")){
279                 
280                         // Skip year.
281                 
282                 } else {
283                 
284                         DateYear = wxAtoi(Anniversary.Mid(0,4));
285                 
286                 }
287                 
288                 DateMonth = (wxDateTime::Month)(wxAtoi(Anniversary.Mid(4,2)) - 1);
289                 DateDay = wxAtoi(Anniversary.Mid(6,2));                                 
290         
291                 wxDateTime ADayDate(DateDay,DateMonth,DateYear);
292         
293                 dapAnniversary->SetValue(ADayDate);
294         
295         }
296         
297         AnniversaryTokens = PropertyTokens;
298         
299         *AnniversaryProcessed = 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