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"
31 struct Playlist
: Screen
<NC::Menu
<MPD::Song
>>, Filterable
, HasSongs
, Searchable
, Tabbable
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
;
69 MPD::Song
nowPlayingSong();
74 void EnableHighlighting();
76 void SetSelectedItemsPriority(int prio
);
78 void setStatus(MPD::Status status
);
79 unsigned oldVersion() const;
80 int currentSongPosition() const;
81 unsigned currentSongLength() const;
83 bool checkForSong(const MPD::Song
&s
);
84 void registerSong(const MPD::Song
&s
);
85 void unregisterSong(const MPD::Song
&s
);
87 void reloadTotalLength() { m_reload_total_length
= true; }
88 void reloadRemaining() { m_reload_remaining
= true; }
91 virtual bool isLockable() OVERRIDE
{ return true; }
94 std::string
getTotalLength();
98 std::unordered_map
<MPD::Song
, int, MPD::Song::Hash
> m_song_refs
;
100 size_t m_total_length
;;
101 size_t m_remaining_time
;
102 size_t m_scroll_begin
;
104 boost::posix_time::ptime m_timer
;
106 MPD::Status m_status
;
107 unsigned m_old_playlist_version
;
109 bool m_reload_total_length
;
110 bool m_reload_remaining
;
113 extern Playlist
*myPlaylist
;
115 #endif // NCMPCPP_PLAYLIST_H