scrollpad: explicitely include iostream
[ncmpcpp.git] / src / playlist.h
blob2df8f881b0197f349bdf989fe2656a972d9a871f
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_PLAYLIST_H
22 #define NCMPCPP_PLAYLIST_H
24 #include <boost/date_time/posix_time/posix_time_types.hpp>
25 #include <unordered_map>
27 #include "interfaces.h"
28 #include "screen.h"
29 #include "song.h"
31 struct Playlist: Screen<NC::Menu<MPD::Song>>, Filterable, HasSongs, Searchable, Tabbable
33 Playlist();
35 // Screen<NC::Menu<MPD::Song>> implementation
36 virtual void switchTo() OVERRIDE;
37 virtual void resize() OVERRIDE;
39 virtual std::wstring title() OVERRIDE;
40 virtual ScreenType type() OVERRIDE { return ScreenType::Playlist; }
42 virtual void update() OVERRIDE;
44 virtual void enterPressed() OVERRIDE;
45 virtual void spacePressed() OVERRIDE;
46 virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
48 virtual bool isMergable() OVERRIDE { return true; }
50 // Filterable implementation
51 virtual bool allowsFiltering() OVERRIDE;
52 virtual std::string currentFilter() OVERRIDE;
53 virtual void applyFilter(const std::string &filter) OVERRIDE;
55 // Searchable implementation
56 virtual bool allowsSearching();
57 virtual bool search(const std::string &constraint) OVERRIDE;
58 virtual void nextFound(bool wrap) OVERRIDE;
59 virtual void prevFound(bool wrap) OVERRIDE;
61 // HasSongs implementation
62 virtual ProxySongList proxySongList() OVERRIDE;
64 virtual bool allowsSelection() OVERRIDE;
65 virtual void reverseSelection() OVERRIDE;
66 virtual MPD::SongList getSelectedSongs() OVERRIDE;
68 // private members
69 MPD::Song nowPlayingSong();
71 bool isFiltered();
72 void Reverse();
74 void EnableHighlighting();
76 void SetSelectedItemsPriority(int prio);
78 bool checkForSong(const MPD::Song &s);
79 void registerSong(const MPD::Song &s);
80 void unregisterSong(const MPD::Song &s);
82 void reloadTotalLength() { m_reload_total_length = true; }
83 void reloadRemaining() { m_reload_remaining = true; }
85 protected:
86 virtual bool isLockable() OVERRIDE { return true; }
88 private:
89 std::string getTotalLength();
91 std::string m_stats;
93 std::unordered_map<MPD::Song, int, MPD::Song::Hash> m_song_refs;
95 size_t m_total_length;;
96 size_t m_remaining_time;
97 size_t m_scroll_begin;
99 boost::posix_time::ptime m_timer;
101 bool m_reload_total_length;
102 bool m_reload_remaining;
105 extern Playlist *myPlaylist;
107 #endif // NCMPCPP_PLAYLIST_H