Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial import of code already done for Xestia Address Book
[xestiaab/.git] / source / contacteditor / frmContactEditorEmail.cpp
1 #include "frmContactEditorEmail.h"
2 #include <map>
3 #include "../common/textprocessing.h"
5 frmContactEditorEmail::frmContactEditorEmail( wxWindow* parent )
6 :
7 frmContactEditorEmailADT( parent )
8 {
9         EditorMode = FALSE;
10         sliPriority->Disable();
11 }
13 void frmContactEditorEmail::EnablePriority( wxCommandEvent& event )
14 {
15         if (chkUsePref->IsChecked()){
16                 sliPriority->Enable();
17         } else {
18                 sliPriority->Disable();
19         }
20 }
22 void frmContactEditorEmail::ProcessData( wxCommandEvent& event )
23 {
24         long ListCtrlIndex;
25         
26         if (EditorMode == FALSE){
27         
28                 // Add the email address to the list.
29         
30                 wxString strAddress;
31                 wxString strValue;
32                 
33                 // Add Email address.
34                 
35                 EmailListPtr->insert(std::make_pair(EmailListIndex, txtEmail->GetValue()));
36                 
37                 // Add Email type.
38                 
39                 if (EditSectionType == CE_GENERAL){
40                 
41                         EmailListTypePtr->insert(std::make_pair(EmailListIndex, wxT("")));
42                 
43                 } else if (EditSectionType == CE_HOME) {
44                 
45                         EmailListTypePtr->insert(std::make_pair(EmailListIndex, wxT("home")));
46                 
47                 } else if (EditSectionType == CE_WORK) {
48                 
49                         EmailListTypePtr->insert(std::make_pair(EmailListIndex, wxT("work")));
50                 
51                 }
52                 
53                 // Add Email priority.
54                 
55                 if (chkUsePref->IsChecked()){
56                 
57                         EmailListPrefPtr->insert(std::make_pair(EmailListIndex, sliPriority->GetValue()));
58                 
59                 } else {
60                 
61                         EmailListPrefPtr->insert(std::make_pair(EmailListIndex, 0));            
62                 
63                 }               
64                 
65                 // Add the data to the form.
66                 
67                 wxListItem coldata;
68                 
69                 coldata.SetId(EmailListIndex);
70                 coldata.SetData(EmailListIndex);                
71                 coldata.SetText(txtEmail->GetValue());
72                 ListCtrlIndex = EmailListCtrlPtr->InsertItem(coldata);
73                 
74                 if (chkUsePref->IsChecked()){
75                 
76                         EmailListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
77                 
78                 }
79                 
80                 this->Close();
81         
82         } else if (EditorMode == TRUE){
83         
84                 // Edit the email address.
85                 
86                 wxString strAddress;
87                 wxString strValue;
88                 long longSelected = -1;
90                 EmailListPtr->erase(EmailListIndex);
91                 EmailListPtr->insert(std::make_pair(EmailListIndex, txtEmail->GetValue()));
92                 
93                 EmailListPrefPtr->erase(EmailListIndex);
94                 
95                 if (chkUsePref->IsChecked()){
96                 
97                         EmailListPrefPtr->insert(std::make_pair(EmailListIndex, sliPriority->GetValue()));
98                 
99                 } else {
100                 
101                         EmailListPrefPtr->insert(std::make_pair(EmailListIndex, 0));            
102                 
103                 }
104                 
105                 longSelected = EmailListCtrlPtr->GetNextItem(longSelected, 
106                         wxLIST_NEXT_ALL,
107                         wxLIST_STATE_SELECTED);
108                         
109                 if (longSelected == -1){
110                         return;
111                 }
112                 
113                 EmailListCtrlPtr->SetItem(longSelected, 0, txtEmail->GetValue());               
114                 
115                 if (chkUsePref->IsChecked()){
116                 
117                         EmailListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
118                 
119                 } else {
120                 
121                         EmailListCtrlPtr->SetItem(longSelected, 1, wxT(""));
122                 
123                 }       
124                         
125                 this->Close();  
126         
127         }       
128         
131 void frmContactEditorEmail::CloseWindow( wxCommandEvent& event )
133         this->Close();
136 void frmContactEditorEmail::SetEditorMode(bool EditMode, SectionType SectType)
139         // Set the editor mode for adding or editing an email address.
141         if (EditMode == FALSE){
142         
143                 EditorMode = FALSE;
144                 btnAction->SetLabel(_("Add"));
145                 this->SetTitle(_("Add Email"));
146         
147         } else if (EditMode == TRUE){
148         
149                 EditorMode = TRUE;
150                 btnAction->SetLabel(_("Modify"));
151                 this->SetTitle(_("Modify Email"));
152         
153                 std::map<int,int>::iterator intiter;
154                 std::map<int,wxString>::iterator striter;
155                 wxString strValue;
156                 
157                 // Load the data into the form.
158                 
159                 striter = EmailListPtr->find(EmailListIndex);
160                  
161                 if (striter->first == EmailListIndex){
162                 
163                         strValue = striter->second;
164                 
165                 }
166                 
167                 txtEmail->SetValue(strValue);
168                 
169                 // Setup the Slider.
170                 
171                 intiter = EmailListPrefPtr->find(EmailListIndex);
172                 
173                 if (intiter->first == EmailListIndex && intiter->second > 0){
174                 
175                         sliPriority->SetValue(intiter->second);
176                         sliPriority->Enable();
177                         chkUsePref->SetValue(TRUE);
178                 
179                 }       
180                 
181         }
182         
183         EditSectionType = SectType;
184         
187 void frmContactEditorEmail::SetupPointers(std::map<int, wxString> *EmailList,
188         std::map<int, wxString> *EmailListAltID,
189         std::map<int, wxString> *EmailListPID,
190         std::map<int, wxString> *EmailListType,
191         std::map<int, wxString> *EmailListTokens,
192         std::map<int, int> *EmailListPref,
193         wxListCtrl *EmailListCtrl,
194         int EmailIndex )
197         // Setup the pointers so that the data can be processed without
198         // duplication.
200         EmailListPtr = EmailList;
201         EmailListAltIDPtr = EmailListAltID;
202         EmailListPIDPtr = EmailListPID;
203         EmailListTypePtr = EmailListType;
204         EmailListTokensPtr = EmailListTokens;
205         EmailListPrefPtr = EmailListPref;
206         EmailListCtrlPtr = EmailListCtrl;
207         EmailListIndex = EmailIndex;
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