Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Fixed source code formatting in CALURI for ConvertToV3
[xestiaab/.git] / source / contacteditor / frmContactEditorTimezones.cpp
1 // frmContactEditorTimezones.cpp - frmContactEditorTimezones 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 "frmContactEditorTimezones.h"
20 #include <map>
21 #include "../common/textprocessing.h"
23 frmContactEditorTimezones::frmContactEditorTimezones( wxWindow* parent )
24 :
25 frmContactEditorTimezonesADT( parent )
26 {
27         EditorMode = FALSE;
28         sliPriority->Disable();
29 }
31 void frmContactEditorTimezones::EnablePriority( wxCommandEvent& event )
32 {
33         if (chkUsePref->IsChecked()){
34                 sliPriority->Enable();
35         } else {
36                 sliPriority->Disable();
37         }
38 }
40 void frmContactEditorTimezones::SetEditorMode(bool EditMode, SectionType SectType)
41 {
43         // Set the editor mode for adding or editing a timezone.
45         if (EditMode == FALSE){
46         
47                 EditorMode = FALSE;
48                 btnAction->SetLabel(_("Add"));
49                 this->SetTitle(_("Add Timezone"));
50         
51         } else if (EditMode == TRUE){
52         
53                 EditorMode = TRUE;
54                 btnAction->SetLabel(_("Modify"));
55                 this->SetTitle(_("Modify Timezone"));
56         
57                 std::map<int,int>::iterator intiter;
58                 std::map<int,wxString>::iterator striter;
59                 wxString strValue;
60                 
61                 // Load the data into the form.
62                 
63                 striter = TZListPtr->find(TZListIndex);
64                  
65                 if (striter->first == TZListIndex){
66                 
67                         strValue = striter->second;
68                 
69                 }
70                 
71                 cmbTimezone->SetValue(strValue);
72                 
73                 // Setup the Slider.
74                 
75                 intiter = TZListPrefPtr->find(TZListIndex);
76                 
77                 if (intiter->first == TZListIndex && intiter->second > 0){
78                 
79                         sliPriority->SetValue(intiter->second);
80                         sliPriority->Enable();
81                         chkUsePref->SetValue(TRUE);
82                 
83                 }       
84                 
85         }
86         
87         EditSectionType = SectType;
88         
89 }
91 void frmContactEditorTimezones::ProcessAction( wxCommandEvent& event )
92 {
93         
94         long ListCtrlIndex;
96         if (EditorMode == FALSE){
97         
98                 // Add the language to the list.
100                 wxString strValue;
101                 
102                 // Add language.
103                 
104                 TZListPtr->insert(std::make_pair(TZListIndex, cmbTimezone->GetValue()));
105                 
106                 // Add Email type.
107                 
108                 if (EditSectionType == CE_GENERAL){
109                 
110                         TZListTypePtr->insert(std::make_pair(TZListIndex, wxT("")));
111                 
112                 } else if (EditSectionType == CE_HOME) {
113                 
114                         TZListTypePtr->insert(std::make_pair(TZListIndex, wxT("home")));
115                 
116                 } else if (EditSectionType == CE_WORK) {
117                 
118                         TZListTypePtr->insert(std::make_pair(TZListIndex, wxT("work")));
119                 
120                 }
121                 
122                 // Add Language priority.
123                 
124                 if (chkUsePref->IsChecked()){
125                 
126                         TZListPrefPtr->insert(std::make_pair(TZListIndex, sliPriority->GetValue()));
127                 
128                 } else {
129                 
130                         TZListPrefPtr->insert(std::make_pair(TZListIndex, 0));          
131                 
132                 }               
133                 
134                 // Add the data to the form.
135                 
136                 wxListItem coldata;
137                 
138                 coldata.SetId(TZListIndex);
139                 coldata.SetData(TZListIndex);           
140                 coldata.SetText(cmbTimezone->GetValue());
141                 ListCtrlIndex = TZListCtrlPtr->InsertItem(coldata);
142                 
143                 if (chkUsePref->IsChecked()){
144                 
145                         TZListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
146                 
147                 }
148                 
149                 this->Close();          
150         
151         } else if (EditorMode == TRUE){
152         
153                 // Edit the language.
154                 
155                 wxString strAddress;
156                 wxString strValue;
157                 long longSelected = -1;
159                 TZListPtr->erase(TZListIndex);
160                 TZListPtr->insert(std::make_pair(TZListIndex, cmbTimezone->GetValue()));
161                 
162                 TZListPrefPtr->erase(TZListIndex);
163                 
164                 if (chkUsePref->IsChecked()){
165                 
166                         TZListPrefPtr->insert(std::make_pair(TZListIndex, sliPriority->GetValue()));
167                 
168                 } else {
169                 
170                         TZListPrefPtr->insert(std::make_pair(TZListIndex, 0));          
171                 
172                 }
173                 
174                 longSelected = TZListCtrlPtr->GetNextItem(longSelected, 
175                         wxLIST_NEXT_ALL,
176                         wxLIST_STATE_SELECTED);
177                         
178                 if (longSelected == -1){
179                         return;
180                 }
181                 
182                 TZListCtrlPtr->SetItem(longSelected, 0, cmbTimezone->GetValue());               
183                 
184                 if (chkUsePref->IsChecked()){
185                 
186                         TZListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
187                 
188                 } else {
189                 
190                         TZListCtrlPtr->SetItem(longSelected, 1, wxT(""));
191                 
192                 }       
193                         
194                 this->Close();
195         
196         }
197         
200 void frmContactEditorTimezones::CloseWindow( wxCommandEvent& event )
202         this->Close();
205 void frmContactEditorTimezones::SetupPointers(std::map<int, wxString> *TZList,
206         std::map<int, wxString> *TZListAltID,
207         std::map<int, wxString> *TZListPID,
208         std::map<int, wxString> *TZListType,
209         std::map<int, wxString> *TZListTokens,
210         std::map<int, wxString> *TZListMediatype,       
211         std::map<int, int> *TZListPref,
212         wxListCtrl *TZListCtrl,
213         int TZIndex )
216         // Setup the pointers so that the data can be processed without
217         // duplication.
219         TZListPtr = TZList;
220         TZListAltIDPtr = TZListAltID;
221         TZListPIDPtr = TZListPID;
222         TZListTypePtr = TZListType;
223         TZListTokensPtr = TZListTokens;
224         TZListPrefPtr = TZListPref;
225         TZListCtrlPtr = TZListCtrl;
226         TZListIndex = TZIndex;
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