1 #include "frmContactEditorWebsites.h"
5 #include "../common/textprocessing.h"
7 frmContactEditorWebsites::frmContactEditorWebsites( wxWindow* parent )
9 frmContactEditorWebsitesADT( parent )
12 sliPriority->Disable();
15 void frmContactEditorWebsites::EnablePriority( wxCommandEvent& event )
17 if (chkUsePref->IsChecked()){
18 sliPriority->Enable();
20 sliPriority->Disable();
24 void frmContactEditorWebsites::ProcessAction( wxCommandEvent& event )
26 // Set if the editor is adding or editing an address.
32 if (EditorMode == FALSE){
36 // Get the website address.
38 WebsiteListPtr->insert(std::make_pair(WebsiteListIndex, txtWebsite->GetValue()));
40 // Get the type of website.
42 if (EditSectionType == CE_GENERAL){
44 WebsiteListTypePtr->insert(std::make_pair(WebsiteListIndex, wxT("")));
46 } else if (EditSectionType == CE_HOME) {
48 WebsiteListTypePtr->insert(std::make_pair(WebsiteListIndex, wxT("home")));
50 } else if (EditSectionType == CE_WORK) {
52 WebsiteListTypePtr->insert(std::make_pair(WebsiteListIndex, wxT("work")));
56 // Add the website priority.
58 if (chkUsePref->IsChecked()){
60 WebsiteListPrefPtr->insert(std::make_pair(WebsiteListIndex, sliPriority->GetValue()));
64 WebsiteListPrefPtr->insert(std::make_pair(WebsiteListIndex, 0));
72 coldata.SetId(WebsiteListIndex);
73 coldata.SetData(WebsiteListIndex);
74 coldata.SetText(txtWebsite->GetValue());
75 ListCtrlIndex = WebsiteListCtrlPtr->InsertItem(coldata);
77 if (chkUsePref->IsChecked()){
79 WebsiteListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
87 // Update the website address.
88 long longSelected = -1;
90 WebsiteListPtr->erase(WebsiteListIndex);
91 WebsiteListPtr->insert(std::make_pair(WebsiteListIndex, txtWebsite->GetValue()));
93 // Update the slider priority.
95 WebsiteListPrefPtr->erase(WebsiteListIndex);
97 if (chkUsePref->IsChecked()){
99 WebsiteListPrefPtr->insert(std::make_pair(WebsiteListIndex, sliPriority->GetValue()));
103 WebsiteListPrefPtr->insert(std::make_pair(WebsiteListIndex, 0));
109 longSelected = WebsiteListCtrlPtr->GetNextItem(longSelected,
111 wxLIST_STATE_SELECTED);
113 if (longSelected == -1){
117 WebsiteListCtrlPtr->SetItem(longSelected, 0, txtWebsite->GetValue());
119 if (chkUsePref->IsChecked()){
121 WebsiteListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
125 WebsiteListCtrlPtr->SetItem(longSelected, 1, wxT(""));
134 void frmContactEditorWebsites::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 Website"));
146 } else if (EditMode == TRUE){
149 btnAction->SetLabel(_("Modify"));
150 this->SetTitle(_("Modify Website"));
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 = WebsiteListPtr->find(WebsiteListIndex);
160 if (striter->first == WebsiteListIndex){
162 strValue = striter->second;
166 txtWebsite->SetValue(strValue);
170 // Get the website priority.
172 intiter = WebsiteListPrefPtr->find(WebsiteListIndex);
174 if (intiter->first == WebsiteListIndex && intiter->second > 0){
176 sliPriority->SetValue(intiter->second);
177 sliPriority->Enable();
178 chkUsePref->SetValue(TRUE);
184 EditSectionType = SectType;
188 void frmContactEditorWebsites::CloseWindow( wxCommandEvent& event )
193 void frmContactEditorWebsites::SetupPointers(std::map<int, wxString> *WebsiteList,
194 std::map<int, wxString> *WebsiteListAltID,
195 std::map<int, wxString> *WebsiteListPID,
196 std::map<int, wxString> *WebsiteListType,
197 std::map<int, wxString> *WebsiteListTokens,
198 std::map<int, wxString> *WebsiteListMediatype,
199 std::map<int, int> *WebsiteListPref,
200 wxListCtrl *WebsiteListCtrl,
204 WebsiteListPtr = WebsiteList;
205 WebsiteListAltIDPtr = WebsiteListAltID;
206 WebsiteListPIDPtr = WebsiteListPID;
207 WebsiteListTypePtr = WebsiteListType;
208 WebsiteListTokensPtr = WebsiteListTokens;
209 WebsiteListMediatypePtr = WebsiteListMediatype;
210 WebsiteListPrefPtr = WebsiteListPref;
211 WebsiteListCtrlPtr = WebsiteListCtrl;
212 WebsiteListIndex = WebsiteIndex;