Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmPreferences: Removed std::cout printing contact background colour
[xestiaab/.git] / source / contacteditor / frmContactEditorNickname.cpp
1 // frmContactEditorNickname.cpp - frmContactEditorNickname 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 "frmContactEditorNickname.h"
21 frmContactEditorNickname::frmContactEditorNickname( wxWindow* parent )
22 :
23 frmContactEditorNicknameADT( parent )
24 {
26         std::vector<std::string> LanguageCodeList = GetLanguageCodeList();
27         
28         wxArrayString LanguageList;
29         
30         for (auto LanguageItem : LanguageCodeList){
31                 
32                 LanguageList.Add((wxString)LanguageItem, 1);
33                 
34         }
35         
36         cmbLanguage->Append(LanguageList);
37         
38 }
40 void frmContactEditorNickname::InitAddressEditor( wxInitDialogEvent& event )
41 {
42         // Do nothing with this subroutine for the time being.
43 }
45 void frmContactEditorNickname::EnablePriority( wxCommandEvent& event )
46 {
47         
48         // Enable/disable the priority.
49         
50         if (chkUsePref->IsChecked()){
51                 sliPriority->Enable();
52         } else {
53                 sliPriority->Disable();
54         }
55         
56 }
58 void frmContactEditorNickname::ProcessData( wxCommandEvent& event )
59 {
60         
61         // Process the data.
62         
63         long ListCtrlIndex;
65         if (EditorMode == FALSE){
66         
67                 // Add the language to the list.
69                 wxString strValue;
70                 
71                 // Add nickname.
72                 
73                 NicknamesListPtr->insert(std::make_pair(NicknamesListIndex, txtNickname->GetValue()));
74                 
75                 // Add nickname type.
76                 
77                 if (EditSectionType == CE_GENERAL){
78                 
79                         NicknamesListTypePtr->insert(std::make_pair(NicknamesListIndex, wxT("")));
80                 
81                 } else if (EditSectionType == CE_HOME) {
82                 
83                         NicknamesListTypePtr->insert(std::make_pair(NicknamesListIndex, wxT("home")));
84                 
85                 } else if (EditSectionType == CE_WORK) {
86                 
87                         NicknamesListTypePtr->insert(std::make_pair(NicknamesListIndex, wxT("work")));
88                 
89                 }
90                 
91                 // Add nickname language.
92                 
93                 NicknamesListLanguagePtr->insert(std::make_pair(NicknamesListIndex, cmbLanguage->GetValue()));
94                 
95                 // Add nickname priority.
96                 
97                 if (chkUsePref->IsChecked()){
98                 
99                         NicknamesListPrefPtr->insert(std::make_pair(NicknamesListIndex, sliPriority->GetValue()));
100                 
101                 } else {
102                 
103                         NicknamesListPrefPtr->insert(std::make_pair(NicknamesListIndex, 0));            
104                 
105                 }               
106                 
107                 // Add the data to the form.
108                 
109                 wxListItem coldata;
110                 
111                 coldata.SetId(NicknamesListIndex);
112                 coldata.SetData(NicknamesListIndex);            
113                 coldata.SetText(txtNickname->GetValue());
114                 ListCtrlIndex = NicknamesListCtrlPtr->InsertItem(coldata);
115                 
116                 if (chkUsePref->IsChecked()){
117                 
118                         NicknamesListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
119                 
120                 }
121                 
122                 this->Close();          
123         
124         } else if (EditorMode == TRUE){
125         
126                 // Edit the language.
127                 
128                 wxString strAddress;
129                 wxString strValue;
130                 long longSelected = -1;
132                 NicknamesListPtr->erase(NicknamesListIndex);
133                 NicknamesListPtr->insert(std::make_pair(NicknamesListIndex, txtNickname->GetValue()));
134                 
135                 NicknamesListPrefPtr->erase(NicknamesListIndex);
136                 
137                 if (chkUsePref->IsChecked()){
138                 
139                         NicknamesListPrefPtr->insert(std::make_pair(NicknamesListIndex, sliPriority->GetValue()));
140                 
141                 } else {
142                 
143                         NicknamesListPrefPtr->insert(std::make_pair(NicknamesListIndex, 0));            
144                 
145                 }
146                 
147                 NicknamesListLanguagePtr->erase(NicknamesListIndex);
148                 NicknamesListLanguagePtr->insert(std::make_pair(NicknamesListIndex, cmbLanguage->GetValue()));
149                 
150                 longSelected = NicknamesListCtrlPtr->GetNextItem(longSelected, 
151                         wxLIST_NEXT_ALL,
152                         wxLIST_STATE_SELECTED);
153                         
154                 if (longSelected == -1){
155                         return;
156                 }
157                 
158                 NicknamesListCtrlPtr->SetItem(longSelected, 0, txtNickname->GetValue());
159                 
160                 if (chkUsePref->IsChecked()){
161                 
162                         NicknamesListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
163                 
164                 } else {
165                 
166                         NicknamesListCtrlPtr->SetItem(longSelected, 1, wxT(""));
167                 
168                 }       
169                         
170                 this->Close();
171         
172         }
176 void frmContactEditorNickname::CloseWindow( wxCommandEvent& event )
178         
179         // Close this window.
180         
181         this->Close();
182         
185 void frmContactEditorNickname::SetEditorMode(bool EditMode, SectionType SectType)
187         
188         // Set if the editor is adding or editing an address.
189         // FALSE = Add
190         // TRUE = Edit
191         
192         if (EditMode == FALSE){
193         
194                 EditorMode = FALSE;
195                 btnAction->SetLabel(_("Add"));
196                 this->SetTitle(_("Add Nickname"));
197         
198         } else if (EditMode == TRUE){
199         
200                 EditorMode = TRUE;
201                 btnAction->SetLabel(_("Modify"));
202                 this->SetTitle(_("Modify Nickname"));
203                 
204                 std::map<int,int>::iterator intiter;
205                 std::map<int,wxString>::iterator striter;               
206                 wxString strValue;
207                 
208                 // Load the data into the form. Get the website.
209                 
210                 striter = NicknamesListPtr->find(NicknamesListIndex);
211                  
212                 if (striter->first == NicknamesListIndex){
213                 
214                         strValue = striter->second;
215                 
216                 }
217                 
218                 txtNickname->SetValue(strValue);
219                 
220                 strValue.Clear();
221                 
222                 striter = NicknamesListLanguagePtr->find(NicknamesListIndex);
223                  
224                 if (striter->first == NicknamesListIndex &&
225                         striter != NicknamesListLanguagePtr->end()){
226                 
227                         strValue = striter->second;
228                 
229                 }
230                 
231                 cmbLanguage->SetValue(strValue);
232                 strValue.Clear();
233                 
234                 // Get the website priority.
235                 
236                 intiter = NicknamesListPrefPtr->find(NicknamesListIndex);
237                 
238                 if (intiter->first == NicknamesListIndex && intiter->second > 0 &&
239                         intiter != NicknamesListPrefPtr->end()){
240                 
241                         sliPriority->SetValue(intiter->second);
242                         sliPriority->Enable();
243                         chkUsePref->SetValue(TRUE);
244                 
245                 }       
246                 
247         }
248         
249         EditSectionType = SectType;     
250                 
253 void frmContactEditorNickname::SetupPointers(std::map<int, wxString> *NicknamesList,            
254         std::map<int, wxString> *NicknamesListAltID,
255         std::map<int, wxString> *NicknamesListPID,
256         std::map<int, wxString> *NicknamesListType,
257         std::map<int, wxString> *NicknamesListLanguage,
258         std::map<int, wxString> *NicknamesListTokens,
259         std::map<int, int> *NicknamesListPref,
260         wxListCtrl *NicknamesListCtrl,
261         int NicknamesIndex )
264         // Setup the pointers.
265         
266         NicknamesListPtr = NicknamesList;
267         NicknamesListAltIDPtr = NicknamesListAltID;
268         NicknamesListPIDPtr = NicknamesListPID;
269         NicknamesListTypePtr = NicknamesListType;
270         NicknamesListLanguagePtr = NicknamesListLanguage;
271         NicknamesListTokensPtr = NicknamesListTokens;
272         NicknamesListPrefPtr = NicknamesListPref;
273         NicknamesListCtrlPtr = NicknamesListCtrl;
274         NicknamesListIndex = NicknamesIndex;
275         
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