use predefined contants in Search Engine instead of numbers

This commit is contained in:
Andrzej Rybczak
2010-01-22 19:32:37 +01:00
parent a27332a825
commit 794fbbab3d

View File

@@ -112,12 +112,12 @@ std::basic_string<my_char_t> SearchEngine::Title()
void SearchEngine::EnterPressed() void SearchEngine::EnterPressed()
{ {
size_t option = w->Choice(); size_t option = w->Choice();
if (option > 10 && option < SearchButton) if (option > ConstraintsNumber && option < SearchButton)
w->Current().first->Clear(); w->Current().first->Clear();
if (option < 15) if (option < SearchButton)
LockStatusbar(); LockStatusbar();
if (option < 10) if (option < ConstraintsNumber)
{ {
Statusbar() << fmtBold << ConstraintsNames[option] << fmtBoldEnd << ' '; Statusbar() << fmtBold << ConstraintsNames[option] << fmtBoldEnd << ' ';
itsConstraints[option] = Global::wFooter->GetString(itsConstraints[option]); itsConstraints[option] = Global::wFooter->GetString(itsConstraints[option]);
@@ -140,7 +140,7 @@ void SearchEngine::EnterPressed()
CaseSensitive = !CaseSensitive * REG_ICASE; CaseSensitive = !CaseSensitive * REG_ICASE;
*w->Current().first << fmtBold << "Case sensitive:" << fmtBoldEnd << ' ' << (!CaseSensitive ? "Yes" : "No"); *w->Current().first << fmtBold << "Case sensitive:" << fmtBoldEnd << ' ' << (!CaseSensitive ? "Yes" : "No");
} }
else if (option == 15) else if (option == SearchButton)
{ {
ShowMessage("Searching..."); ShowMessage("Searching...");
if (w->Size() > StaticOptions) if (w->Size() > StaticOptions)
@@ -168,7 +168,7 @@ void SearchEngine::EnterPressed()
else else
ShowMessage("No results found"); ShowMessage("No results found");
} }
else if (option == 16) else if (option == ResetButton)
{ {
for (size_t i = 0; i < ConstraintsNumber; ++i) for (size_t i = 0; i < ConstraintsNumber; ++i)
itsConstraints[i].clear(); itsConstraints[i].clear();
@@ -179,7 +179,7 @@ void SearchEngine::EnterPressed()
else else
w->Bold(w->Choice(), myPlaylist->Add(*w->Current().second, w->isBold(), 1)); w->Bold(w->Choice(), myPlaylist->Add(*w->Current().second, w->isBold(), 1));
if (option < 15) if (option < SearchButton)
UnlockStatusbar(); UnlockStatusbar();
} }
@@ -208,7 +208,7 @@ void SearchEngine::MouseButtonPressed(MEVENT me)
if (!w->Goto(me.y)) if (!w->Goto(me.y))
return; return;
w->Refresh(); w->Refresh();
if ((me.bstate & BUTTON3_PRESSED || w->Choice() > 10) && w->Choice() < StaticOptions) if ((me.bstate & BUTTON3_PRESSED || w->Choice() > ConstraintsNumber) && w->Choice() < StaticOptions)
EnterPressed(); EnterPressed();
else if (w->Choice() >= StaticOptions) else if (w->Choice() >= StaticOptions)
{ {
@@ -299,8 +299,8 @@ void SearchEngine::Prepare()
*w->at(12).first << fmtBold << "Search mode:" << fmtBoldEnd << ' ' << (MatchToPattern ? NormalMode : StrictMode); *w->at(12).first << fmtBold << "Search mode:" << fmtBoldEnd << ' ' << (MatchToPattern ? NormalMode : StrictMode);
*w->at(13).first << fmtBold << "Case sensitive:" << fmtBoldEnd << ' ' << (!CaseSensitive ? "Yes" : "No"); *w->at(13).first << fmtBold << "Case sensitive:" << fmtBoldEnd << ' ' << (!CaseSensitive ? "Yes" : "No");
*w->at(15).first << "Search"; *w->at(SearchButton).first << "Search";
*w->at(16).first << "Reset"; *w->at(ResetButton).first << "Reset";
} }
void SearchEngine::Search() void SearchEngine::Search()