Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added copyright and license header to the C++ source and header files in the contacte...
[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         EditorMode = FALSE;
28         sliPriority->Disable();
29 }
31 void frmContactEditorGeoposition::EnablePriority( wxCommandEvent& event )
32 {
34         if (chkUsePref->IsChecked()){
35                 sliPriority->Enable();
36         } else {
37                 sliPriority->Disable();
38         }
39         
40 }
42 void frmContactEditorGeoposition::SetEditorMode(bool EditMode, SectionType SectType)
43 {
45         // Set the editor mode for adding or editing a timezone.
47         if (EditMode == FALSE){
48         
49                 EditorMode = FALSE;
50                 btnAction->SetLabel(_("Add"));
51                 this->SetTitle(_("Add Geoposition"));
52         
53         } else if (EditMode == TRUE){
54         
55                 EditorMode = TRUE;
56                 btnAction->SetLabel(_("Modify"));
57                 this->SetTitle(_("Modify Geoposition"));
58         
59                 std::map<int,int>::iterator intiter;
60                 std::map<int,wxString>::iterator striter;
61                 wxString strValue;
62                 
63                 // Load the data into the form.
64                 
65                 striter = GeopositionListPtr->find(GeopositionListIndex);
66                  
67                 if (striter->first == GeopositionListIndex){
68                 
69                         strValue = striter->second;
70                 
71                 }               
72                 
73                 txtGeoposition->SetValue(strValue);
74                 
75                 // Setup the Slider.
76                 
77                 intiter = GeopositionListPrefPtr->find(GeopositionListIndex);
78                 
79                 if (intiter->first == GeopositionListIndex && intiter->second > 0){
80                 
81                         sliPriority->SetValue(intiter->second);
82                         sliPriority->Enable();
83                         chkUsePref->SetValue(TRUE);
84                 
85                 }       
86                 
87         }
88         
89         EditSectionType = SectType;
90         
91 }
93 void frmContactEditorGeoposition::ProcessAction( wxCommandEvent& event )
94 {
96         long ListCtrlIndex;
98         if (EditorMode == FALSE){
99         
100                 // Add the language to the list.
102                 wxString strValue;
103                 
104                 strValue = txtGeoposition->GetValue();
105                 
106                 // Add language.
107                 
108                 GeopositionListPtr->insert(std::make_pair(GeopositionListIndex, strValue));
109                 
110                 // Add Email type.
111                 
112                 if (EditSectionType == CE_GENERAL){
113                 
114                         GeopositionListTypePtr->insert(std::make_pair(GeopositionListIndex, wxT("")));
115                 
116                 } else if (EditSectionType == CE_HOME) {
117                 
118                         GeopositionListTypePtr->insert(std::make_pair(GeopositionListIndex, wxT("home")));
119                 
120                 } else if (EditSectionType == CE_WORK) {
121                 
122                         GeopositionListTypePtr->insert(std::make_pair(GeopositionListIndex, wxT("work")));
123                 
124                 }
125                 
126                 // Add Language priority.
127                 
128                 if (chkUsePref->IsChecked()){
129                 
130                         GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, sliPriority->GetValue()));
131                 
132                 } else {
133                 
134                         GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, 0));                
135                 
136                 }               
137                 
138                 // Add the data to the form.
139                 
140                 wxListItem coldata;
141                 
142                 coldata.SetId(GeopositionListIndex);
143                 coldata.SetData(GeopositionListIndex);          
144                 coldata.SetText(txtGeoposition->GetValue());
145                 ListCtrlIndex = GeopositionListCtrlPtr->InsertItem(coldata);
146                 
147                 if (chkUsePref->IsChecked()){
148                 
149                         GeopositionListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
150                 
151                 }
152                 
153                 this->Close();          
154         
155         } else if (EditorMode == TRUE){
156         
157                 // Edit the language.
158                 
159                 wxString strAddress;
160                 wxString strValue;
161                 long longSelected = -1;
163                 GeopositionListPtr->erase(GeopositionListIndex);
164                 GeopositionListPtr->insert(std::make_pair(GeopositionListIndex, txtGeoposition->GetValue()));
165                 
166                 GeopositionListPrefPtr->erase(GeopositionListIndex);
167                 
168                 if (chkUsePref->IsChecked()){
169                 
170                         GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, sliPriority->GetValue()));
171                 
172                 } else {
173                 
174                         GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, 0));                
175                 
176                 }
177                 
178                 longSelected = GeopositionListCtrlPtr->GetNextItem(longSelected, 
179                         wxLIST_NEXT_ALL,
180                         wxLIST_STATE_SELECTED);
181                         
182                 if (longSelected == -1){
183                         return;
184                 }
185                 
186                 GeopositionListCtrlPtr->SetItem(longSelected, 0, txtGeoposition->GetValue());
187                 
188                 if (chkUsePref->IsChecked()){
189                 
190                         GeopositionListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
191                 
192                 } else {
193                 
194                         GeopositionListCtrlPtr->SetItem(longSelected, 1, wxT(""));
195                 
196                 }       
197                         
198                 this->Close();
199         
200         }
204 void frmContactEditorGeoposition::CloseWindow( wxCommandEvent& event )
206         this->Close();
209 void frmContactEditorGeoposition::SetupPointers(std::map<int, wxString> *GeopositionList,
210         std::map<int, wxString> *GeopositionListAltID,
211         std::map<int, wxString> *GeopositionListPID,
212         std::map<int, wxString> *GeopositionListType,
213         std::map<int, wxString> *GeopositionListTokens,
214         std::map<int, wxString> *GeopositionListMediatype,      
215         std::map<int, int> *GeopositionListPref,
216         wxListCtrl *GeopositionListCtrl,
217         int GeopositionIndex )
220         // Setup the pointers so that the data can be processed without
221         // duplication.
223         GeopositionListPtr = GeopositionList;
224         GeopositionListAltIDPtr = GeopositionListAltID;
225         GeopositionListPIDPtr = GeopositionListPID;
226         GeopositionListTypePtr = GeopositionListType;
227         GeopositionListTokensPtr = GeopositionListTokens;
228         GeopositionListPrefPtr = GeopositionListPref;
229         GeopositionListCtrlPtr = GeopositionListCtrl;
230         GeopositionListIndex = GeopositionIndex;
231         
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