X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fsearch%2FfrmSearch.cpp;h=8d8530c5312f153a94de7f032c01a745d2d71b5c;hb=d6023ac2bba9572d1bca7da3d5960f6c07082624;hp=b4b8104b1d04ed1eae4bc1efc96712503cfebeda;hpb=4ea07d6964c0f73c858e83513e14a28000054256;p=xestiaab%2F.git
diff --git a/source/search/frmSearch.cpp b/source/search/frmSearch.cpp
index b4b8104..8d8530c 100644
--- a/source/search/frmSearch.cpp
+++ b/source/search/frmSearch.cpp
@@ -1,6 +1,6 @@
// frmSearch.cpp - Search form.
//
-// (c) 2012-2015 Xestia Software Development.
+// (c) 2012-2017 Xestia Software Development.
//
// This file is part of Xestia Address Book.
//
@@ -17,14 +17,9 @@
// with Xestia Address Book. If not, see
#include "frmSearch.h"
-#include "../frmMain.h"
-#include "../frmContact.h"
-#include "frmSearchAccounts.h"
-#include "../common/preferences.h"
-#include "../common/dirs.h"
-#include "../vcard/vcard.h"
-#include
+
+#define SEARCHSETTINGS_MAX 15
DEFINE_EVENT_TYPE(SE_ADDSEARCHSETTING);
DEFINE_EVENT_TYPE(SE_REMOVESEARCHSETTING);
@@ -57,6 +52,17 @@ frmSearch::frmSearch( wxWindow* parent )
frmSearchADT( parent )
{
+ // Setup the application icon.
+
+ wxMemoryInputStream istream(bigimgs_searchicon_png, sizeof(bigimgs_searchicon_png));
+ wxImage bigimgs_searchiconi(istream, wxBITMAP_TYPE_PNG);
+ wxBitmap searchiconbmp(bigimgs_searchiconi, -1);
+ wxIcon searchicon;
+ searchicon.CopyFromBitmap(searchiconbmp);
+ this->SetIcon(searchicon);
+
+ // Setup the search window.
+
XABSearchPanel *InitPanel = new XABSearchPanel( tabSearch );
InitPanel->EnableButtons(TRUE, FALSE);
InitPanel->SetupPointers(this);
@@ -133,6 +139,31 @@ void frmSearch::SelectAccounts( wxCommandEvent& event )
void frmSearch::SearchContacts( wxCommandEvent& event )
{
+ // Check if any accounts has been selected.
+
+ bool AccountsFound = false;
+
+ for (std::map::iterator saiter = SearchAccounts.begin();
+ saiter != SearchAccounts.end(); saiter++){
+
+ if (saiter->second == true){
+
+ AccountsFound = true;
+ break;
+
+ }
+
+ }
+
+ if (AccountsFound == false){
+
+ wxMessageBox(_("No accounts have been selected to search contacts for."),
+ _("No accounts selected"),
+ wxOK|wxICON_ERROR);
+ return;
+
+ }
+
// Change the button to stop.
if (StopMode == FALSE){
@@ -203,6 +234,15 @@ void frmSearch::ResetContacts( wxCommandEvent& event )
}
+ // Clear the status bar.
+
+ wxCommandEvent statusResetEvent (SE_SBUPDATE);
+
+ wxString *statusReset = new wxString(wxT(""));
+
+ statusResetEvent.SetClientData(statusReset);
+ wxPostEvent(this, statusResetEvent);
+
// Add a search settings with the default things.
ScrollGen = 0;
@@ -228,7 +268,6 @@ void frmSearch::AddSearchSetting( wxCommandEvent& event )
NewPanel->SetupPointers(this);
NewPanel->SetupInteger(ScrollGen);
szrSearch->Add(NewPanel, 1, wxEXPAND|wxGROW, 5);
- //szrSearch->Fit(tabSearch);
szrSearch->FitInside(tabSearch);
szrSearch->Layout();
szrSearch->RecalcSizes();
@@ -236,13 +275,13 @@ void frmSearch::AddSearchSetting( wxCommandEvent& event )
SearchFrames.insert(std::make_pair(ScrollGen, NewPanel));
ScrollGen++;
- // Check if number of search settings is 15 (or over).
+ // Check if number of search settings is SEARCHSETTINGS_MAX (or over).
// If it is, disable the option of adding extra settings
// for all frames until one is removed.
XABSearchPanel *XABSPPtr;
- if (SearchFrames.size() >= 15){
+ if (SearchFrames.size() >= SEARCHSETTINGS_MAX){
for (std::map::iterator iter = SearchFrames.begin();
iter != SearchFrames.end(); ++iter){
@@ -275,13 +314,13 @@ void frmSearch::AddSearchSetting( wxCommandEvent& event )
void frmSearch::RemoveSearchSetting( wxCommandEvent& event )
{
+ // Remove a search setting frame from the list.
+
// Get the integer from the event.
std::map::iterator iter;
iter = SearchFrames.find(event.GetInt());
- // Remove a search setting frame from the list.
-
XABSearchPanel *XABSPPtr;
XABSPPtr = static_cast(iter->second);
@@ -294,9 +333,7 @@ void frmSearch::RemoveSearchSetting( wxCommandEvent& event )
delete XABSPPtr;
XABSPPtr = NULL;
- //szrSearch->Fit(tabSearch);
-
- if (SearchFrames.size() < 15 && SearchFrames.size() > 1){
+ if (SearchFrames.size() < SEARCHSETTINGS_MAX && SearchFrames.size() > 1){
for (std::map::iterator iter = SearchFrames.begin();
iter != SearchFrames.end(); ++iter){
@@ -334,7 +371,9 @@ void frmSearch::ReloadAccountList( wxCommandEvent& event ){
}
void frmSearch::SearchBarUpdate( wxCommandEvent& event ){
-
+
+ // Update the status bar.
+
wxString *SBData = (wxString*)event.GetClientData();
stbBottom->SetStatusText(*SBData, 0);
@@ -346,6 +385,9 @@ void frmSearch::SearchBarUpdate( wxCommandEvent& event ){
void frmSearch::SearchFinished( wxCommandEvent& event ){
+ // Reset the search button and unlock the search
+ // panel buttons.
+
StopMode = FALSE;
btnSearch->SetLabel(_("Search"));
DisableAllSearchSettings(FALSE);
@@ -354,6 +396,35 @@ void frmSearch::SearchFinished( wxCommandEvent& event ){
void frmSearch::DisableAllSearchSettings(bool Enable){
+ // Check if there is only one search value. If there is, only enable
+ // the add button if this is the case.
+
+ if (SearchFrames.size() == 1){
+
+ XABSearchPanel *XABSPPtr = static_cast(SearchFrames.begin()->second);
+ XABSPPtr->EnableButtons(TRUE, FALSE);
+ return;
+
+ }
+
+ // Check if there is SEARCHSETTINGS_MAX controls set or more, only
+ // enable the remove button if this is the case.
+
+ if (SearchFrames.size() >= SEARCHSETTINGS_MAX){
+
+ for (std::map::iterator siter = SearchFrames.begin();
+ siter != SearchFrames.end(); siter++){
+
+ XABSearchPanel *XABSPPtr = static_cast(SearchFrames.begin()->second);
+ XABSPPtr->EnableButtons(FALSE, TRUE);
+
+ }
+ return;
+
+ }
+
+ // More than one control, so process them.
+
for (std::map::iterator siter = SearchFrames.begin();
siter != SearchFrames.end(); siter++){
@@ -403,20 +474,24 @@ void frmSearch::CloseWindow( wxCloseEvent& event ){
// Close window.
- WindowData *WData = new WindowData;
+ if (SearchMode == false){
+
+ WindowData *WData = new WindowData;
- WData->DataType = 2;
- WData->WindowPointer = this;
- WData->WindowID = SearchUID;
+ WData->DataType = 2;
+ WData->WindowPointer = this;
+ WData->WindowID = SearchUID;
- wxCommandEvent delevent(WINDOW_CLOSE);
- delevent.SetClientData(WData);
- wxPostEvent(GetParent(), delevent);
+ wxCommandEvent delevent(WINDOW_CLOSE);
+ delevent.SetClientData(WData);
+ wxPostEvent(GetParent(), delevent);
- wxCommandEvent rs(CE_REMOVESEARCH);
- wxPostEvent(this, rs);
+ wxCommandEvent rs(CE_REMOVESEARCH);
+ wxPostEvent(this, rs);
- WData = NULL;
+ WData = NULL;
+
+ }
this->Destroy();
@@ -424,18 +499,24 @@ void frmSearch::CloseWindow( wxCloseEvent& event ){
void frmSearch::CloseWindow( wxCommandEvent& event ){
+ // Close this window.
+
this->Close();
}
void frmSearch::SetUID(int UID){
+ // Set the UID of the search window.
+
SearchUID = UID;
}
void frmSearch::SetSearchMode(bool SearchModeIn){
+ // Set the search mode of the window.
+
SearchMode = SearchModeIn;
if (SearchMode == TRUE){