Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial import of code already done for Xestia Address Book
[xestiaab/.git] / source / contacteditor / frmContactEditorGeoposition.cpp
1 #include "frmContactEditorGeoposition.h"
2 #include <map>
3 #include "../common/textprocessing.h"
5 frmContactEditorGeoposition::frmContactEditorGeoposition( wxWindow* parent )
6 :
7 frmContactEditorGeopositionADT( parent )
8 {
9         EditorMode = FALSE;
10         sliPriority->Disable();
11 }
13 void frmContactEditorGeoposition::EnablePriority( wxCommandEvent& event )
14 {
16         if (chkUsePref->IsChecked()){
17                 sliPriority->Enable();
18         } else {
19                 sliPriority->Disable();
20         }
21         
22 }
24 void frmContactEditorGeoposition::SetEditorMode(bool EditMode, SectionType SectType)
25 {
27         // Set the editor mode for adding or editing a timezone.
29         if (EditMode == FALSE){
30         
31                 EditorMode = FALSE;
32                 btnAction->SetLabel(_("Add"));
33                 this->SetTitle(_("Add Geoposition"));
34         
35         } else if (EditMode == TRUE){
36         
37                 EditorMode = TRUE;
38                 btnAction->SetLabel(_("Modify"));
39                 this->SetTitle(_("Modify Geoposition"));
40         
41                 std::map<int,int>::iterator intiter;
42                 std::map<int,wxString>::iterator striter;
43                 wxString strValue;
44                 
45                 // Load the data into the form.
46                 
47                 striter = GeopositionListPtr->find(GeopositionListIndex);
48                  
49                 if (striter->first == GeopositionListIndex){
50                 
51                         strValue = striter->second;
52                 
53                 }               
54                 
55                 txtGeoposition->SetValue(strValue);
56                 
57                 // Setup the Slider.
58                 
59                 intiter = GeopositionListPrefPtr->find(GeopositionListIndex);
60                 
61                 if (intiter->first == GeopositionListIndex && intiter->second > 0){
62                 
63                         sliPriority->SetValue(intiter->second);
64                         sliPriority->Enable();
65                         chkUsePref->SetValue(TRUE);
66                 
67                 }       
68                 
69         }
70         
71         EditSectionType = SectType;
72         
73 }
75 void frmContactEditorGeoposition::ProcessAction( wxCommandEvent& event )
76 {
78         long ListCtrlIndex;
80         if (EditorMode == FALSE){
81         
82                 // Add the language to the list.
84                 wxString strValue;
85                 
86                 strValue = txtGeoposition->GetValue();
87                 
88                 // Add language.
89                 
90                 GeopositionListPtr->insert(std::make_pair(GeopositionListIndex, strValue));
91                 
92                 // Add Email type.
93                 
94                 if (EditSectionType == CE_GENERAL){
95                 
96                         GeopositionListTypePtr->insert(std::make_pair(GeopositionListIndex, wxT("")));
97                 
98                 } else if (EditSectionType == CE_HOME) {
99                 
100                         GeopositionListTypePtr->insert(std::make_pair(GeopositionListIndex, wxT("home")));
101                 
102                 } else if (EditSectionType == CE_WORK) {
103                 
104                         GeopositionListTypePtr->insert(std::make_pair(GeopositionListIndex, wxT("work")));
105                 
106                 }
107                 
108                 // Add Language priority.
109                 
110                 if (chkUsePref->IsChecked()){
111                 
112                         GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, sliPriority->GetValue()));
113                 
114                 } else {
115                 
116                         GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, 0));                
117                 
118                 }               
119                 
120                 // Add the data to the form.
121                 
122                 wxListItem coldata;
123                 
124                 coldata.SetId(GeopositionListIndex);
125                 coldata.SetData(GeopositionListIndex);          
126                 coldata.SetText(txtGeoposition->GetValue());
127                 ListCtrlIndex = GeopositionListCtrlPtr->InsertItem(coldata);
128                 
129                 if (chkUsePref->IsChecked()){
130                 
131                         GeopositionListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
132                 
133                 }
134                 
135                 this->Close();          
136         
137         } else if (EditorMode == TRUE){
138         
139                 // Edit the language.
140                 
141                 wxString strAddress;
142                 wxString strValue;
143                 long longSelected = -1;
145                 GeopositionListPtr->erase(GeopositionListIndex);
146                 GeopositionListPtr->insert(std::make_pair(GeopositionListIndex, txtGeoposition->GetValue()));
147                 
148                 GeopositionListPrefPtr->erase(GeopositionListIndex);
149                 
150                 if (chkUsePref->IsChecked()){
151                 
152                         GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, sliPriority->GetValue()));
153                 
154                 } else {
155                 
156                         GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, 0));                
157                 
158                 }
159                 
160                 longSelected = GeopositionListCtrlPtr->GetNextItem(longSelected, 
161                         wxLIST_NEXT_ALL,
162                         wxLIST_STATE_SELECTED);
163                         
164                 if (longSelected == -1){
165                         return;
166                 }
167                 
168                 GeopositionListCtrlPtr->SetItem(longSelected, 0, txtGeoposition->GetValue());
169                 
170                 if (chkUsePref->IsChecked()){
171                 
172                         GeopositionListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
173                 
174                 } else {
175                 
176                         GeopositionListCtrlPtr->SetItem(longSelected, 1, wxT(""));
177                 
178                 }       
179                         
180                 this->Close();
181         
182         }
186 void frmContactEditorGeoposition::CloseWindow( wxCommandEvent& event )
188         this->Close();
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
203         // duplication.
205         GeopositionListPtr = GeopositionList;
206         GeopositionListAltIDPtr = GeopositionListAltID;
207         GeopositionListPIDPtr = GeopositionListPID;
208         GeopositionListTypePtr = GeopositionListType;
209         GeopositionListTokensPtr = GeopositionListTokens;
210         GeopositionListPrefPtr = GeopositionListPref;
211         GeopositionListCtrlPtr = GeopositionListCtrl;
212         GeopositionListIndex = GeopositionIndex;
213         
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