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_EDITOR_H
22 #define NCMPCPP_PLAYLIST_EDITOR_H
24 #include <boost/date_time/posix_time/posix_time_types.hpp>
26 #include "interfaces.h"
27 #include "regex_filter.h"
29 #include "song_list.h"
31 struct PlaylistEditor
: Screen
<NC::Window
*>, HasColumns
, HasSongs
, Searchable
, Tabbable
35 virtual void switchTo() OVERRIDE
;
36 virtual void resize() OVERRIDE
;
38 virtual std::wstring
title() OVERRIDE
;
39 virtual ScreenType
type() OVERRIDE
{ return ScreenType::PlaylistEditor
; }
41 virtual void refresh() OVERRIDE
;
42 virtual void update() OVERRIDE
;
44 virtual int windowTimeout() OVERRIDE
;
46 virtual void enterPressed() OVERRIDE
;
47 virtual void mouseButtonPressed(MEVENT me
) OVERRIDE
;
49 virtual bool isLockable() OVERRIDE
{ return true; }
50 virtual bool isMergable() OVERRIDE
{ return true; }
52 // Searchable implementation
53 virtual bool allowsSearching() OVERRIDE
;
54 virtual void setSearchConstraint(const std::string
&constraint
) OVERRIDE
;
55 virtual void clearConstraint() OVERRIDE
;
56 virtual bool find(SearchDirection direction
, bool wrap
, bool skip_current
) OVERRIDE
;
58 // HasSongs implementation
59 virtual bool addItemToPlaylist() OVERRIDE
;
60 virtual std::vector
<MPD::Song
> getSelectedSongs() OVERRIDE
;
62 // HasColumns implementation
63 virtual bool previousColumnAvailable() OVERRIDE
;
64 virtual void previousColumn() OVERRIDE
;
66 virtual bool nextColumnAvailable() OVERRIDE
;
67 virtual void nextColumn() OVERRIDE
;
72 void requestPlaylistsUpdate() { m_playlists_update_requested
= true; }
73 void requestContentsUpdate() { m_content_update_requested
= true; }
75 virtual void Locate(const MPD::Playlist
&playlist
);
77 NC::Menu
<MPD::Playlist
> Playlists
;
81 bool addItemToPlaylist(bool play
);
83 bool m_playlists_update_requested
;
84 bool m_content_update_requested
;
86 boost::posix_time::ptime m_timer
;
88 const int m_window_timeout
;
89 const boost::posix_time::time_duration m_fetching_delay
;
91 Regex::Filter
<MPD::Playlist
> m_playlists_search_predicate
;
92 Regex::Filter
<MPD::Song
> m_content_search_predicate
;
95 extern PlaylistEditor
*myPlaylistEditor
;
97 #endif // NCMPCPP_PLAYLIST_EDITOR_H