Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
62937afa498f4596f5dbe4098f9a5251b60e5e94
[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"
20 #include "../common/textprocessing.h"
22 frmContactEditorNickname::frmContactEditorNickname( wxWindow* parent )
23 :
24 frmContactEditorNicknameADT( parent )
25 {
27 }
29 void frmContactEditorNickname::InitAddressEditor( wxInitDialogEvent& event )
30 {
31         // Do nothing with this subroutine for the time being.
32 }
34 void frmContactEditorNickname::EnablePriority( wxCommandEvent& event )
35 {
36         if (chkUsePref->IsChecked()){
37                 sliPriority->Enable();
38         } else {
39                 sliPriority->Disable();
40         }
41 }
43 void frmContactEditorNickname::ProcessData( wxCommandEvent& event )
44 {
45         long ListCtrlIndex;
47         if (EditorMode == FALSE){
48         
49                 // Add the language to the list.
51                 wxString strValue;
52                 
53                 // Add nickname.
54                 
55                 NicknamesListPtr->insert(std::make_pair(NicknamesListIndex, txtNickname->GetValue()));
56                 
57                 // Add nickname type.
58                 
59                 if (EditSectionType == CE_GENERAL){
60                 
61                         NicknamesListTypePtr->insert(std::make_pair(NicknamesListIndex, wxT("")));
62                 
63                 } else if (EditSectionType == CE_HOME) {
64                 
65                         NicknamesListTypePtr->insert(std::make_pair(NicknamesListIndex, wxT("home")));
66                 
67                 } else if (EditSectionType == CE_WORK) {
68                 
69                         NicknamesListTypePtr->insert(std::make_pair(NicknamesListIndex, wxT("work")));
70                 
71                 }
72                 
73                 // Add nickname language.
74                 
75                 NicknamesListLanguagePtr->insert(std::make_pair(NicknamesListIndex, cmbLanguage->GetValue()));
76                 
77                 // Add nickname priority.
78                 
79                 if (chkUsePref->IsChecked()){
80                 
81                         NicknamesListPrefPtr->insert(std::make_pair(NicknamesListIndex, sliPriority->GetValue()));
82                 
83                 } else {
84                 
85                         NicknamesListPrefPtr->insert(std::make_pair(NicknamesListIndex, 0));            
86                 
87                 }               
88                 
89                 // Add the data to the form.
90                 
91                 wxListItem coldata;
92                 
93                 coldata.SetId(NicknamesListIndex);
94                 coldata.SetData(NicknamesListIndex);            
95                 coldata.SetText(txtNickname->GetValue());
96                 ListCtrlIndex = NicknamesListCtrlPtr->InsertItem(coldata);
97                 
98                 if (chkUsePref->IsChecked()){
99                 
100                         NicknamesListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
101                 
102                 }
103                 
104                 this->Close();          
105         
106         } else if (EditorMode == TRUE){
107         
108                 // Edit the language.
109                 
110                 wxString strAddress;
111                 wxString strValue;
112                 long longSelected = -1;
114                 NicknamesListPtr->erase(NicknamesListIndex);
115                 NicknamesListPtr->insert(std::make_pair(NicknamesListIndex, txtNickname->GetValue()));
116                 
117                 NicknamesListPrefPtr->erase(NicknamesListIndex);
118                 
119                 if (chkUsePref->IsChecked()){
120                 
121                         NicknamesListPrefPtr->insert(std::make_pair(NicknamesListIndex, sliPriority->GetValue()));
122                 
123                 } else {
124                 
125                         NicknamesListPrefPtr->insert(std::make_pair(NicknamesListIndex, 0));            
126                 
127                 }
128                 
129                 NicknamesListLanguagePtr->erase(NicknamesListIndex);
130                 NicknamesListLanguagePtr->insert(std::make_pair(NicknamesListIndex, cmbLanguage->GetValue()));
131                 
132                 longSelected = NicknamesListCtrlPtr->GetNextItem(longSelected, 
133                         wxLIST_NEXT_ALL,
134                         wxLIST_STATE_SELECTED);
135                         
136                 if (longSelected == -1){
137                         return;
138                 }
139                 
140                 NicknamesListCtrlPtr->SetItem(longSelected, 0, txtNickname->GetValue());
141                 
142                 if (chkUsePref->IsChecked()){
143                 
144                         NicknamesListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
145                 
146                 } else {
147                 
148                         NicknamesListCtrlPtr->SetItem(longSelected, 1, wxT(""));
149                 
150                 }       
151                         
152                 this->Close();
153         
154         }
158 void frmContactEditorNickname::CloseWindow( wxCommandEvent& event )
160         this->Close();
163 void frmContactEditorNickname::SetEditorMode(bool EditMode, SectionType SectType)
165         // Set if the editor is adding or editing an address.
166         // FALSE = Add
167         // TRUE = Edit
168         
169         if (EditMode == FALSE){
170         
171                 EditorMode = FALSE;
172                 btnAction->SetLabel(_("Add"));
173                 this->SetTitle(_("Add Nickname"));
174         
175         } else if (EditMode == TRUE){
176         
177                 EditorMode = TRUE;
178                 btnAction->SetLabel(_("Modify"));
179                 this->SetTitle(_("Modify Nickname"));
180                 
181                 std::map<int,int>::iterator intiter;
182                 std::map<int,wxString>::iterator striter;               
183                 wxString strValue;
184                 
185                 // Load the data into the form. Get the website.
186                 
187                 striter = NicknamesListPtr->find(NicknamesListIndex);
188                  
189                 if (striter->first == NicknamesListIndex){
190                 
191                         strValue = striter->second;
192                 
193                 }
194                 
195                 txtNickname->SetValue(strValue);
196                 
197                 strValue.Clear();
198                 
199                 striter = NicknamesListLanguagePtr->find(NicknamesListIndex);
200                  
201                 if (striter->first == NicknamesListIndex){
202                 
203                         strValue = striter->second;
204                 
205                 }
206                 
207                 cmbLanguage->SetValue(strValue);
208                 strValue.Clear();
209                 
210                 // Get the website priority.
211                 
212                 intiter = NicknamesListPrefPtr->find(NicknamesListIndex);
213                 
214                 if (intiter->first == NicknamesListIndex && intiter->second > 0){
215                 
216                         sliPriority->SetValue(intiter->second);
217                         sliPriority->Enable();
218                         chkUsePref->SetValue(TRUE);
219                 
220                 }       
221                 
222         }
223         
224         EditSectionType = SectType;     
225                 
228 void frmContactEditorNickname::SetupPointers(std::map<int, wxString> *NicknamesList,            
229         std::map<int, wxString> *NicknamesListAltID,
230         std::map<int, wxString> *NicknamesListPID,
231         std::map<int, wxString> *NicknamesListType,
232         std::map<int, wxString> *NicknamesListLanguage,
233         std::map<int, wxString> *NicknamesListTokens,
234         std::map<int, int> *NicknamesListPref,
235         wxListCtrl *NicknamesListCtrl,
236         int NicknamesIndex )
239         NicknamesListPtr = NicknamesList;
240         NicknamesListAltIDPtr = NicknamesListAltID;
241         NicknamesListPIDPtr = NicknamesListPID;
242         NicknamesListTypePtr = NicknamesListType;
243         NicknamesListLanguagePtr = NicknamesListLanguage;
244         NicknamesListTokensPtr = NicknamesListTokens;
245         NicknamesListPrefPtr = NicknamesListPref;
246         NicknamesListCtrlPtr = NicknamesListCtrl;
247         NicknamesListIndex = NicknamesIndex;
248         
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