implement ProxySongList for handling general operations on lists
[ncmpcpp.git] / src / playlist.h
blob4702953aae88646f56ec2203fbbd57aed266734f
1 /***************************************************************************
2 * Copyright (C) 2008-2012 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 _PLAYLIST_H
22 #define _PLAYLIST_H
24 #include "interfaces.h"
25 #include "screen.h"
26 #include "song.h"
28 class Playlist : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable
30 public:
31 enum Movement { mUp, mDown };
33 Playlist() : NowPlaying(-1), itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0) { }
34 ~Playlist() { }
36 virtual void SwitchTo();
37 virtual void Resize();
39 virtual std::basic_string<my_char_t> Title();
41 virtual void EnterPressed();
42 virtual void SpacePressed();
43 virtual void MouseButtonPressed(MEVENT);
44 virtual bool isTabbable() { return true; }
46 /// Filterable implementation
47 virtual std::string currentFilter();
48 virtual void applyFilter(const std::string &filter);
50 /// Searchable implementation
51 virtual bool search(const std::string &constraint);
52 virtual void nextFound(bool wrap);
53 virtual void prevFound(bool wrap);
55 /// HasSongs implementation
56 virtual MPD::Song *getSong(size_t pos);
57 virtual MPD::Song *currentSong();
58 virtual std::shared_ptr<ProxySongList> getProxySongList();
60 virtual bool allowsSelection();
61 virtual void reverseSelection();
62 virtual MPD::SongList getSelectedSongs();
64 virtual NC::List *GetList() { return w == Items ? Items : 0; }
66 virtual bool isMergable() { return true; }
68 bool isFiltered();
69 bool isPlaying() { return NowPlaying >= 0 && !Items->Empty(); }
70 const MPD::Song *NowPlayingSong();
72 void MoveSelectedItems(Movement where);
74 void Sort();
75 void Reverse();
76 void AdjustSortOrder(Movement where);
77 bool SortingInProgress();
79 void EnableHighlighting();
80 void UpdateTimer() { time(&itsTimer); }
81 time_t Timer() const { return itsTimer; }
83 bool Add(const MPD::Song &s, bool in_playlist, bool play, int position = -1);
84 bool Add(const MPD::SongList &l, bool play, int position = -1);
85 void PlayNewlyAddedSongs();
87 void SetSelectedItemsPriority(int prio);
89 bool checkForSong(const MPD::Song &s);
91 //static std::string SongToString(const MPD::Song &s);
92 //static std::string SongInColumnsToString(const MPD::Song &s);
94 NC::Menu< MPD::Song > *Items;
96 int NowPlaying;
98 static bool ReloadTotalLength;
99 static bool ReloadRemaining;
101 protected:
102 virtual void Init();
103 virtual bool isLockable() { return true; }
105 private:
106 std::string TotalLength();
107 std::string itsBufferedStats;
109 size_t itsTotalLength;
110 size_t itsRemainingTime;
111 size_t itsScrollBegin;
113 time_t itsTimer;
116 extern Playlist *myPlaylist;
118 #endif