1 #include "frmContactEditorTitles.h"
5 #include "../common/textprocessing.h"
7 frmContactEditorTitles::frmContactEditorTitles( wxWindow* parent )
9 frmContactEditorTitlesADT( parent )
12 sliPriority->Disable();
15 void frmContactEditorTitles::EnablePriority( wxCommandEvent& event )
17 if (chkUsePref->IsChecked()){
18 sliPriority->Enable();
20 sliPriority->Disable();
24 void frmContactEditorTitles::ProcessAction( wxCommandEvent& event )
26 // Set if the editor is adding or editing an address.
32 if (EditorMode == FALSE){
36 // Get the website address.
38 TitlesListPtr->insert(std::make_pair(TitlesListIndex, txtTitle->GetValue()));
40 // Get the type of website.
42 if (EditSectionType == CE_GENERAL){
44 TitlesListTypePtr->insert(std::make_pair(TitlesListIndex, wxT("")));
46 } else if (EditSectionType == CE_HOME) {
48 TitlesListTypePtr->insert(std::make_pair(TitlesListIndex, wxT("home")));
50 } else if (EditSectionType == CE_WORK) {
52 TitlesListTypePtr->insert(std::make_pair(TitlesListIndex, wxT("work")));
56 // Add the website priority.
58 if (chkUsePref->IsChecked()){
60 TitlesListPrefPtr->insert(std::make_pair(TitlesListIndex, sliPriority->GetValue()));
64 TitlesListPrefPtr->insert(std::make_pair(TitlesListIndex, 0));
72 coldata.SetId(TitlesListIndex);
73 coldata.SetData(TitlesListIndex);
74 coldata.SetText(txtTitle->GetValue());
75 ListCtrlIndex = TitlesListCtrlPtr->InsertItem(coldata);
77 if (chkUsePref->IsChecked()){
79 TitlesListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
88 long longSelected = -1;
90 TitlesListPtr->erase(TitlesListIndex);
91 TitlesListPtr->insert(std::make_pair(TitlesListIndex, txtTitle->GetValue()));
93 // Update the slider priority.
95 TitlesListPrefPtr->erase(TitlesListIndex);
97 if (chkUsePref->IsChecked()){
99 TitlesListPrefPtr->insert(std::make_pair(TitlesListIndex, sliPriority->GetValue()));
103 TitlesListPrefPtr->insert(std::make_pair(TitlesListIndex, 0));
109 longSelected = TitlesListCtrlPtr->GetNextItem(longSelected,
111 wxLIST_STATE_SELECTED);
113 if (longSelected == -1){
117 TitlesListCtrlPtr->SetItem(longSelected, 0, txtTitle->GetValue());
119 if (chkUsePref->IsChecked()){
121 TitlesListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
125 TitlesListCtrlPtr->SetItem(longSelected, 1, wxT(""));
134 void frmContactEditorTitles::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 = TitlesListPtr->find(TitlesListIndex);
160 if (striter->first == TitlesListIndex){
162 strValue = striter->second;
166 txtTitle->SetValue(strValue);
170 // Get the website priority.
172 intiter = TitlesListPrefPtr->find(TitlesListIndex);
174 if (intiter->first == TitlesListIndex && intiter->second > 0){
176 sliPriority->SetValue(intiter->second);
177 sliPriority->Enable();
178 chkUsePref->SetValue(TRUE);
184 EditSectionType = SectType;
188 void frmContactEditorTitles::CloseWindow( wxCommandEvent& event )
193 void frmContactEditorTitles::SetupPointers(std::map<int, wxString> *TitlesList,
194 std::map<int, wxString> *TitlesListLanguage,
195 std::map<int, wxString> *TitlesListAltID,
196 std::map<int, wxString> *TitlesListPID,
197 std::map<int, wxString> *TitlesListType,
198 std::map<int, wxString> *TitlesListTokens,
199 std::map<int, int> *TitlesListPref,
200 wxListCtrl *TitlesListCtrl,
204 TitlesListPtr = TitlesList;
205 TitlesListLanguagePtr = TitlesListLanguage;
206 TitlesListAltIDPtr = TitlesListAltID;
207 TitlesListPIDPtr = TitlesListPID;
208 TitlesListTypePtr = TitlesListType;
209 TitlesListTokensPtr = TitlesListTokens;
210 TitlesListPrefPtr = TitlesListPref;
211 TitlesListCtrlPtr = TitlesListCtrl;
212 TitlesListIndex = TitlesIndex;