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