From 17855e4229758abd623d7f2236b389bfff0fbbff Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Wed, 24 Feb 2016 16:05:01 +0000 Subject: [PATCH] Fixed issue where remove search setting appears after searching. This is appears after searching with one search setting where the remove search setting button appears. The user can remove this setting, however would not have been able to add a setting until the user had hit the Reset button. This has been fixed and now checks if only one setting is being used after searching. --- source/search/frmSearch.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/source/search/frmSearch.cpp b/source/search/frmSearch.cpp index 23b32b6..56ae1ed 100644 --- a/source/search/frmSearch.cpp +++ b/source/search/frmSearch.cpp @@ -26,6 +26,8 @@ #include +#define SEARCHSETTINGS_MAX 15 + DEFINE_EVENT_TYPE(SE_ADDSEARCHSETTING); DEFINE_EVENT_TYPE(SE_REMOVESEARCHSETTING); DEFINE_EVENT_TYPE(SE_RELOADACCOUNTS); @@ -261,13 +263,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){ @@ -321,7 +323,7 @@ void frmSearch::RemoveSearchSetting( wxCommandEvent& event ) //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){ @@ -379,6 +381,19 @@ 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 (SearchFrames.size() == 1){ + + XABSearchPanel *XABSPPtr = static_cast(SearchFrames.begin()->second); + XABSPPtr->EnableButtons(TRUE, FALSE); + return; + + } + + // More than one control, so process them. + for (std::map::iterator siter = SearchFrames.begin(); siter != SearchFrames.end(); siter++){ -- 2.39.5