Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added support for saving REV, XML, CLIENTPIDMAP and SOURCE properties.
[xestiaab/.git] / source / contacteditor / frmContactEditorRelated.cpp
1 // frmContactEditorRelated.cpp - frmContactEditorRelated form.
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 "frmContactEditorRelated.h"
20 #include <map>
21 #include "../common/textprocessing.h"
22 #include "../enums.h"
24 frmContactEditorRelated::frmContactEditorRelated( wxWindow* parent )
25 :
26 frmContactEditorRelatedADT( parent )
27 {
28         
29         EditorMode = FALSE;
30         sliPriority->Disable();
31         
32         // Setup the list of types for the related drop down box.
33         
34         cmbType->Append(_("Contact"));
35         cmbType->Append(_("Acquaintance"));     
36         cmbType->Append(_("Friend"));   
37         cmbType->Append(_("Met"));
38         cmbType->Append(_("Co-worker"));
39         cmbType->Append(_("Colleague"));
40         cmbType->Append(_("Co-resident"));
41         cmbType->Append(_("Neighbour"));
42         cmbType->Append(_("Child"));
43         cmbType->Append(_("Parent"));
44         cmbType->Append(_("Sibling"));  
45         cmbType->Append(_("Spouse"));
46         cmbType->Append(_("Kin"));
47         cmbType->Append(_("Muse"));
48         cmbType->Append(_("Crush"));
49         cmbType->Append(_("Date"));
50         cmbType->Append(_("Sweetheart"));
51         cmbType->Append(_("Me"));
52         cmbType->Append(_("Agent"));
53         cmbType->Append(_("Emergency"));        
54         
55 }
57 void frmContactEditorRelated::EnablePriority( wxCommandEvent& event )
58 {
59         if (chkUsePref->IsChecked()){
60                 sliPriority->Enable();
61         } else {
62                 sliPriority->Disable();
63         }
64 }
66 void frmContactEditorRelated::SetEditorMode(bool EditMode, SectionType SectType)
67 {
68         if (EditMode == FALSE){
69         
70                 EditorMode = FALSE;
71                 btnAction->SetLabel(_("Add"));
72                 this->SetTitle(_("Add Related"));
73         
74         } else if (EditMode == TRUE){
75         
76                 EditorMode = TRUE;
77                 btnAction->SetLabel(_("Modify"));
78                 this->SetTitle(_("Modify Related"));
79                 
80                 std::map<int,int>::iterator intiter;
81                 std::map<int,wxString>::iterator striter;               
82                 wxString strValue;
83                 
84                 // Get the related data.
85                 
86                 striter = RelatedListPtr->find(RelatedListIndex);
87                  
88                 if (striter->first == RelatedListIndex){
89                 
90                         strValue = striter->second;
91                 
92                 }
93                 
94                 txtRelated->SetValue(strValue);
95                 
96                 strValue.Clear();
97                 
98                 // Get the related type.
99                 
100                 striter = RelatedListRelTypePtr->find(RelatedListIndex);
101                  
102                 if (striter->first == RelatedListIndex){
103                 
104                         strValue = striter->second;
105                 
106                 }
107                 
108                 if (strValue == wxT("contact")){
109                 
110                         cmbType->SetValue(_("Contact"));
111                 
112                 } else if (strValue == wxT("acquaintance")){
113                 
114                         cmbType->SetValue(_("Acquaintance"));
115                 
116                 } else if (strValue == wxT("friend")){
117                 
118                         cmbType->SetValue(_("Friend"));
119                 
120                 } else if (strValue == wxT("met")){
121                 
122                         cmbType->SetValue(_("Met"));
123                 
124                 } else if (strValue == wxT("co-worker")){
125                 
126                         cmbType->SetValue(_("Co-worker"));
127                 
128                 } else if (strValue == wxT("colleague")){
129                 
130                         cmbType->SetValue(_("Colleague"));
131                 
132                 } else if (strValue == wxT("co-resident")){
133                 
134                         cmbType->SetValue(_("Co-resident"));
135                 
136                 } else if (strValue == wxT("neighbor")){
137                 
138                         cmbType->SetValue(_("Neighbour"));
139                 
140                 } else if (strValue == wxT("child")){
141                 
142                         cmbType->SetValue(_("Child"));
143                 
144                 } else if (strValue == wxT("parent")){
145                 
146                         cmbType->SetValue(_("Parent"));
147                 
148                 } else if (strValue == wxT("sibling")){
149                 
150                         cmbType->SetValue(_("Sibling"));
151                 
152                 } else if (strValue == wxT("spouse")){
153                 
154                         cmbType->SetValue(_("Spouse"));
155                 
156                 } else if (strValue == wxT("kin")){
157                 
158                         cmbType->SetValue(_("Kin"));
159                 
160                 } else if (strValue == wxT("muse")){
161                 
162                         cmbType->SetValue(_("Muse"));
163                 
164                 } else if (strValue == wxT("crush")){
165                 
166                         cmbType->SetValue(_("Crush"));
167                 
168                 } else if (strValue == wxT("date")){
169                 
170                         cmbType->SetValue(_("Date"));
171                 
172                 } else if (strValue == wxT("sweetheart")){
173                 
174                         cmbType->SetValue(_("Sweetheart"));
175                 
176                 } else if (strValue == wxT("me")){
177                 
178                         cmbType->SetValue(_("Me"));
179                 
180                 } else if (strValue == wxT("agent")){
181                 
182                         cmbType->SetValue(_("Agent"));
183                 
184                 } else if (strValue == wxT("emergency")){
185                 
186                         cmbType->SetValue(_("Emergency"));
187                 
188                 } else {
189                 
190                         cmbType->SetValue(strValue);
191                 
192                 }
193                 
194                 // Setup the Slider.
195                 
196                 intiter = RelatedListPrefPtr->find(RelatedListIndex);
197                 
198                 if (intiter->first == RelatedListIndex && intiter->second > 0){
199                 
200                         sliPriority->SetValue(intiter->second);
201                         sliPriority->Enable();
202                         chkUsePref->SetValue(TRUE);
203                 
204                 }
205                 
206         }
207         
208         EditSectionType = SectType;     
209         
212 void frmContactEditorRelated::ProcessData( wxCommandEvent& event )
214         long ListCtrlIndex;
215         
216         if (EditorMode == FALSE){
218                 wxString strValue;
220                 RelatedListPtr->insert(std::make_pair(RelatedListIndex, txtRelated->GetValue()));
221                 
222                 // Work out the type of contact.
223                 
224                 strValue = cmbType->GetValue();         
225                 
226                 if (strValue == _("Contact")){
227                 
228                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("contact")));
229                 
230                 } else if (strValue == _("Acquaintance")){
231                 
232                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("acquaintance")));
233                 
234                 } else if (strValue == _("Friend")){
235                 
236                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("friend")));
237                 
238                 } else if (strValue == _("Met")){
239                 
240                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("met")));
241                 
242                 } else if (strValue == _("Co-worker")){
243                 
244                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("co-worker")));
245                 
246                 } else if (strValue == _("Colleague")){
247                 
248                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("colleague")));
249                 
250                 } else if (strValue == _("Co-resident")){
251                 
252                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("co-resident")));
253                 
254                 } else if (strValue == _("Neighbour")){
255                 
256                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("neighbor")));
257                 
258                 } else if (strValue == _("Child")){
259                 
260                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("child")));
261                 
262                 } else if (strValue == _("Parent")){
263                 
264                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("parent")));
265                 
266                 } else if (strValue == _("Sibling")){
267                 
268                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("sibling")));
269                 
270                 } else if (strValue == _("Spouse")){
271                 
272                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("spouse")));
273                 
274                 } else if (strValue == _("Kin")){
275                 
276                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("kin")));
277                 
278                 } else if (strValue == _("Muse")){
279                 
280                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("muse")));
281                 
282                 } else if (strValue == _("Crush")){
283                 
284                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("crush")));
285                 
286                 } else if (strValue == _("Date")){
287                 
288                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("date")));
289                 
290                 } else if (strValue == _("Sweetheart")){
291                 
292                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("sweetheart")));
293                 
294                 } else if (strValue == _("Me")){
295                 
296                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("me")));
297                 
298                 } else if (strValue == _("Agent")){
299                 
300                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("agent")));
301                 
302                 } else if (strValue == _("Emergency")){
303                 
304                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("emergency")));
305                 
306                 } else {
307                 
308                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, strValue));
309                 
310                 }
311                 
312                 // Add Related type.
313                 
314                 if (EditSectionType == CE_GENERAL){
315                 
316                         RelatedListTypePtr->insert(std::make_pair(RelatedListIndex, wxT("")));
317                 
318                 } else if (EditSectionType == CE_HOME) {
319                 
320                         RelatedListTypePtr->insert(std::make_pair(RelatedListIndex, wxT("home")));
321                 
322                 } else if (EditSectionType == CE_WORK) {
323                 
324                         RelatedListTypePtr->insert(std::make_pair(RelatedListIndex, wxT("work")));
325                 
326                 }       
327                 
328                 // Add Related Priority.
329                 
330                 if (chkUsePref->IsChecked()){
331                 
332                         RelatedListPrefPtr->insert(std::make_pair(RelatedListIndex, sliPriority->GetValue()));
333                 
334                 } else {
335                 
336                         RelatedListPrefPtr->insert(std::make_pair(RelatedListIndex, 0));                
337                 
338                 }
339                 
340                 // Add to the form.
341                 
342                 wxListItem coldata;
343                 
344                 coldata.SetId(RelatedListIndex);
345                 coldata.SetData(RelatedListIndex);              
346                 coldata.SetText(cmbType->GetValue());
347                 ListCtrlIndex = RelatedListCtrlPtr->InsertItem(coldata);
348                 
349                 RelatedListCtrlPtr->SetItem(ListCtrlIndex, 1, txtRelated->GetValue());
350                 
351                 if (chkUsePref->IsChecked()){
352                 
353                         RelatedListCtrlPtr->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), sliPriority->GetValue()));
354                 
355                 }               
356         
357                 this->Close();
358         
359         } else if (EditorMode == TRUE) {
360         
361                 wxString strValue;
362                 long longSelected = -1;
363         
364                 // Work out the type of contact.
365                 
366                 strValue = cmbType->GetValue();         
367                 
368                 RelatedListRelTypePtr->erase(RelatedListIndex);
369                 
370                 if (strValue == _("Contact")){
371                 
372                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("contact")));
373                 
374                 } else if (strValue == _("Acquaintance")){
375                 
376                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("acquaintance")));
377                 
378                 } else if (strValue == _("Friend")){
379                 
380                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("friend")));
381                 
382                 } else if (strValue == _("Met")){
383                 
384                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("met")));
385                 
386                 } else if (strValue == _("Co-worker")){
387                 
388                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("co-worker")));
389                 
390                 } else if (strValue == _("Colleague")){
391                 
392                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("colleague")));
393                 
394                 } else if (strValue == _("Co-resident")){
395                 
396                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("co-resident")));
397                 
398                 } else if (strValue == _("Neighbour")){
399                 
400                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("neighbor")));
401                 
402                 } else if (strValue == _("Child")){
403                 
404                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("child")));
405                 
406                 } else if (strValue == _("Parent")){
407                 
408                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("parent")));
409                 
410                 } else if (strValue == _("Sibling")){
411                 
412                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("sibling")));
413                 
414                 } else if (strValue == _("Spouse")){
415                 
416                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("spouse")));
417                 
418                 } else if (strValue == _("Kin")){
419                 
420                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("kin")));
421                 
422                 } else if (strValue == _("Muse")){
423                 
424                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("muse")));
425                 
426                 } else if (strValue == _("Crush")){
427                 
428                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("crush")));
429                 
430                 } else if (strValue == _("Date")){
431                 
432                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("date")));
433                 
434                 } else if (strValue == _("Sweetheart")){
435                 
436                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("sweetheart")));
437                 
438                 } else if (strValue == _("Me")){
439                 
440                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("me")));
441                 
442                 } else if (strValue == _("Agent")){
443                 
444                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("agent")));
445                 
446                 } else if (strValue == _("Emergency")){
447                 
448                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, wxT("emergency")));
449                 
450                 } else {
451                 
452                         RelatedListRelTypePtr->insert(std::make_pair(RelatedListIndex, strValue));
453                 
454                 }       
455                 
456                 RelatedListPrefPtr->erase(RelatedListIndex);
457                 
458                 if (chkUsePref->IsChecked()){
459                 
460                         RelatedListPrefPtr->insert(std::make_pair(RelatedListIndex, sliPriority->GetValue()));
461                 
462                 } else {
463                 
464                         RelatedListPrefPtr->insert(std::make_pair(RelatedListIndex, 0));
465                 
466                 }
467                 
468                 // Get the related person/details.
469                 
470                 RelatedListPtr->erase(RelatedListIndex);
471                 RelatedListPtr->insert(std::make_pair(RelatedListIndex, txtRelated->GetValue()));               
472                 
473                 // Update the form.
474                 
475                 longSelected = RelatedListCtrlPtr->GetNextItem(longSelected, 
476                         wxLIST_NEXT_ALL,
477                         wxLIST_STATE_SELECTED);
478                         
479                 if (longSelected == -1){
480                         return;
481                 }               
482                 
483                 RelatedListCtrlPtr->SetItem(longSelected, 0, cmbType->GetValue());
484                 RelatedListCtrlPtr->SetItem(longSelected, 1, txtRelated->GetValue());
485                 
486                 if (chkUsePref->IsChecked()){
487                 
488                         RelatedListCtrlPtr->SetItem(longSelected, 2, wxString::Format(wxT("%i"), sliPriority->GetValue()));
489                 
490                 } else {
491                 
492                         RelatedListCtrlPtr->SetItem(longSelected, 2, wxT(""));
493                 
494                 }       
495         
496                 this->Close();
497         
498         }       
501 void frmContactEditorRelated::CloseWindow( wxCommandEvent& event )
503         this->Close();
506 void frmContactEditorRelated::SetupPointers(std::map<int, wxString> *RelatedList,
507         std::map<int, wxString> *RelatedListRelType,
508         std::map<int, wxString> *RelatedListAltID,
509         std::map<int, wxString> *RelatedListPID,
510         std::map<int, wxString> *RelatedListType,
511         std::map<int, wxString> *RelatedListTokens,                     
512         std::map<int, int> *RelatedListPref,
513         wxListCtrl *RelatedListCtrl,
514         int RelatedIndex )
517         RelatedListPtr = RelatedList;
518         RelatedListRelTypePtr = RelatedListRelType;     
519         RelatedListAltIDPtr = RelatedListAltID;
520         RelatedListPIDPtr = RelatedListPID;
521         RelatedListTypePtr = RelatedListType;
522         RelatedListTokensPtr = RelatedListTokens;
523         RelatedListPrefPtr = RelatedListPref;
524         RelatedListCtrlPtr = RelatedListCtrl;
525         RelatedListIndex = RelatedIndex;
526         
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