X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fsearch%2FfrmSearch.cpp;h=46d7d1e07dfcb7ebe02ced11e868cd6dd78c4f69;hb=bdeb1b14f7c371af5ffad2aa06a1f83ad7c53fa9;hp=b4b8104b1d04ed1eae4bc1efc96712503cfebeda;hpb=4ea07d6964c0f73c858e83513e14a28000054256;p=xestiaab%2F.git diff --git a/source/search/frmSearch.cpp b/source/search/frmSearch.cpp index b4b8104..46d7d1e 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); @@ -133,6 +135,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){ @@ -236,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){ @@ -296,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){ @@ -354,6 +381,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++){