1 // frmSearch-contact.cpp - Search contact subroutines.
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 "frmSearch.h"
20 #include "../frmMain.h"
21 #include "../frmContact.h"
23 void frmSearch::OpenContact( wxCommandEvent& event ){
25 // Check if a contact has been selected.
27 long intSelected = -1;
28 long intContactSeekNum = -1;
30 intSelected = lstResults->GetNextItem(intSelected,
32 wxLIST_STATE_SELECTED);
34 if (intSelected == -1){
38 intContactSeekNum = lstResults->GetItemData(intSelected);
40 if (SearchMode == TRUE){
44 Person.LoadFile(SearchResultFilename[intContactSeekNum]);
46 wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
47 wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
48 wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
50 contacticon.CopyFromBitmap(contacticonbmp);
52 frmContact *Contact = new frmContact( this );
54 Contact->SetupPointers(&SearchModeMemoryFSPtr);
55 Contact->SetupContactData(&Person);
57 Contact->SetIcon(contacticon);
62 UCNotif *uc = new UCNotif;
64 uc->ContactAccount = SearchResultAccount[intContactSeekNum];
65 uc->ContactFilename = SearchResultFilename[intContactSeekNum];
67 wxCommandEvent oc(CE_OPENCONTACT);
69 wxPostEvent(this->GetParent(), oc);
75 void frmSearch::EditContact( wxCommandEvent& event ){
77 // Check if a contact has been selected.
79 long intSelected = -1;
80 long intContactSeekNum = -1;
82 intSelected = lstResults->GetNextItem(intSelected,
84 wxLIST_STATE_SELECTED);
86 if (intSelected == -1){
90 intContactSeekNum = lstResults->GetItemData(intSelected);
92 UCNotif *uc = new UCNotif;
94 uc->ContactAccount = SearchResultAccount[intContactSeekNum];
95 uc->ContactFilename = SearchResultFilename[intContactSeekNum];
97 wxCommandEvent ec(CE_EDITCONTACT);
100 wxPostEvent(this->GetParent(), ec);
104 void frmSearch::RevealContact( wxCommandEvent& event ){
106 // Check if a contact has been selected.
108 long intSelected = -1;
109 long intContactSeekNum = -1;
111 intSelected = lstResults->GetNextItem(intSelected,
113 wxLIST_STATE_SELECTED);
115 if (intSelected == -1){
119 intContactSeekNum = lstResults->GetItemData(intSelected);
121 UCNotif *uc = new UCNotif;
123 uc->ContactAccount = SearchResultAccount[intContactSeekNum];
124 uc->ContactFilename = SearchResultFilename[intContactSeekNum];
126 wxCommandEvent rc(CE_REVEALCONTACT);
127 rc.SetClientData(uc);
129 wxPostEvent(this->GetParent(), rc);
133 void frmSearch::ShowContactMenu( wxMouseEvent& event ){
135 // Show the contact menu.
137 ContactMenu->SetupPointersSearch(this, lstResults, SearchMode);
139 PopupMenu(ContactMenu->MenuPointer(), wxDefaultPosition);