Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed references to the boost library in remaining source and header files.
[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         // Set if the editor is adding or editing an address.
33         // FALSE = Add
34         // TRUE = Edit
35         
36         if (EditMode == FALSE){
37         
38                 EditorMode = FALSE;
39                 btnAction->SetLabel(_("Add"));
40                 this->SetTitle(_("Add Vendor Namespace"));
41         
42         } else if (EditMode == TRUE){
43         
44                 EditorMode = TRUE;
45                 btnAction->SetLabel(_("Modify"));
46                 this->SetTitle(_("Add Vendor Namespace"));
47                 
48                 std::map<int,int>::iterator intiter;
49                 std::map<int,wxString>::iterator striter;               
50                 wxString strValue;
51                 
52                 // Get the vendor PEN.
53                 
54                 striter = VendorListPENPtr->find(VendorListIndex);
55                  
56                 if (striter->first == VendorListIndex){
57                 
58                         strValue = striter->second;
59                 
60                 }
61                 
62                 txtPEN->SetValue(strValue);
63                 
64                 strValue.Clear();
65                 
66                 // Get the vendor element.
68                 striter = VendorListElementPtr->find(VendorListIndex);
69                  
70                 if (striter->first == VendorListIndex){
71                 
72                         strValue = striter->second;
73                 
74                 }
75                 
76                 txtElement->SetValue(strValue);
77                 
78                 strValue.Clear();
79                 
80                 // Get the vendor value.
81                 
82                 striter = VendorListPtr->find(VendorListIndex);
83                  
84                 if (striter->first == VendorListIndex){
85                 
86                         strValue = striter->second;
87                 
88                 }
90                 txtValue->SetValue(strValue);
91                 
92                 strValue.Clear();               
93                 
94         }
95         
96 }
98 void frmContactEditorVendor::ProcessAction( wxCommandEvent& event )
99 {
100         
101         if (EditorMode == FALSE){
103                 wxString strValue;
104                 wxString strVNDID;
105                 wxListItem coldata;     
106                 long ListCtrlIndex;
107                 
108                 coldata.SetId(VendorListIndex);
109                 coldata.SetData(VendorListIndex);
110                 ListCtrlIndex = VendorListCtrlPtr->InsertItem(coldata);         
111                 
112                 // Get Vendor PEN.
113                 
114                 strValue = txtPEN->GetValue();
115                 VendorListPENPtr->insert(std::make_pair(VendorListIndex, strValue));
116                 
117                 // Get Vendor Element.
118                 
119                 strValue = txtElement->GetValue();
120                 VendorListElementPtr->insert(std::make_pair(VendorListIndex, strValue));
121                 
122                 // Get Vendor Value.
123                 
124                 strValue = txtValue->GetValue();
125                 VendorListPtr->insert(std::make_pair(VendorListIndex, strValue));
126                 
127                 // Update form.
128                 
129                 strVNDID = txtPEN->GetValue() + wxT("-") + txtElement->GetValue();
130                 
131                 VendorListCtrlPtr->SetItem(ListCtrlIndex, 0, strVNDID);
132                 
133                 this->Close();
134                 
135         } else if (EditorMode == TRUE){
137                 long longSelected = -1; 
138                 wxString strValue;
139                 wxString strVNDID;
140                 
141                 longSelected = VendorListCtrlPtr->GetNextItem(longSelected, 
142                         wxLIST_NEXT_ALL,
143                         wxLIST_STATE_SELECTED);
144                         
145                 if (longSelected == -1){
146                         return;
147                 }
148                 
149                 // Update Vendor PEN.
150                 
151                 VendorListPENPtr->erase(VendorListIndex);
152                 strValue = txtPEN->GetValue();
153                 VendorListPENPtr->insert(std::make_pair(VendorListIndex, strValue));            
154                 
155                 // Update Vendor Element.
156                 
157                 VendorListElementPtr->erase(VendorListIndex);
158                 strValue = txtValue->GetValue();
159                 VendorListElementPtr->insert(std::make_pair(VendorListIndex, strValue));                
160                 
161                 // Update Vendor Value.
162                 
163                 VendorListPtr->erase(VendorListIndex);
164                 strValue = txtValue->GetValue();
165                 VendorListPtr->insert(std::make_pair(VendorListIndex, strValue));
166                 
167                 // Update form.
169                 strVNDID = txtPEN->GetValue() + wxT("-") + txtElement->GetValue();              
170                 VendorListCtrlPtr->SetItem(longSelected, 0, strVNDID);
171                 
172                 this->Close();  
173         
174         }
177 void frmContactEditorVendor::SetupPointers( std::map<int, wxString> *VendorList,
178                         std::map<int, wxString> *VendorListPEN,
179                         std::map<int, wxString> *VendorListElement,
180                         wxListCtrl *VendorListCtrl,
181                         int VendorIndex )
184         VendorListPtr = VendorList;
185         VendorListPENPtr = VendorListPEN;
186         VendorListElementPtr = VendorListElement;
187         VendorListCtrlPtr = VendorListCtrl;
188         VendorListIndex = VendorIndex;
189         
192 void frmContactEditorVendor::CloseWindow( wxCommandEvent& event )
194         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