1 #include "frmContactEditorTimezones.h"
3 #include "../common/textprocessing.h"
5 frmContactEditorTimezones::frmContactEditorTimezones( wxWindow* parent )
7 frmContactEditorTimezonesADT( parent )
10 sliPriority->Disable();
13 void frmContactEditorTimezones::EnablePriority( wxCommandEvent& event )
15 if (chkUsePref->IsChecked()){
16 sliPriority->Enable();
18 sliPriority->Disable();
22 void frmContactEditorTimezones::SetEditorMode(bool EditMode, SectionType SectType)
25 // Set the editor mode for adding or editing a timezone.
27 if (EditMode == FALSE){
30 btnAction->SetLabel(_("Add"));
31 this->SetTitle(_("Add Timezone"));
33 } else if (EditMode == TRUE){
36 btnAction->SetLabel(_("Modify"));
37 this->SetTitle(_("Modify Timezone"));
39 std::map<int,int>::iterator intiter;
40 std::map<int,wxString>::iterator striter;
43 // Load the data into the form.
45 striter = TZListPtr->find(TZListIndex);
47 if (striter->first == TZListIndex){
49 strValue = striter->second;
53 cmbTimezone->SetValue(strValue);
57 intiter = TZListPrefPtr->find(TZListIndex);
59 if (intiter->first == TZListIndex && intiter->second > 0){
61 sliPriority->SetValue(intiter->second);
62 sliPriority->Enable();
63 chkUsePref->SetValue(TRUE);
69 EditSectionType = SectType;
73 void frmContactEditorTimezones::ProcessAction( wxCommandEvent& event )
78 if (EditorMode == FALSE){
80 // Add the language to the list.
86 TZListPtr->insert(std::make_pair(TZListIndex, cmbTimezone->GetValue()));
90 if (EditSectionType == CE_GENERAL){
92 TZListTypePtr->insert(std::make_pair(TZListIndex, wxT("")));
94 } else if (EditSectionType == CE_HOME) {
96 TZListTypePtr->insert(std::make_pair(TZListIndex, wxT("home")));
98 } else if (EditSectionType == CE_WORK) {
100 TZListTypePtr->insert(std::make_pair(TZListIndex, wxT("work")));
104 // Add Language priority.
106 if (chkUsePref->IsChecked()){
108 TZListPrefPtr->insert(std::make_pair(TZListIndex, sliPriority->GetValue()));
112 TZListPrefPtr->insert(std::make_pair(TZListIndex, 0));
116 // Add the data to the form.
120 coldata.SetId(TZListIndex);
121 coldata.SetData(TZListIndex);
122 coldata.SetText(cmbTimezone->GetValue());
123 ListCtrlIndex = TZListCtrlPtr->InsertItem(coldata);
125 if (chkUsePref->IsChecked()){
127 TZListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
133 } else if (EditorMode == TRUE){
135 // Edit the language.
139 long longSelected = -1;
141 TZListPtr->erase(TZListIndex);
142 TZListPtr->insert(std::make_pair(TZListIndex, cmbTimezone->GetValue()));
144 TZListPrefPtr->erase(TZListIndex);
146 if (chkUsePref->IsChecked()){
148 TZListPrefPtr->insert(std::make_pair(TZListIndex, sliPriority->GetValue()));
152 TZListPrefPtr->insert(std::make_pair(TZListIndex, 0));
156 longSelected = TZListCtrlPtr->GetNextItem(longSelected,
158 wxLIST_STATE_SELECTED);
160 if (longSelected == -1){
164 TZListCtrlPtr->SetItem(longSelected, 0, cmbTimezone->GetValue());
166 if (chkUsePref->IsChecked()){
168 TZListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
172 TZListCtrlPtr->SetItem(longSelected, 1, wxT(""));
182 void frmContactEditorTimezones::CloseWindow( wxCommandEvent& event )
187 void frmContactEditorTimezones::SetupPointers(std::map<int, wxString> *TZList,
188 std::map<int, wxString> *TZListAltID,
189 std::map<int, wxString> *TZListPID,
190 std::map<int, wxString> *TZListType,
191 std::map<int, wxString> *TZListTokens,
192 std::map<int, wxString> *TZListMediatype,
193 std::map<int, int> *TZListPref,
194 wxListCtrl *TZListCtrl,
198 // Setup the pointers so that the data can be processed without
202 TZListAltIDPtr = TZListAltID;
203 TZListPIDPtr = TZListPID;
204 TZListTypePtr = TZListType;
205 TZListTokensPtr = TZListTokens;
206 TZListPrefPtr = TZListPref;
207 TZListCtrlPtr = TZListCtrl;
208 TZListIndex = TZIndex;