search engine: fix error occuring while trying to select first album in results
This commit is contained in:
12
src/menu.h
12
src/menu.h
@@ -279,6 +279,12 @@ namespace NCurses
|
||||
///
|
||||
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
|
||||
/// @param pos position in list
|
||||
/// @param state state of selection
|
||||
@@ -956,6 +962,12 @@ template <typename T> bool NCurses::Menu<T>::isStatic(int pos) const
|
||||
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
|
||||
{
|
||||
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 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 void ReverseSelection() { w->ReverseSelection(StaticOptions); }
|
||||
|
||||
Reference in New Issue
Block a user