Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmContactEditor(*): Call Layout on szrGeneral after adding priorty control
[xestiaab/.git] / source / contacteditor / frmContactEditorEmail.cpp
1 // frmContactEditorEmail.cpp - frmContactEditorEmail 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 "frmContactEditorEmail.h"
20 #include <map>
21 #include "../common/textprocessing.h"
23 frmContactEditorEmail::frmContactEditorEmail( wxWindow* parent )
24 :
25 frmContactEditorEmailADT( parent )
26 {
27         
28         // Setup the window.
29         
30         EditorMode = FALSE;
31         priorityCtrl = new XABPriorityCtrl(tabGeneral);
32         szrGeneral->Add(priorityCtrl, 1, wxEXPAND, 5);
33         szrGeneral->Layout();
34         
35 }
37 void frmContactEditorEmail::ProcessData( wxCommandEvent& event )
38 {
39         
40         // Process action.
41         
42         long ListCtrlIndex;
43         
44         if (EditorMode == FALSE){
45         
46                 // Add the email address to the list.
47         
48                 wxString strAddress;
49                 wxString strValue;
50                 
51                 // Add Email address.
52                 
53                 EmailListPtr->insert(std::make_pair(EmailListIndex, txtEmail->GetValue()));
54                 
55                 // Add Email type.
56                 
57                 if (EditSectionType == CE_GENERAL){
58                 
59                         EmailListTypePtr->insert(std::make_pair(EmailListIndex, wxT("")));
60                 
61                 } else if (EditSectionType == CE_HOME) {
62                 
63                         EmailListTypePtr->insert(std::make_pair(EmailListIndex, wxT("home")));
64                 
65                 } else if (EditSectionType == CE_WORK) {
66                 
67                         EmailListTypePtr->insert(std::make_pair(EmailListIndex, wxT("work")));
68                 
69                 }
70                 
71                 // Add Email priority.
72                 
73                 if (priorityCtrl->IsPriorityChecked()){
74                 
75                         EmailListPrefPtr->insert(std::make_pair(EmailListIndex, priorityCtrl->GetValue()));
76                 
77                 } else {
78                 
79                         EmailListPrefPtr->insert(std::make_pair(EmailListIndex, 0));            
80                 
81                 }               
82                 
83                 // Add the data to the form.
84                 
85                 wxListItem coldata;
86                 
87                 coldata.SetId(EmailListIndex);
88                 coldata.SetData(EmailListIndex);                
89                 coldata.SetText(txtEmail->GetValue());
90                 ListCtrlIndex = EmailListCtrlPtr->InsertItem(coldata);
91                 
92                 if (priorityCtrl->IsPriorityChecked()){
93                 
94                         EmailListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), priorityCtrl->GetValue()));
95                 
96                 }
97                 
98                 this->Close();
99         
100         } else if (EditorMode == TRUE){
101         
102                 // Edit the email address.
103                 
104                 wxString strAddress;
105                 wxString strValue;
106                 long longSelected = -1;
108                 EmailListPtr->erase(EmailListIndex);
109                 EmailListPtr->insert(std::make_pair(EmailListIndex, txtEmail->GetValue()));
110                 
111                 EmailListPrefPtr->erase(EmailListIndex);
112                 
113                 if (priorityCtrl->IsPriorityChecked()){
114                 
115                         EmailListPrefPtr->insert(std::make_pair(EmailListIndex, priorityCtrl->GetValue()));
116                 
117                 } else {
118                 
119                         EmailListPrefPtr->insert(std::make_pair(EmailListIndex, 0));            
120                 
121                 }
122                 
123                 longSelected = EmailListCtrlPtr->GetNextItem(longSelected, 
124                         wxLIST_NEXT_ALL,
125                         wxLIST_STATE_SELECTED);
126                         
127                 if (longSelected == -1){
128                         return;
129                 }
130                 
131                 EmailListCtrlPtr->SetItem(longSelected, 0, txtEmail->GetValue());               
132                 
133                 if (priorityCtrl->IsPriorityChecked()){
134                 
135                         EmailListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), priorityCtrl->GetValue()));
136                 
137                 } else {
138                 
139                         EmailListCtrlPtr->SetItem(longSelected, 1, wxT(""));
140                 
141                 }       
142                         
143                 this->Close();  
144         
145         }       
146         
149 void frmContactEditorEmail::CloseWindow( wxCommandEvent& event )
151         
152         // Close this window.
153         
154         this->Close();
155         
158 void frmContactEditorEmail::SetEditorMode(bool EditMode, SectionType SectType)
161         // Set the editor mode.
162         
163         // Set the editor mode for adding or editing an email address.
165         if (EditMode == FALSE){
166         
167                 EditorMode = FALSE;
168                 btnAction->SetLabel(_("Add"));
169                 this->SetTitle(_("Add Email"));
170         
171         } else if (EditMode == TRUE){
172         
173                 EditorMode = TRUE;
174                 btnAction->SetLabel(_("Modify"));
175                 this->SetTitle(_("Modify Email"));
176         
177                 std::map<int,int>::iterator intiter;
178                 std::map<int,wxString>::iterator striter;
179                 wxString strValue;
180                 
181                 // Load the data into the form.
182                 
183                 striter = EmailListPtr->find(EmailListIndex);
184                  
185                 if (striter->first == EmailListIndex){
186                 
187                         strValue = striter->second;
188                 
189                 }
190                 
191                 txtEmail->SetValue(strValue);
192                 
193                 // Setup the Slider.
194                 
195                 intiter = EmailListPrefPtr->find(EmailListIndex);
196                 
197                 if (intiter->first == EmailListIndex && intiter->second > 0 &&
198                         intiter != EmailListPrefPtr->end()){
199                 
200                         priorityCtrl->SetValue(intiter->second);
201                         priorityCtrl->EnablePriority(true);
202                 
203                 }
204                 
205         }
206         
207         EditSectionType = SectType;
208         
211 void frmContactEditorEmail::SetupPointers(std::map<int, wxString> *EmailList,
212         std::map<int, wxString> *EmailListAltID,
213         std::map<int, wxString> *EmailListPID,
214         std::map<int, wxString> *EmailListType,
215         std::map<int, wxString> *EmailListTokens,
216         std::map<int, int> *EmailListPref,
217         wxListCtrl *EmailListCtrl,
218         int EmailIndex )
221         // Setup the pointers so that the data can be processed without
222         // duplication.
224         EmailListPtr = EmailList;
225         EmailListAltIDPtr = EmailListAltID;
226         EmailListPIDPtr = EmailListPID;
227         EmailListTypePtr = EmailListType;
228         EmailListTokensPtr = EmailListTokens;
229         EmailListPrefPtr = EmailListPref;
230         EmailListCtrlPtr = EmailListCtrl;
231         EmailListIndex = EmailIndex;
232         
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