Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added support for saving REV, XML, CLIENTPIDMAP and SOURCE properties.
[xestiaab/.git] / source / contacteditor / frmContactEditorXToken.cpp
1 // frmContactEditorXToken.cpp - frmContactEditorXToken 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 "frmContactEditorXToken.h"
20 #include <wx/tokenzr.h>
21 #include "../common/textprocessing.h"
23 frmContactEditorXToken::frmContactEditorXToken( wxWindow* parent )
24 :
25 frmContactEditorXTokenADT( parent )
26 {
28 }
30 void frmContactEditorXToken::ProcessAction( wxCommandEvent& event )
31 {
33         long ListCtrlIndex;
34         
35         if (EditorMode == FALSE){
37                 wxString strValue;
38                 wxListItem coldata;             
39                 
40                 coldata.SetId(XTokenListIndex);
41                 coldata.SetData(XTokenListIndex);
42                 ListCtrlIndex = XTokenListCtrlPtr->InsertItem(coldata);         
43                 
44                 // Get the X-Token value.
45                 
46                 strValue = txtValue->GetValue();
47                 XTokenListPtr->insert(std::make_pair(XTokenListIndex, strValue));               
48                 
49                 // Get the X-Token name.
50                 
51                 strValue = txtTokenName->GetValue();
52                 XTokenListTokensPtr->insert(std::make_pair(XTokenListIndex, strValue));
53                 
54                 // Update form.
55                 
56                 XTokenListCtrlPtr->SetItem(ListCtrlIndex, 0, strValue);
57                 
58                 this->Close();
59                 
60         } else if (EditorMode == TRUE){
62                 long longSelected = -1; 
63                 wxString strValue;
64                 
65                 longSelected = XTokenListCtrlPtr->GetNextItem(longSelected, 
66                         wxLIST_NEXT_ALL,
67                         wxLIST_STATE_SELECTED);
68                         
69                 if (longSelected == -1){
70                         return;
71                 }
72                 
73                 // Update X-Token value.
74                 
75                 XTokenListPtr->erase(XTokenListIndex);
76                 strValue = txtValue->GetValue();
77                 XTokenListPtr->insert(std::make_pair(XTokenListIndex, strValue));               
78                 
79                 // Update X-Token name.
80                 
81                 XTokenListTokensPtr->erase(XTokenListIndex);
82                 strValue = txtTokenName->GetValue();
83                 XTokenListTokensPtr->insert(std::make_pair(XTokenListIndex, strValue));
84                 
85                 // Update form.
87                 XTokenListCtrlPtr->SetItem(longSelected, 0,strValue);
88                 
89                 this->Close();
90         
91         }
92         
93 }
95 void frmContactEditorXToken::SetEditorMode(bool EditMode)
96 {
97         // Set if the editor is adding or editing an address.
98         // FALSE = Add
99         // TRUE = Edit
100         
101         if (EditMode == FALSE){
102         
103                 EditorMode = FALSE;
104                 btnAction->SetLabel(_("Add"));
105                 this->SetTitle(_("Add X-Token"));
106         
107         } else if (EditMode == TRUE){
108         
109                 EditorMode = TRUE;
110                 btnAction->SetLabel(_("Modify"));
111                 this->SetTitle(_("Add X-Token"));
112                 
113                 std::map<int,int>::iterator intiter;
114                 std::map<int,wxString>::iterator striter;               
115                 wxString strValue;
116                 
117                 // Get the X-Token name.
118                 
119                 striter = XTokenListTokensPtr->find(XTokenListIndex);
120                  
121                 if (striter->first == XTokenListIndex){
122                 
123                         strValue = striter->second;
124                 
125                 }
126                 
127                 txtTokenName->SetValue(strValue);
128                 
129                 strValue.Clear();
130                 
131                 // Get the X-Token value.
133                 striter = XTokenListPtr->find(XTokenListIndex);
134                  
135                 if (striter->first == XTokenListIndex){
136                 
137                         strValue = striter->second;
138                 
139                 }
140                 
141                 txtValue->SetValue(strValue);
142                 
143                 strValue.Clear();               
144                 
145         }
146         
149 void frmContactEditorXToken::SetupPointers( std::map<int, wxString> *XTokenList,
150                         std::map<int, wxString> *XTokenListTokens,
151                         wxListCtrl *XTokenListCtrl,
152                         int XTokenIndex )
155         XTokenListPtr = XTokenList;
156         XTokenListTokensPtr = XTokenListTokens;
157         XTokenListCtrlPtr = XTokenListCtrl;
158         XTokenListIndex = XTokenIndex;
162 void frmContactEditorXToken::CloseWindow( wxCommandEvent& event )
164         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