Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed references to the boost library in remaining source and header files.
[xestiaab/.git] / source / contacteditor / frmContactEditorLanguages.cpp
1 // frmContactEditorLanguages.cpp - frmContactEditorLanguages 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 "frmContactEditorLanguages.h"
20 #include "../common/textprocessing.h"
21 #include <map>
23 frmContactEditorLanguages::frmContactEditorLanguages( wxWindow* parent )
24 :
25 frmContactEditorLanguagesADT( parent )
26 {
27         EditorMode = FALSE;
28         sliPriority->Disable();
29 }
31 void frmContactEditorLanguages::EnablePriority( wxCommandEvent& event )
32 {
33         if (chkUsePref->IsChecked()){
34                 sliPriority->Enable();
35         } else {
36                 sliPriority->Disable();
37         }
38 }
40 void frmContactEditorLanguages::SetEditorMode(bool EditMode, SectionType SectType)
41 {
43         // Set the editor mode for adding or editing an email address.
45         if (EditMode == FALSE){
46         
47                 EditorMode = FALSE;
48                 btnAction->SetLabel(_("Add"));
49                 this->SetTitle(_("Add Language"));
50         
51         } else if (EditMode == TRUE){
52         
53                 EditorMode = TRUE;
54                 btnAction->SetLabel(_("Modify"));
55                 this->SetTitle(_("Modify Language"));
56         
57                 std::map<int,int>::iterator intiter;
58                 std::map<int,wxString>::iterator striter;
59                 wxString strValue;
60                 
61                 // Load the data into the form.
62                 
63                 striter = LanguageListPtr->find(LanguageListIndex);
64                  
65                 if (striter->first == LanguageListIndex){
66                 
67                         strValue = striter->second;
68                 
69                 }
70                 
71                 txtLanguage->SetValue(strValue);
72                 
73                 // Setup the Slider.
74                 
75                 intiter = LanguageListPrefPtr->find(LanguageListIndex);
76                 
77                 if (intiter->first == LanguageListIndex && intiter->second > 0){
78                 
79                         sliPriority->SetValue(intiter->second);
80                         sliPriority->Enable();
81                         chkUsePref->SetValue(TRUE);
82                 
83                 }       
84                 
85         }
86         
87         EditSectionType = SectType;
88 }
90 void frmContactEditorLanguages::ProcessAction( wxCommandEvent& event )
91 {
93         long ListCtrlIndex;
95         if (EditorMode == FALSE){
96         
97                 // Add the language to the list.
99                 wxString strValue;
100                 
101                 // Add language.
102                 
103                 LanguageListPtr->insert(std::make_pair(LanguageListIndex, txtLanguage->GetValue()));
104                 
105                 // Add Email type.
106                 
107                 if (EditSectionType == CE_GENERAL){
108                 
109                         LanguageListTypePtr->insert(std::make_pair(LanguageListIndex, wxT("")));
110                 
111                 } else if (EditSectionType == CE_HOME) {
112                 
113                         LanguageListTypePtr->insert(std::make_pair(LanguageListIndex, wxT("home")));
114                 
115                 } else if (EditSectionType == CE_WORK) {
116                 
117                         LanguageListTypePtr->insert(std::make_pair(LanguageListIndex, wxT("work")));
118                 
119                 }
120                 
121                 // Add Language priority.
122                 
123                 if (chkUsePref->IsChecked()){
124                 
125                         LanguageListPrefPtr->insert(std::make_pair(LanguageListIndex, sliPriority->GetValue()));
126                 
127                 } else {
128                 
129                         LanguageListPrefPtr->insert(std::make_pair(LanguageListIndex, 0));              
130                 
131                 }               
132                 
133                 // Add the data to the form.
134                 
135                 wxListItem coldata;
136                 
137                 coldata.SetId(LanguageListIndex);
138                 coldata.SetData(LanguageListIndex);             
139                 coldata.SetText(txtLanguage->GetValue());
140                 ListCtrlIndex = LanguageListCtrlPtr->InsertItem(coldata);
141                 
142                 if (chkUsePref->IsChecked()){
143                 
144                         LanguageListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->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                 LanguageListPtr->erase(LanguageListIndex);
159                 LanguageListPtr->insert(std::make_pair(LanguageListIndex, txtLanguage->GetValue()));
160                 
161                 LanguageListPrefPtr->erase(LanguageListIndex);
162                 
163                 if (chkUsePref->IsChecked()){
164                 
165                         LanguageListPrefPtr->insert(std::make_pair(LanguageListIndex, sliPriority->GetValue()));
166                 
167                 } else {
168                 
169                         LanguageListPrefPtr->insert(std::make_pair(LanguageListIndex, 0));              
170                 
171                 }
172                 
173                 longSelected = LanguageListCtrlPtr->GetNextItem(longSelected, 
174                         wxLIST_NEXT_ALL,
175                         wxLIST_STATE_SELECTED);
176                         
177                 if (longSelected == -1){
178                         return;
179                 }
180                 
181                 LanguageListCtrlPtr->SetItem(longSelected, 0, txtLanguage->GetValue());         
182                 
183                 if (chkUsePref->IsChecked()){
184                 
185                         LanguageListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
186                 
187                 } else {
188                 
189                         LanguageListCtrlPtr->SetItem(longSelected, 1, wxT(""));
190                 
191                 }       
192                         
193                 this->Close();
194         
195         }
199 void frmContactEditorLanguages::CloseWindow( wxCommandEvent& event )
202         // Close the window.
203         
204         this->Close();
208 void frmContactEditorLanguages::SetupPointers(std::map<int, wxString> *LanguageList,
209         std::map<int, wxString> *LanguageListAltID,
210         std::map<int, wxString> *LanguageListPID,
211         std::map<int, wxString> *LanguageListType,
212         std::map<int, wxString> *LanguageListTokens,
213         std::map<int, int> *LanguageListPref,
214         wxListCtrl *LanguageListCtrl,
215         int LanguageIndex )
218         // Setup the pointers so that the data can be processed without
219         // duplication.
221         LanguageListPtr = LanguageList;
222         LanguageListAltIDPtr = LanguageListAltID;
223         LanguageListPIDPtr = LanguageListPID;
224         LanguageListTypePtr = LanguageListType;
225         LanguageListTokensPtr = LanguageListTokens;
226         LanguageListPrefPtr = LanguageListPref;
227         LanguageListCtrlPtr = LanguageListCtrl;
228         LanguageListIndex = LanguageIndex;
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