search engine: fix error occuring while trying to select first album in results

master
Andrzej Rybczak 15 years ago
parent e42c1c1729
commit 07c540e67e
  1. 12
      src/menu.h
  2. 2
      src/search_engine.h

@ -279,6 +279,12 @@ namespace NCurses
/// ///
bool isStatic(int pos = -1) const; bool isStatic(int pos = -1) const;
/// Checks whether given position is separator
/// @param pos position to be checked, -1 checks currently highlighted position
/// @return true if position is separator, false otherwise
///
bool isSeparator(int pos = -1) const;
/// Selects/deselects given position /// Selects/deselects given position
/// @param pos position in list /// @param pos position in list
/// @param state state of selection /// @param state state of selection
@ -956,6 +962,12 @@ template <typename T> bool NCurses::Menu<T>::isStatic(int pos) const
return (*itsOptionsPtr)[pos]->isStatic; return (*itsOptionsPtr)[pos]->isStatic;
} }
template <typename T> bool NCurses::Menu<T>::isSeparator(int pos) const
{
pos = pos == -1 ? itsHighlight : pos;
return !itsOptionsPtr->at(pos);
}
template <typename T> bool NCurses::Menu<T>::hasSelected() const template <typename T> bool NCurses::Menu<T>::hasSelected() const
{ {
for (option_const_iterator it = itsOptionsPtr->begin(); it != itsOptionsPtr->end(); ++it) for (option_const_iterator it = itsOptionsPtr->begin(); it != itsOptionsPtr->end(); ++it)

@ -38,7 +38,7 @@ class SearchEngine : public Screen< Menu< std::pair<Buffer *, MPD::Song *> > >
virtual bool isTabbable() { return true; } virtual bool isTabbable() { return true; }
virtual MPD::Song *CurrentSong(); virtual MPD::Song *CurrentSong();
virtual MPD::Song *GetSong(size_t pos) { return w->at(pos).second; } virtual MPD::Song *GetSong(size_t pos) { return !w->isSeparator(pos) ? w->at(pos).second : 0; }
virtual bool allowsSelection() { return w->Choice() >= StaticOptions; } virtual bool allowsSelection() { return w->Choice() >= StaticOptions; }
virtual void ReverseSelection() { w->ReverseSelection(StaticOptions); } virtual void ReverseSelection() { w->ReverseSelection(StaticOptions); }

Loading…
Cancel
Save