actions: use unique_ptr for storing actions
[ncmpcpp.git] / src / playlist.h
blob0bfe62fd86384f560338df33aac993dd35a0a3fc
1 /***************************************************************************
2 * Copyright (C) 2008-2016 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 "regex_filter.h"
29 #include "screen.h"
30 #include "song.h"
31 #include "song_list.h"
33 struct Playlist: Screen<SongMenu>, Filterable, HasSongs, Searchable, Tabbable
35 Playlist();
37 // Screen<SongMenu> implementation
38 virtual void switchTo() override;
39 virtual void resize() override;
41 virtual std::wstring title() override;
42 virtual ScreenType type() override { return ScreenType::Playlist; }
44 virtual void update() override;
46 virtual void mouseButtonPressed(MEVENT me) override;
48 virtual bool isLockable() override { return true; }
49 virtual bool isMergable() override { return true; }
51 // Searchable implementation
52 virtual bool allowsSearching() override;
53 virtual const std::string &searchConstraint() override;
54 virtual void setSearchConstraint(const std::string &constraint) override;
55 virtual void clearSearchConstraint() override;
56 virtual bool search(SearchDirection direction, bool wrap, bool skip_current) override;
58 // Filterable implementation
59 virtual bool allowsFiltering() override;
60 virtual std::string currentFilter() override;
61 virtual void applyFilter(const std::string &filter) override;
63 // HasSongs implementation
64 virtual bool itemAvailable() override;
65 virtual bool addItemToPlaylist(bool play) override;
66 virtual std::vector<MPD::Song> getSelectedSongs() override;
68 // other members
69 MPD::Song nowPlayingSong();
71 // Locate song in playlist.
72 void locateSong(const MPD::Song &s);
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 private:
86 std::string getTotalLength();
88 std::string m_stats;
90 std::unordered_map<MPD::Song, int, MPD::Song::Hash> m_song_refs;
92 size_t m_total_length;;
93 size_t m_remaining_time;
94 size_t m_scroll_begin;
96 boost::posix_time::ptime m_timer;
98 bool m_reload_total_length;
99 bool m_reload_remaining;
101 Regex::Filter<MPD::Song> m_search_predicate;
104 extern Playlist *myPlaylist;
106 #endif // NCMPCPP_PLAYLIST_H