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