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