1 // frmSearchAccounts.cpp - frmSearchAccounts form.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
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.
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.
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 "frmSearchAccounts.h"
20 #include "../frmMain.h"
22 frmSearchAccounts::frmSearchAccounts( wxWindow* parent )
24 frmSearchAccountsADT( parent )
29 frmSearchAccounts::~frmSearchAccounts(){
33 void frmSearchAccounts::LoadSearchAccounts(std::map<wxString, bool> *SearchAccounts,
34 std::map<wxString, wxString> *SearchAccountsList)
37 // Load the list of accounts to the accounts list in the window.
39 SAPtr = SearchAccounts;
40 SALPtr = SearchAccountsList;
41 std::map<wxString, wxString>::iterator SALiter;
44 // Load the search accounts into the Checklist.
46 wxArrayString AccList;
48 for (std::map<wxString, bool>::iterator iter = SAPtr->begin();
49 iter != SAPtr->end(); ++iter){
51 SALiter = SALPtr->find(iter->first);
53 AccList.Add(SALiter->second, 1);
57 chlAccounts->Append(AccList);
58 //chlAccounts->SetSelection(wxNOT_FOUND);
60 // Check if each account is selected.
62 for (int i = 0; i < chlAccounts->GetCount(); i++){
64 AccDir = chlAccounts->GetString(i);
66 for (std::map<wxString, bool>::iterator iter = SAPtr->begin();
67 iter != SAPtr->end(); ++iter){
69 SALiter = SALPtr->find(iter->first);
71 if (AccDir == SALiter->second){
73 chlAccounts->Check(i, iter->second);
83 void frmSearchAccounts::UpdateSelectedAccounts( wxCommandEvent& event )
86 // Process each of the items in the Checklist box.
87 // Compare each with the ones in the std::map
88 // and adjust the bool value accordingly.
91 std::map<wxString, wxString>::iterator SALiter;
93 for (int i = 0; i < chlAccounts->GetCount(); i++){
95 AccDir = chlAccounts->GetString(i);
97 for (std::map<wxString, bool>::iterator iter = SAPtr->begin();
98 iter != SAPtr->end(); ++iter){
100 SALiter = SALPtr->find(iter->first);
102 if (AccDir == SALiter->second){
104 iter->second = chlAccounts->IsChecked(i);
116 void frmSearchAccounts::CloseWindow( wxCommandEvent& event )
119 // Close this window.