1 #include "frmContactEditorGeoposition.h"
3 #include "../common/textprocessing.h"
5 frmContactEditorGeoposition::frmContactEditorGeoposition( wxWindow* parent )
7 frmContactEditorGeopositionADT( parent )
10 sliPriority->Disable();
13 void frmContactEditorGeoposition::EnablePriority( wxCommandEvent& event )
16 if (chkUsePref->IsChecked()){
17 sliPriority->Enable();
19 sliPriority->Disable();
24 void frmContactEditorGeoposition::SetEditorMode(bool EditMode, SectionType SectType)
27 // Set the editor mode for adding or editing a timezone.
29 if (EditMode == FALSE){
32 btnAction->SetLabel(_("Add"));
33 this->SetTitle(_("Add Geoposition"));
35 } else if (EditMode == TRUE){
38 btnAction->SetLabel(_("Modify"));
39 this->SetTitle(_("Modify Geoposition"));
41 std::map<int,int>::iterator intiter;
42 std::map<int,wxString>::iterator striter;
45 // Load the data into the form.
47 striter = GeopositionListPtr->find(GeopositionListIndex);
49 if (striter->first == GeopositionListIndex){
51 strValue = striter->second;
55 txtGeoposition->SetValue(strValue);
59 intiter = GeopositionListPrefPtr->find(GeopositionListIndex);
61 if (intiter->first == GeopositionListIndex && intiter->second > 0){
63 sliPriority->SetValue(intiter->second);
64 sliPriority->Enable();
65 chkUsePref->SetValue(TRUE);
71 EditSectionType = SectType;
75 void frmContactEditorGeoposition::ProcessAction( wxCommandEvent& event )
80 if (EditorMode == FALSE){
82 // Add the language to the list.
86 strValue = txtGeoposition->GetValue();
90 GeopositionListPtr->insert(std::make_pair(GeopositionListIndex, strValue));
94 if (EditSectionType == CE_GENERAL){
96 GeopositionListTypePtr->insert(std::make_pair(GeopositionListIndex, wxT("")));
98 } else if (EditSectionType == CE_HOME) {
100 GeopositionListTypePtr->insert(std::make_pair(GeopositionListIndex, wxT("home")));
102 } else if (EditSectionType == CE_WORK) {
104 GeopositionListTypePtr->insert(std::make_pair(GeopositionListIndex, wxT("work")));
108 // Add Language priority.
110 if (chkUsePref->IsChecked()){
112 GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, sliPriority->GetValue()));
116 GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, 0));
120 // Add the data to the form.
124 coldata.SetId(GeopositionListIndex);
125 coldata.SetData(GeopositionListIndex);
126 coldata.SetText(txtGeoposition->GetValue());
127 ListCtrlIndex = GeopositionListCtrlPtr->InsertItem(coldata);
129 if (chkUsePref->IsChecked()){
131 GeopositionListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
137 } else if (EditorMode == TRUE){
139 // Edit the language.
143 long longSelected = -1;
145 GeopositionListPtr->erase(GeopositionListIndex);
146 GeopositionListPtr->insert(std::make_pair(GeopositionListIndex, txtGeoposition->GetValue()));
148 GeopositionListPrefPtr->erase(GeopositionListIndex);
150 if (chkUsePref->IsChecked()){
152 GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, sliPriority->GetValue()));
156 GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, 0));
160 longSelected = GeopositionListCtrlPtr->GetNextItem(longSelected,
162 wxLIST_STATE_SELECTED);
164 if (longSelected == -1){
168 GeopositionListCtrlPtr->SetItem(longSelected, 0, txtGeoposition->GetValue());
170 if (chkUsePref->IsChecked()){
172 GeopositionListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
176 GeopositionListCtrlPtr->SetItem(longSelected, 1, wxT(""));
186 void frmContactEditorGeoposition::CloseWindow( wxCommandEvent& event )
191 void frmContactEditorGeoposition::SetupPointers(std::map<int, wxString> *GeopositionList,
192 std::map<int, wxString> *GeopositionListAltID,
193 std::map<int, wxString> *GeopositionListPID,
194 std::map<int, wxString> *GeopositionListType,
195 std::map<int, wxString> *GeopositionListTokens,
196 std::map<int, wxString> *GeopositionListMediatype,
197 std::map<int, int> *GeopositionListPref,
198 wxListCtrl *GeopositionListCtrl,
199 int GeopositionIndex )
202 // Setup the pointers so that the data can be processed without
205 GeopositionListPtr = GeopositionList;
206 GeopositionListAltIDPtr = GeopositionListAltID;
207 GeopositionListPIDPtr = GeopositionListPID;
208 GeopositionListTypePtr = GeopositionListType;
209 GeopositionListTokensPtr = GeopositionListTokens;
210 GeopositionListPrefPtr = GeopositionListPref;
211 GeopositionListCtrlPtr = GeopositionListCtrl;
212 GeopositionListIndex = GeopositionIndex;