implement Searchable interface / make use of unnamed namespaces

This commit is contained in:
Andrzej Rybczak
2012-09-01 16:10:52 +02:00
parent 12ca003350
commit 0811e30319
19 changed files with 904 additions and 639 deletions

View File

@@ -26,7 +26,7 @@
#include "regex_filter.h"
#include "screen.h"
class Browser : public Screen< Menu<MPD::Item> >, public Filterable
class Browser : public Screen< Menu<MPD::Item> >, public Filterable, public Searchable
{
public:
Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/") { }
@@ -48,9 +48,15 @@ class Browser : public Screen< Menu<MPD::Item> >, public Filterable
virtual void ReverseSelection();
virtual void GetSelectedSongs(MPD::SongList &);
/// Filterable implementation
virtual std::string currentFilter();
virtual void applyFilter(const std::string &filter);
/// Searchable implementation
virtual bool search(const std::string &constraint);
virtual void nextFound(bool wrap);
virtual void prevFound(bool wrap);
virtual List *GetList() { return w; }
virtual bool isMergable() { return true; }
@@ -68,18 +74,15 @@ class Browser : public Screen< Menu<MPD::Item> >, public Filterable
# endif // !WIN32
void UpdateItemList();
bool isParentDir(size_t pos) { return itsBrowsedDir != "/" && pos == 0; }
static bool isParentDirectory(const MPD::Item &item) {
return item.type == MPD::itDirectory && item.name == "..";
}
protected:
virtual void Init();
virtual bool isLockable() { return true; }
private:
static bool hasSupportedExtension(const std::string &);
static std::string ItemToString(const MPD::Item &item);
static std::set<std::string> SupportedExtensions;
bool itsBrowseLocally;
size_t itsScrollBeginning;
std::string itsBrowsedDir;