Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Version 0.18 release
[xestiaab/.git] / source / contacteditor / frmContactEditorVendor.cpp
1 // frmContactEditorVendor.cpp - frmContactEditorVendor 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 "frmContactEditorVendor.h"
20 #include <wx/tokenzr.h>
21 #include "../common/textprocessing.h"
23 frmContactEditorVendor::frmContactEditorVendor( wxWindow* parent )
24 :
25 frmContactEditorVendorADT( parent )
26 {
28 }
30 void frmContactEditorVendor::SetEditorMode(bool EditMode)
31 {
32         
33         // Set if the editor is adding or editing an address.
34         // FALSE = Add
35         // TRUE = Edit
36         
37         if (EditMode == FALSE){
38         
39                 EditorMode = FALSE;
40                 btnAction->SetLabel(_("Add"));
41                 this->SetTitle(_("Add Vendor Namespace"));
42         
43         } else if (EditMode == TRUE){
44         
45                 EditorMode = TRUE;
46                 btnAction->SetLabel(_("Modify"));
47                 this->SetTitle(_("Add Vendor Namespace"));
48                 
49                 std::map<int,int>::iterator intiter;
50                 std::map<int,wxString>::iterator striter;               
51                 wxString strValue;
52                 
53                 // Get the vendor PEN.
54                 
55                 striter = VendorListPENPtr->find(VendorListIndex);
56                  
57                 if (striter->first == VendorListIndex){
58                 
59                         strValue = striter->second;
60                 
61                 }
62                 
63                 txtPEN->SetValue(strValue);
64                 
65                 strValue.Clear();
66                 
67                 // Get the vendor element.
69                 striter = VendorListElementPtr->find(VendorListIndex);
70                  
71                 if (striter->first == VendorListIndex &&
72                         striter != VendorListElementPtr->end()){
73                 
74                         strValue = striter->second;
75                 
76                 }
77                 
78                 txtElement->SetValue(strValue);
79                 
80                 strValue.Clear();
81                 
82                 // Get the vendor value.
83                 
84                 striter = VendorListPtr->find(VendorListIndex);
85                  
86                 if (striter->first == VendorListIndex &&
87                         striter != VendorListPtr->end()){
88                 
89                         strValue = striter->second;
90                 
91                 }
93                 txtValue->SetValue(strValue);
94                 
95                 strValue.Clear();               
96                 
97         }
98         
99 }
101 void frmContactEditorVendor::ProcessAction( wxCommandEvent& event )
103         
104         // Process action.
105         
106         if (EditorMode == FALSE){
108                 wxString strValue;
109                 wxString strVNDID;
110                 wxListItem coldata;     
111                 long ListCtrlIndex;
112                 
113                 coldata.SetId(VendorListIndex);
114                 coldata.SetData(VendorListIndex);
115                 ListCtrlIndex = VendorListCtrlPtr->InsertItem(coldata);         
116                 
117                 // Get Vendor PEN.
118                 
119                 strValue = txtPEN->GetValue();
120                 VendorListPENPtr->insert(std::make_pair(VendorListIndex, strValue));
121                 
122                 // Get Vendor Element.
123                 
124                 strValue = txtElement->GetValue();
125                 VendorListElementPtr->insert(std::make_pair(VendorListIndex, strValue));
126                 
127                 // Get Vendor Value.
128                 
129                 strValue = txtValue->GetValue();
130                 VendorListPtr->insert(std::make_pair(VendorListIndex, strValue));
131                 
132                 // Update form.
133                 
134                 strVNDID = txtPEN->GetValue() + wxT("-") + txtElement->GetValue();
135                 
136                 VendorListCtrlPtr->SetItem(ListCtrlIndex, 0, strVNDID);
137                 
138                 this->Close();
139                 
140         } else if (EditorMode == TRUE){
142                 long longSelected = -1; 
143                 wxString strValue;
144                 wxString strVNDID;
145                 
146                 longSelected = VendorListCtrlPtr->GetNextItem(longSelected, 
147                         wxLIST_NEXT_ALL,
148                         wxLIST_STATE_SELECTED);
149                         
150                 if (longSelected == -1){
151                         return;
152                 }
153                 
154                 // Update Vendor PEN.
155                 
156                 VendorListPENPtr->erase(VendorListIndex);
157                 strValue = txtPEN->GetValue();
158                 VendorListPENPtr->insert(std::make_pair(VendorListIndex, strValue));            
159                 
160                 // Update Vendor Element.
161                 
162                 VendorListElementPtr->erase(VendorListIndex);
163                 strValue = txtValue->GetValue();
164                 VendorListElementPtr->insert(std::make_pair(VendorListIndex, strValue));                
165                 
166                 // Update Vendor Value.
167                 
168                 VendorListPtr->erase(VendorListIndex);
169                 strValue = txtValue->GetValue();
170                 VendorListPtr->insert(std::make_pair(VendorListIndex, strValue));
171                 
172                 // Update form.
174                 strVNDID = txtPEN->GetValue() + wxT("-") + txtElement->GetValue();              
175                 VendorListCtrlPtr->SetItem(longSelected, 0, strVNDID);
176                 
177                 this->Close();  
178         
179         }
182 void frmContactEditorVendor::SetupPointers( std::map<int, wxString> *VendorList,
183                         std::map<int, wxString> *VendorListPEN,
184                         std::map<int, wxString> *VendorListElement,
185                         wxListCtrl *VendorListCtrl,
186                         int VendorIndex )
188         // Setup the pointers.
189         
190         VendorListPtr = VendorList;
191         VendorListPENPtr = VendorListPEN;
192         VendorListElementPtr = VendorListElement;
193         VendorListCtrlPtr = VendorListCtrl;
194         VendorListIndex = VendorIndex;
195         
198 void frmContactEditorVendor::CloseWindow( wxCommandEvent& event )
200         
201         // Close the window.
202         
203         this->Close();
204         
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