menu: get rid of RealChoice

This commit is contained in:
Andrzej Rybczak
2012-08-31 06:05:29 +02:00
parent 970727fab2
commit 04bbdc53fc
2 changed files with 13 additions and 27 deletions

View File

@@ -337,11 +337,6 @@ template <typename T> struct Menu : public Window, public List
/// ///
size_t Choice() const; size_t Choice() const;
/// @return real current positions, i.e it doesn't
/// count positions that are static or separators
///
size_t RealChoice() const;
/// Searches the list for a given contraint. It uses ItemStringifier to convert stored items /// Searches the list for a given contraint. It uses ItemStringifier to convert stored items
/// into strings and then performs pattern matching. Note that this supports regular expressions. /// into strings and then performs pattern matching. Note that this supports regular expressions.
/// @param constraint a search constraint to be used /// @param constraint a search constraint to be used
@@ -931,15 +926,6 @@ template <typename T> size_t Menu<T>::Choice() const
return m_highlight; return m_highlight;
} }
template <typename T> size_t Menu<T>::RealChoice() const
{
size_t result = 0;
for (auto it = m_options_ptr->begin(); it != m_options_ptr->begin()+m_highlight; ++it)
if (!(*it)->isInactive())
result++;
return result;
}
template <typename T> void Menu<T>::ReverseSelection(size_t beginning) template <typename T> void Menu<T>::ReverseSelection(size_t beginning)
{ {
auto it = m_options_ptr->begin()+beginning; auto it = m_options_ptr->begin()+beginning;

View File

@@ -348,8 +348,8 @@ void TagEditor::EnterPressed()
} }
else if (w == FParserDialog) else if (w == FParserDialog)
{ {
size_t choice = FParserDialog->RealChoice(); size_t choice = FParserDialog->Choice();
if (choice == 2) // cancel if (choice == 3) // cancel
{ {
w = TagTypes; w = TagTypes;
Refresh(); Refresh();
@@ -404,9 +404,9 @@ void TagEditor::EnterPressed()
else if (w == FParser) else if (w == FParser)
{ {
bool quit = 0; bool quit = 0;
size_t pos = FParser->RealChoice(); size_t pos = FParser->Choice();
if (pos == 3) // save if (pos == 4) // save
FParserUsePreview = 0; FParserUsePreview = 0;
if (pos == 0) // change pattern if (pos == 0) // change pattern
@@ -422,7 +422,7 @@ void TagEditor::EnterPressed()
FParser->at(0).value() += Config.pattern; FParser->at(0).value() += Config.pattern;
} }
} }
else if (pos == 1 || pos == 3) // preview or proceed else if (pos == 1 || pos == 4) // preview or proceed
{ {
bool success = 1; bool success = 1;
ShowMessage("Parsing..."); ShowMessage("Parsing...");
@@ -476,7 +476,7 @@ void TagEditor::EnterPressed()
Patterns.insert(Patterns.begin(), Config.pattern); Patterns.insert(Patterns.begin(), Config.pattern);
quit = 1; quit = 1;
} }
if (pos != 3 || success) if (pos != 4 || success)
ShowMessage("Operation finished"); ShowMessage("Operation finished");
} }
else if (pos == 2) // show legend else if (pos == 2) // show legend
@@ -484,7 +484,7 @@ void TagEditor::EnterPressed()
FParserHelper = FParserLegend; FParserHelper = FParserLegend;
FParserHelper->Display(); FParserHelper->Display();
} }
else if (pos == 4) // cancel else if (pos == 5) // cancel
{ {
quit = 1; quit = 1;
} }
@@ -518,7 +518,7 @@ void TagEditor::EnterPressed()
for (size_t i = 0; i < Tags->Size(); ++i) for (size_t i = 0; i < Tags->Size(); ++i)
EditedSongs.push_back(&(*Tags)[i].value()); EditedSongs.push_back(&(*Tags)[i].value());
size_t id = TagTypes->RealChoice(); size_t id = TagTypes->Choice();
if (w == TagTypes && id == 5) if (w == TagTypes && id == 5)
{ {
@@ -566,7 +566,7 @@ void TagEditor::EnterPressed()
} }
else else
{ {
if (id == 11) // filename related options if (id == 12) // filename related options
{ {
if (w == TagTypes) if (w == TagTypes)
{ {
@@ -594,26 +594,26 @@ void TagEditor::EnterPressed()
Tags->Scroll(wDown); Tags->Scroll(wDown);
} }
} }
else if (id == 12) // capitalize first letters else if (id == 16) // capitalize first letters
{ {
ShowMessage("Processing..."); ShowMessage("Processing...");
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it) for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
CapitalizeFirstLetters(**it); CapitalizeFirstLetters(**it);
ShowMessage("Done"); ShowMessage("Done");
} }
else if (id == 13) // lower all letters else if (id == 17) // lower all letters
{ {
ShowMessage("Processing..."); ShowMessage("Processing...");
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it) for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
LowerAllLetters(**it); LowerAllLetters(**it);
ShowMessage("Done"); ShowMessage("Done");
} }
else if (id == 14) // reset else if (id == 18) // reset
{ {
Tags->Clear(); Tags->Clear();
ShowMessage("Changes reset"); ShowMessage("Changes reset");
} }
else if (id == 15) // save else if (id == 19) // save
{ {
bool success = 1; bool success = 1;
ShowMessage("Writing changes..."); ShowMessage("Writing changes...");