1 /***************************************************************************
2 * Copyright (C) 2008-2014 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
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. *
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. *
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"
31 #include "song_list.h"
33 struct Playlist
: Screen
<SongMenu
>, HasSongs
, Searchable
, Tabbable
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 virtual std::string
currentFilter() OVERRIDE
;
59 virtual void applyFilter(const std::string
&filter
) OVERRIDE
;
61 // HasSongs implementation
62 virtual bool itemAvailable() OVERRIDE
;
63 virtual bool addItemToPlaylist(bool play
) OVERRIDE
;
64 virtual std::vector
<MPD::Song
> getSelectedSongs() OVERRIDE
;
67 MPD::Song
nowPlayingSong();
69 // Move to given song from playlist.
70 void moveToSong(const MPD::Song
&s
);
72 void enableHighlighting();
74 void setSelectedItemsPriority(int prio
);
76 bool checkForSong(const MPD::Song
&s
);
77 void registerSong(const MPD::Song
&s
);
78 void unregisterSong(const MPD::Song
&s
);
80 void reloadTotalLength() { m_reload_total_length
= true; }
81 void reloadRemaining() { m_reload_remaining
= true; }
84 std::string
getTotalLength();
88 std::unordered_map
<MPD::Song
, int, MPD::Song::Hash
> m_song_refs
;
90 size_t m_total_length
;;
91 size_t m_remaining_time
;
92 size_t m_scroll_begin
;
94 boost::posix_time::ptime m_timer
;
96 bool m_reload_total_length
;
97 bool m_reload_remaining
;
99 Regex::Filter
<MPD::Song
> m_search_predicate
;
102 extern Playlist
*myPlaylist
;
104 #endif // NCMPCPP_PLAYLIST_H