Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
bcc3e87a70e31897ce7633e146336ffa3e3532b7
[xestiaab/.git] / source / contacteditor / frmContactEditorGeoposition.cpp
1 // frmContactEditorGeoposition.cpp - frmContactEditorGeoposition form.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "frmContactEditorGeoposition.h"
20 #include <map>
21 #include "../common/textprocessing.h"
23 frmContactEditorGeoposition::frmContactEditorGeoposition( wxWindow* parent )
24 :
25 frmContactEditorGeopositionADT( parent )
26 {
27         
28         // Setup the window.
29         
30         EditorMode = FALSE;
31         priorityCtrl = new XABPriorityCtrl(tabGeneral);
32         szrGeneral->Add(priorityCtrl, 1, wxEXPAND, 5);
33         szrGeneral->Layout();
34         
35 }
37 void frmContactEditorGeoposition::SetEditorMode(bool EditMode, SectionType SectType)
38 {
40         // Setup the editor mode.
41         
42         // Set the editor mode for adding or editing a timezone.
44         if (EditMode == FALSE){
45         
46                 EditorMode = FALSE;
47                 btnAction->SetLabel(_("Add"));
48                 this->SetTitle(_("Add Geoposition"));
49         
50         } else if (EditMode == TRUE){
51         
52                 EditorMode = TRUE;
53                 btnAction->SetLabel(_("Modify"));
54                 this->SetTitle(_("Modify Geoposition"));
55         
56                 std::map<int,int>::iterator intiter;
57                 std::map<int,wxString>::iterator striter;
58                 wxString strValue;
59                 
60                 // Load the data into the form.
61                 
62                 striter = GeopositionListPtr->find(GeopositionListIndex);
63                  
64                 if (striter->first == GeopositionListIndex){
65                 
66                         strValue = striter->second;
67                 
68                 }               
69                 
70                 txtGeoposition->SetValue(strValue);
71                 
72                 // Setup the Slider.
73                 
74                 intiter = GeopositionListPrefPtr->find(GeopositionListIndex);
75                 
76                 if (intiter->first == GeopositionListIndex && intiter->second > 0 &&
77                         intiter != GeopositionListPrefPtr->end()){
78                 
79                         priorityCtrl->SetValue(intiter->second);
80                         priorityCtrl->EnablePriority(true);
81                 
82                 }       
83                 
84         }
85         
86         EditSectionType = SectType;
87         
88 }
90 void frmContactEditorGeoposition::ProcessAction( wxCommandEvent& event )
91 {
93         // Process action.
94         
95         long ListCtrlIndex;
97         if (EditorMode == FALSE){
98         
99                 // Add the language to the list.
101                 wxString strValue;
102                 
103                 strValue = txtGeoposition->GetValue();
104                 
105                 // Add language.
106                 
107                 GeopositionListPtr->insert(std::make_pair(GeopositionListIndex, strValue));
108                 
109                 // Add Email type.
110                 
111                 if (EditSectionType == CE_GENERAL){
112                 
113                         GeopositionListTypePtr->insert(std::make_pair(GeopositionListIndex, wxT("")));
114                 
115                 } else if (EditSectionType == CE_HOME) {
116                 
117                         GeopositionListTypePtr->insert(std::make_pair(GeopositionListIndex, wxT("home")));
118                 
119                 } else if (EditSectionType == CE_WORK) {
120                 
121                         GeopositionListTypePtr->insert(std::make_pair(GeopositionListIndex, wxT("work")));
122                 
123                 }
124                 
125                 // Add Language priority.
126                 
127                 if (priorityCtrl->IsPriorityChecked()){
128                 
129                         GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, priorityCtrl->GetValue()));
130                 
131                 } else {
132                 
133                         GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, 0));                
134                 
135                 }               
136                 
137                 // Add the data to the form.
138                 
139                 wxListItem coldata;
140                 
141                 coldata.SetId(GeopositionListIndex);
142                 coldata.SetData(GeopositionListIndex);          
143                 coldata.SetText(txtGeoposition->GetValue());
144                 ListCtrlIndex = GeopositionListCtrlPtr->InsertItem(coldata);
145                 
146                 if (priorityCtrl->IsPriorityChecked()){
147                 
148                         GeopositionListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), priorityCtrl->GetValue()));
149                 
150                 }
151                 
152                 this->Close();          
153         
154         } else if (EditorMode == TRUE){
155         
156                 // Edit the language.
157                 
158                 wxString strAddress;
159                 wxString strValue;
160                 long longSelected = -1;
162                 GeopositionListPtr->erase(GeopositionListIndex);
163                 GeopositionListPtr->insert(std::make_pair(GeopositionListIndex, txtGeoposition->GetValue()));
164                 
165                 GeopositionListPrefPtr->erase(GeopositionListIndex);
166                 
167                 if (priorityCtrl->IsPriorityChecked()){
168                 
169                         GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, priorityCtrl->GetValue()));
170                 
171                 } else {
172                 
173                         GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, 0));                
174                 
175                 }
176                 
177                 longSelected = GeopositionListCtrlPtr->GetNextItem(longSelected, 
178                         wxLIST_NEXT_ALL,
179                         wxLIST_STATE_SELECTED);
180                         
181                 if (longSelected == -1){
182                         return;
183                 }
184                 
185                 GeopositionListCtrlPtr->SetItem(longSelected, 0, txtGeoposition->GetValue());
186                 
187                 if (priorityCtrl->IsPriorityChecked()){
188                 
189                         GeopositionListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), priorityCtrl->GetValue()));
190                 
191                 } else {
192                 
193                         GeopositionListCtrlPtr->SetItem(longSelected, 1, wxT(""));
194                 
195                 }       
196                         
197                 this->Close();
198         
199         }
203 void frmContactEditorGeoposition::CloseWindow( wxCommandEvent& event )
205         
206         // Close this window.
207         
208         this->Close();
209         
212 void frmContactEditorGeoposition::SetupPointers(std::map<int, wxString> *GeopositionList,
213         std::map<int, wxString> *GeopositionListAltID,
214         std::map<int, wxString> *GeopositionListPID,
215         std::map<int, wxString> *GeopositionListType,
216         std::map<int, wxString> *GeopositionListDataType,
217         std::map<int, wxString> *GeopositionListTokens,
218         std::map<int, wxString> *GeopositionListMediatype,      
219         std::map<int, int> *GeopositionListPref,
220         wxListCtrl *GeopositionListCtrl,
221         int GeopositionIndex )
224         // Setup the pointers so that the data can be processed without
225         // duplication.
227         GeopositionListPtr = GeopositionList;
228         GeopositionListAltIDPtr = GeopositionListAltID;
229         GeopositionListPIDPtr = GeopositionListPID;
230         GeopositionListTypePtr = GeopositionListType;
231         GeopositionListDataTypePtr = GeopositionListDataType;
232         GeopositionListTokensPtr = GeopositionListTokens;
233         GeopositionListPrefPtr = GeopositionListPref;
234         GeopositionListCtrlPtr = GeopositionListCtrl;
235         GeopositionListIndex = GeopositionIndex;
236         
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