1 #include "frmContactEditorEmail.h"
3 #include "../common/textprocessing.h"
5 frmContactEditorEmail::frmContactEditorEmail( wxWindow* parent )
7 frmContactEditorEmailADT( parent )
10 sliPriority->Disable();
13 void frmContactEditorEmail::EnablePriority( wxCommandEvent& event )
15 if (chkUsePref->IsChecked()){
16 sliPriority->Enable();
18 sliPriority->Disable();
22 void frmContactEditorEmail::ProcessData( wxCommandEvent& event )
26 if (EditorMode == FALSE){
28 // Add the email address to the list.
35 EmailListPtr->insert(std::make_pair(EmailListIndex, txtEmail->GetValue()));
39 if (EditSectionType == CE_GENERAL){
41 EmailListTypePtr->insert(std::make_pair(EmailListIndex, wxT("")));
43 } else if (EditSectionType == CE_HOME) {
45 EmailListTypePtr->insert(std::make_pair(EmailListIndex, wxT("home")));
47 } else if (EditSectionType == CE_WORK) {
49 EmailListTypePtr->insert(std::make_pair(EmailListIndex, wxT("work")));
53 // Add Email priority.
55 if (chkUsePref->IsChecked()){
57 EmailListPrefPtr->insert(std::make_pair(EmailListIndex, sliPriority->GetValue()));
61 EmailListPrefPtr->insert(std::make_pair(EmailListIndex, 0));
65 // Add the data to the form.
69 coldata.SetId(EmailListIndex);
70 coldata.SetData(EmailListIndex);
71 coldata.SetText(txtEmail->GetValue());
72 ListCtrlIndex = EmailListCtrlPtr->InsertItem(coldata);
74 if (chkUsePref->IsChecked()){
76 EmailListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
82 } else if (EditorMode == TRUE){
84 // Edit the email address.
88 long longSelected = -1;
90 EmailListPtr->erase(EmailListIndex);
91 EmailListPtr->insert(std::make_pair(EmailListIndex, txtEmail->GetValue()));
93 EmailListPrefPtr->erase(EmailListIndex);
95 if (chkUsePref->IsChecked()){
97 EmailListPrefPtr->insert(std::make_pair(EmailListIndex, sliPriority->GetValue()));
101 EmailListPrefPtr->insert(std::make_pair(EmailListIndex, 0));
105 longSelected = EmailListCtrlPtr->GetNextItem(longSelected,
107 wxLIST_STATE_SELECTED);
109 if (longSelected == -1){
113 EmailListCtrlPtr->SetItem(longSelected, 0, txtEmail->GetValue());
115 if (chkUsePref->IsChecked()){
117 EmailListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
121 EmailListCtrlPtr->SetItem(longSelected, 1, wxT(""));
131 void frmContactEditorEmail::CloseWindow( wxCommandEvent& event )
136 void frmContactEditorEmail::SetEditorMode(bool EditMode, SectionType SectType)
139 // Set the editor mode for adding or editing an email address.
141 if (EditMode == FALSE){
144 btnAction->SetLabel(_("Add"));
145 this->SetTitle(_("Add Email"));
147 } else if (EditMode == TRUE){
150 btnAction->SetLabel(_("Modify"));
151 this->SetTitle(_("Modify Email"));
153 std::map<int,int>::iterator intiter;
154 std::map<int,wxString>::iterator striter;
157 // Load the data into the form.
159 striter = EmailListPtr->find(EmailListIndex);
161 if (striter->first == EmailListIndex){
163 strValue = striter->second;
167 txtEmail->SetValue(strValue);
171 intiter = EmailListPrefPtr->find(EmailListIndex);
173 if (intiter->first == EmailListIndex && intiter->second > 0){
175 sliPriority->SetValue(intiter->second);
176 sliPriority->Enable();
177 chkUsePref->SetValue(TRUE);
183 EditSectionType = SectType;
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,
197 // Setup the pointers so that the data can be processed without
200 EmailListPtr = EmailList;
201 EmailListAltIDPtr = EmailListAltID;
202 EmailListPIDPtr = EmailListPID;
203 EmailListTypePtr = EmailListType;
204 EmailListTokensPtr = EmailListTokens;
205 EmailListPrefPtr = EmailListPref;
206 EmailListCtrlPtr = EmailListCtrl;
207 EmailListIndex = EmailIndex;