1 #include "frmContactEditorRoles.h"
5 #include "../common/textprocessing.h"
7 frmContactEditorRoles::frmContactEditorRoles( wxWindow* parent )
9 frmContactEditorRolesADT( parent )
12 sliPriority->Disable();
15 void frmContactEditorRoles::EnablePriority( wxCommandEvent& event )
17 if (chkUsePref->IsChecked()){
18 sliPriority->Enable();
20 sliPriority->Disable();
24 void frmContactEditorRoles::ProcessAction( wxCommandEvent& event )
26 // Set if the editor is adding or editing an address.
32 if (EditorMode == FALSE){
36 // Get the website address.
38 RolesListPtr->insert(std::make_pair(RolesListIndex, txtRole->GetValue()));
40 // Get the type of website.
42 if (EditSectionType == CE_GENERAL){
44 RolesListTypePtr->insert(std::make_pair(RolesListIndex, wxT("")));
46 } else if (EditSectionType == CE_HOME) {
48 RolesListTypePtr->insert(std::make_pair(RolesListIndex, wxT("home")));
50 } else if (EditSectionType == CE_WORK) {
52 RolesListTypePtr->insert(std::make_pair(RolesListIndex, wxT("work")));
56 // Add the website priority.
58 if (chkUsePref->IsChecked()){
60 RolesListPrefPtr->insert(std::make_pair(RolesListIndex, sliPriority->GetValue()));
64 RolesListPrefPtr->insert(std::make_pair(RolesListIndex, 0));
72 coldata.SetId(RolesListIndex);
73 coldata.SetData(RolesListIndex);
74 coldata.SetText(txtRole->GetValue());
75 ListCtrlIndex = RolesListCtrlPtr->InsertItem(coldata);
77 if (chkUsePref->IsChecked()){
79 RolesListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
88 long longSelected = -1;
90 RolesListPtr->erase(RolesListIndex);
91 RolesListPtr->insert(std::make_pair(RolesListIndex, txtRole->GetValue()));
93 // Update the slider priority.
95 RolesListPrefPtr->erase(RolesListIndex);
97 if (chkUsePref->IsChecked()){
99 RolesListPrefPtr->insert(std::make_pair(RolesListIndex, sliPriority->GetValue()));
103 RolesListPrefPtr->insert(std::make_pair(RolesListIndex, 0));
109 longSelected = RolesListCtrlPtr->GetNextItem(longSelected,
111 wxLIST_STATE_SELECTED);
113 if (longSelected == -1){
117 RolesListCtrlPtr->SetItem(longSelected, 0, txtRole->GetValue());
119 if (chkUsePref->IsChecked()){
121 RolesListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
125 RolesListCtrlPtr->SetItem(longSelected, 1, wxT(""));
134 void frmContactEditorRoles::SetEditorMode(bool EditMode, SectionType SectType)
136 // Set if the editor is adding or editing an address.
140 if (EditMode == FALSE){
143 btnAction->SetLabel(_("Add"));
144 this->SetTitle(_("Add Title"));
146 } else if (EditMode == TRUE){
149 btnAction->SetLabel(_("Modify"));
150 this->SetTitle(_("Modify Title"));
152 std::map<int,int>::iterator intiter;
153 std::map<int,wxString>::iterator striter;
156 // Load the data into the form. Get the website.
158 striter = RolesListPtr->find(RolesListIndex);
160 if (striter->first == RolesListIndex){
162 strValue = striter->second;
166 txtRole->SetValue(strValue);
170 // Get the website priority.
172 intiter = RolesListPrefPtr->find(RolesListIndex);
174 if (intiter->first == RolesListIndex && intiter->second > 0){
176 sliPriority->SetValue(intiter->second);
177 sliPriority->Enable();
178 chkUsePref->SetValue(TRUE);
184 EditSectionType = SectType;
188 void frmContactEditorRoles::CloseWindow( wxCommandEvent& event )
193 void frmContactEditorRoles::SetupPointers(std::map<int, wxString> *RolesList,
194 std::map<int, wxString> *RolesListLanguage,
195 std::map<int, wxString> *RolesListAltID,
196 std::map<int, wxString> *RolesListPID,
197 std::map<int, wxString> *RolesListType,
198 std::map<int, wxString> *RolesListTokens,
199 std::map<int, int> *RolesListPref,
200 wxListCtrl *RolesListCtrl,
204 RolesListPtr = RolesList;
205 RolesListLanguagePtr = RolesListLanguage;
206 RolesListAltIDPtr = RolesListAltID;
207 RolesListPIDPtr = RolesListPID;
208 RolesListTypePtr = RolesListType;
209 RolesListTokensPtr = RolesListTokens;
210 RolesListPrefPtr = RolesListPref;
211 RolesListCtrlPtr = RolesListCtrl;
212 RolesListIndex = RolesIndex;