actions: use unique_ptr for storing actions
[ncmpcpp.git] / src / browser.h
blob6170c976f031a6a3ea42a3d1c88dd5241ad988d1
1 /***************************************************************************
2 * Copyright (C) 2008-2016 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 NCMPCPP_BROWSER_H
22 #define NCMPCPP_BROWSER_H
24 #include "interfaces.h"
25 #include "mpdpp.h"
26 #include "regex_filter.h"
27 #include "screen.h"
28 #include "song_list.h"
30 struct BrowserWindow: NC::Menu<MPD::Item>, SongList
32 BrowserWindow() { }
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>, Filterable, HasSongs, Searchable, Tabbable
48 Browser();
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 const std::string &searchConstraint() override;
67 virtual void setSearchConstraint(const std::string &constraint) override;
68 virtual void clearSearchConstraint() override;
69 virtual bool search(SearchDirection direction, bool wrap, bool skip_current) override;
71 // Filterable implemenetation
72 virtual bool allowsFiltering() override;
73 virtual std::string currentFilter() override;
74 virtual void applyFilter(const std::string &filter) override;
76 // HasSongs implementation
77 virtual bool itemAvailable() override;
78 virtual bool addItemToPlaylist(bool play) override;
79 virtual std::vector<MPD::Song> getSelectedSongs() override;
81 // private members
82 void requestUpdate() { m_update_request = true; }
84 bool inRootDirectory();
85 bool isParentDirectory(const MPD::Item &item);
86 const std::string &currentDirectory();
88 bool isLocal() { return m_local_browser; }
89 void locateSong(const MPD::Song &s);
90 bool enterDirectory();
91 void getDirectory(std::string directory);
92 void changeBrowseMode();
93 void remove(const MPD::Item &item);
95 static void fetchSupportedExtensions();
97 private:
98 bool m_update_request;
99 bool m_local_browser;
100 size_t m_scroll_beginning;
101 std::string m_current_directory;
102 Regex::Filter<MPD::Item> m_search_predicate;
105 extern Browser *myBrowser;
107 #endif // NCMPCPP_BROWSER_H