strbuffer: change basic_buffer to BasicBuffer
[ncmpcpp.git] / src / browser.h
blob2f61b94f68ee8d34e7bdbd73bb5c68b6c2e40cd8
1 /***************************************************************************
2 * Copyright (C) 2008-2012 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #ifndef _BROWSER_H
22 #define _BROWSER_H
24 #include "interfaces.h"
25 #include "mpdpp.h"
26 #include "screen.h"
28 class Browser : public Screen< NC::Menu<MPD::Item> >, public Filterable, public HasSongs, public Searchable
30 public:
31 Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/") { }
33 // Screen< NC::Menu<MPD::Item> > implementation
34 virtual void Resize() OVERRIDE;
35 virtual void SwitchTo() OVERRIDE;
37 virtual std::wstring Title() OVERRIDE;
39 virtual void Update() OVERRIDE { }
41 virtual void EnterPressed() OVERRIDE;
42 virtual void SpacePressed() OVERRIDE;
43 virtual void MouseButtonPressed(MEVENT me) OVERRIDE;
45 virtual bool isTabbable() OVERRIDE { return true; }
46 virtual bool isMergable() OVERRIDE { return true; }
48 // Filterable implementation
49 virtual bool allowsFiltering() OVERRIDE;
50 virtual std::string currentFilter() OVERRIDE;
51 virtual void applyFilter(const std::string &filter) OVERRIDE;
53 // Searchable implementation
54 virtual bool allowsSearching() OVERRIDE;
55 virtual bool search(const std::string &constraint) OVERRIDE;
56 virtual void nextFound(bool wrap) OVERRIDE;
57 virtual void prevFound(bool wrap) OVERRIDE;
59 // HasSongs implementation
60 virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
62 virtual bool allowsSelection() OVERRIDE;
63 virtual void reverseSelection() OVERRIDE;
64 virtual MPD::SongList getSelectedSongs() OVERRIDE;
66 // private members
67 const std::string &CurrentDir() { return itsBrowsedDir; }
69 bool isLocal() { return itsBrowseLocally; }
70 void LocateSong(const MPD::Song &);
71 void GetDirectory(std::string, std::string = "/");
72 # ifndef WIN32
73 void GetLocalDirectory(MPD::ItemList &, const std::string & = "", bool = 0) const;
74 void ClearDirectory(const std::string &) const;
75 void ChangeBrowseMode();
76 bool deleteItem(const MPD::Item &);
77 # endif // !WIN32
79 static bool isParentDirectory(const MPD::Item &item) {
80 return item.type == MPD::itDirectory && item.name == "..";
83 protected:
84 virtual void Init() OVERRIDE;
85 virtual bool isLockable() OVERRIDE { return true; }
87 private:
88 bool itsBrowseLocally;
89 size_t itsScrollBeginning;
90 std::string itsBrowsedDir;
93 extern Browser *myBrowser;
95 #endif