scrollpad: explicitely include iostream
[ncmpcpp.git] / src / browser.h
blob8736169670de0fb5f5f8216b9fc1170277f18603
1 /***************************************************************************
2 * Copyright (C) 2008-2014 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 NCMPCPP_BROWSER_H
22 #define NCMPCPP_BROWSER_H
24 #include "interfaces.h"
25 #include "mpdpp.h"
26 #include "screen.h"
28 struct Browser: Screen<NC::Menu<MPD::Item>>, Filterable, HasSongs, Searchable, Tabbable
30 Browser();
32 // Screen< NC::Menu<MPD::Item> > implementation
33 virtual void resize() OVERRIDE;
34 virtual void switchTo() OVERRIDE;
36 virtual std::wstring title() OVERRIDE;
37 virtual ScreenType type() OVERRIDE { return ScreenType::Browser; }
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 isMergable() OVERRIDE { return true; }
47 // Filterable implementation
48 virtual bool allowsFiltering() OVERRIDE;
49 virtual std::string currentFilter() OVERRIDE;
50 virtual void applyFilter(const std::string &filter) OVERRIDE;
52 // Searchable implementation
53 virtual bool allowsSearching() OVERRIDE;
54 virtual bool search(const std::string &constraint) OVERRIDE;
55 virtual void nextFound(bool wrap) OVERRIDE;
56 virtual void prevFound(bool wrap) OVERRIDE;
58 // HasSongs implementation
59 virtual ProxySongList proxySongList() OVERRIDE;
61 virtual bool allowsSelection() OVERRIDE;
62 virtual void reverseSelection() OVERRIDE;
63 virtual MPD::SongList getSelectedSongs() OVERRIDE;
65 // private members
66 const std::string &CurrentDir() { return itsBrowsedDir; }
68 void fetchSupportedExtensions();
70 bool isLocal() { return itsBrowseLocally; }
71 void LocateSong(const MPD::Song &);
72 void GetDirectory(std::string, std::string = "/");
73 # ifndef WIN32
74 void GetLocalDirectory(MPD::ItemList &, const std::string &, bool) const;
75 void ClearDirectory(const std::string &) const;
76 void ChangeBrowseMode();
77 bool deleteItem(const MPD::Item &, std::string &errmsg);
78 # endif // !WIN32
80 static bool isParentDirectory(const MPD::Item &item) {
81 return item.type == MPD::itDirectory && item.name == "..";
84 protected:
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 // NCMPCPP_BROWSER_H