Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial import of code already done for Xestia Address Book
[xestiaab/.git] / source / contacteditor / frmContactEditorVendor.cpp
1 #include "frmContactEditorVendor.h"
2 #include <wx/tokenzr.h>
3 #include "../common/textprocessing.h"
5 frmContactEditorVendor::frmContactEditorVendor( wxWindow* parent )
6 :
7 frmContactEditorVendorADT( parent )
8 {
10 }
12 void frmContactEditorVendor::SetEditorMode(bool EditMode)
13 {
14         // Set if the editor is adding or editing an address.
15         // FALSE = Add
16         // TRUE = Edit
17         
18         if (EditMode == FALSE){
19         
20                 EditorMode = FALSE;
21                 btnAction->SetLabel(_("Add"));
22                 this->SetTitle(_("Add Vendor Namespace"));
23         
24         } else if (EditMode == TRUE){
25         
26                 EditorMode = TRUE;
27                 btnAction->SetLabel(_("Modify"));
28                 this->SetTitle(_("Add Vendor Namespace"));
29                 
30                 std::map<int,int>::iterator intiter;
31                 std::map<int,wxString>::iterator striter;               
32                 wxString strValue;
33                 
34                 // Get the vendor PEN.
35                 
36                 striter = VendorListPENPtr->find(VendorListIndex);
37                  
38                 if (striter->first == VendorListIndex){
39                 
40                         strValue = striter->second;
41                 
42                 }
43                 
44                 txtPEN->SetValue(strValue);
45                 
46                 strValue.Clear();
47                 
48                 // Get the vendor element.
50                 striter = VendorListElementPtr->find(VendorListIndex);
51                  
52                 if (striter->first == VendorListIndex){
53                 
54                         strValue = striter->second;
55                 
56                 }
57                 
58                 txtElement->SetValue(strValue);
59                 
60                 strValue.Clear();
61                 
62                 // Get the vendor value.
63                 
64                 striter = VendorListPtr->find(VendorListIndex);
65                  
66                 if (striter->first == VendorListIndex){
67                 
68                         strValue = striter->second;
69                 
70                 }
72                 txtValue->SetValue(strValue);
73                 
74                 strValue.Clear();               
75                 
76         }
77         
78 }
80 void frmContactEditorVendor::ProcessAction( wxCommandEvent& event )
81 {
82         
83         if (EditorMode == FALSE){
85                 wxString strValue;
86                 wxString strVNDID;
87                 wxListItem coldata;     
88                 long ListCtrlIndex;
89                 
90                 coldata.SetId(VendorListIndex);
91                 coldata.SetData(VendorListIndex);
92                 ListCtrlIndex = VendorListCtrlPtr->InsertItem(coldata);         
93                 
94                 // Get Vendor PEN.
95                 
96                 strValue = txtPEN->GetValue();
97                 VendorListPENPtr->insert(std::make_pair(VendorListIndex, strValue));
98                 
99                 // Get Vendor Element.
100                 
101                 strValue = txtElement->GetValue();
102                 VendorListElementPtr->insert(std::make_pair(VendorListIndex, strValue));
103                 
104                 // Get Vendor Value.
105                 
106                 strValue = txtValue->GetValue();
107                 VendorListPtr->insert(std::make_pair(VendorListIndex, strValue));
108                 
109                 // Update form.
110                 
111                 strVNDID = txtPEN->GetValue() + wxT("-") + txtElement->GetValue();
112                 
113                 VendorListCtrlPtr->SetItem(ListCtrlIndex, 0, strVNDID);
114                 
115                 this->Close();
116                 
117         } else if (EditorMode == TRUE){
119                 long longSelected = -1; 
120                 wxString strValue;
121                 wxString strVNDID;
122                 
123                 longSelected = VendorListCtrlPtr->GetNextItem(longSelected, 
124                         wxLIST_NEXT_ALL,
125                         wxLIST_STATE_SELECTED);
126                         
127                 if (longSelected == -1){
128                         return;
129                 }
130                 
131                 // Update Vendor PEN.
132                 
133                 VendorListPENPtr->erase(VendorListIndex);
134                 strValue = txtPEN->GetValue();
135                 VendorListPENPtr->insert(std::make_pair(VendorListIndex, strValue));            
136                 
137                 // Update Vendor Element.
138                 
139                 VendorListElementPtr->erase(VendorListIndex);
140                 strValue = txtValue->GetValue();
141                 VendorListElementPtr->insert(std::make_pair(VendorListIndex, strValue));                
142                 
143                 // Update Vendor Value.
144                 
145                 VendorListPtr->erase(VendorListIndex);
146                 strValue = txtValue->GetValue();
147                 VendorListPtr->insert(std::make_pair(VendorListIndex, strValue));
148                 
149                 // Update form.
151                 strVNDID = txtPEN->GetValue() + wxT("-") + txtElement->GetValue();              
152                 VendorListCtrlPtr->SetItem(longSelected, 0, strVNDID);
153                 
154                 this->Close();  
155         
156         }
159 void frmContactEditorVendor::SetupPointers( std::map<int, wxString> *VendorList,
160                         std::map<int, wxString> *VendorListPEN,
161                         std::map<int, wxString> *VendorListElement,
162                         wxListCtrl *VendorListCtrl,
163                         int VendorIndex )
166         VendorListPtr = VendorList;
167         VendorListPENPtr = VendorListPEN;
168         VendorListElementPtr = VendorListElement;
169         VendorListCtrlPtr = VendorListCtrl;
170         VendorListIndex = VendorIndex;
171         
174 void frmContactEditorVendor::CloseWindow( wxCommandEvent& event )
176         this->Close();
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