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_BROWSER_H
22 #define NCMPCPP_BROWSER_H
24 #include "interfaces.h"
26 #include "regex_filter.h"
28 #include "song_list.h"
30 struct BrowserWindow
: NC::Menu
<MPD::Item
>, SongList
33 BrowserWindow(NC::Menu
<MPD::Item
> &&base
)
34 : NC::Menu
<MPD::Item
>(std::move(base
)) { }
36 virtual SongIterator
currentS() OVERRIDE
;
37 virtual ConstSongIterator
currentS() const OVERRIDE
;
38 virtual SongIterator
beginS() OVERRIDE
;
39 virtual ConstSongIterator
beginS() const OVERRIDE
;
40 virtual SongIterator
endS() OVERRIDE
;
41 virtual ConstSongIterator
endS() const OVERRIDE
;
43 virtual std::vector
<MPD::Song
> getSelectedSongs() OVERRIDE
;
46 struct Browser
: Screen
<BrowserWindow
>, HasSongs
, Searchable
, Tabbable
50 // Screen<BrowserWindow> implementation
51 virtual void resize() OVERRIDE
;
52 virtual void switchTo() OVERRIDE
;
54 virtual std::wstring
title() OVERRIDE
;
55 virtual ScreenType
type() OVERRIDE
{ return ScreenType::Browser
; }
57 virtual void update() OVERRIDE
;
59 virtual void mouseButtonPressed(MEVENT me
) OVERRIDE
;
61 virtual bool isLockable() OVERRIDE
{ return true; }
62 virtual bool isMergable() OVERRIDE
{ return true; }
64 // Searchable implementation
65 virtual bool allowsSearching() OVERRIDE
;
66 virtual void setSearchConstraint(const std::string
&constraint
) OVERRIDE
;
67 virtual void clearConstraint() OVERRIDE
;
68 virtual bool find(SearchDirection direction
, bool wrap
, bool skip_current
) OVERRIDE
;
70 // HasSongs implementation
71 virtual bool itemAvailable() OVERRIDE
;
72 virtual bool addItemToPlaylist(bool play
) OVERRIDE
;
73 virtual std::vector
<MPD::Song
> getSelectedSongs() OVERRIDE
;
76 void requestUpdate() { m_update_request
= true; }
78 bool inRootDirectory();
79 bool isParentDirectory(const MPD::Item
&item
);
80 const std::string
¤tDirectory();
82 bool isLocal() { return m_local_browser
; }
83 void locateSong(const MPD::Song
&s
);
84 bool enterDirectory();
85 void getDirectory(std::string directory
);
86 void changeBrowseMode();
87 void remove(const MPD::Item
&item
);
89 static void fetchSupportedExtensions();
92 bool m_update_request
;
94 size_t m_scroll_beginning
;
95 std::string m_current_directory
;
96 Regex::Filter
<MPD::Item
> m_search_predicate
;
99 extern Browser
*myBrowser
;
101 #endif // NCMPCPP_BROWSER_H