1 /*************************************************************************** 2 * Copyright (C) 2008-2021 by Andrzej Rybczak * 3 * andrzej@rybczak.net * 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 ***************************************************************************/ 20 21 #ifndef NCMPCPP_TAG_EDITOR_H 22 #define NCMPCPP_TAG_EDITOR_H 23 24 #include "config.h" 25 26 #ifdef HAVE_TAGLIB_H 27 28 #include <list> 29 30 #include "interfaces.h" 31 #include "mutable_song.h" 32 #include "regex_filter.h" 33 #include "screens/screen.h" 34 #include "song_list.h" 35 36 struct TagsWindow: NC::Menu<MPD::MutableSong>, SongList 37 { TagsWindowTagsWindow38 TagsWindow() { } TagsWindowTagsWindow39 TagsWindow(NC::Menu<MPD::MutableSong> &&base) 40 : NC::Menu<MPD::MutableSong>(std::move(base)) { } 41 42 virtual SongIterator currentS() override; 43 virtual ConstSongIterator currentS() const override; 44 virtual SongIterator beginS() override; 45 virtual ConstSongIterator beginS() const override; 46 virtual SongIterator endS() override; 47 virtual ConstSongIterator endS() const override; 48 49 virtual std::vector<MPD::Song> getSelectedSongs() override; 50 }; 51 52 struct TagEditor: Screen<NC::Window *>, HasActions, HasColumns, HasSongs, Searchable, Tabbable 53 { 54 TagEditor(); 55 56 virtual void resize() override; 57 virtual void switchTo() override; 58 59 virtual std::wstring title() override; typeTagEditor60 virtual ScreenType type() override { return ScreenType::TagEditor; } 61 62 virtual void refresh() override; 63 virtual void update() override; 64 65 virtual void mouseButtonPressed(MEVENT) override; 66 isLockableTagEditor67 virtual bool isLockable() override { return true; } isMergableTagEditor68 virtual bool isMergable() override { return true; } 69 70 // Searchable implementation 71 virtual bool allowsSearching() override; 72 virtual const std::string &searchConstraint() override; 73 virtual void setSearchConstraint(const std::string &constraint) override; 74 virtual void clearSearchConstraint() override; 75 virtual bool search(SearchDirection direction, bool wrap, bool skip_current) override; 76 77 // HasActions implementation 78 virtual bool actionRunnable() override; 79 virtual void runAction() override; 80 81 // HasSongs implementation 82 virtual bool itemAvailable() override; 83 virtual bool addItemToPlaylist(bool play) override; 84 virtual std::vector<MPD::Song> getSelectedSongs() override; 85 86 // HasColumns implementation 87 virtual bool previousColumnAvailable() override; 88 virtual void previousColumn() override; 89 90 virtual bool nextColumnAvailable() override; 91 virtual void nextColumn() override; 92 93 // private members 94 bool enterDirectory(); 95 void LocateSong(const MPD::Song &s); CurrentDirTagEditor96 const std::string &CurrentDir() { return itsBrowsedDir; } 97 98 NC::Menu< std::pair<std::string, std::string> > *Dirs; 99 NC::Menu<std::string> *TagTypes; 100 TagsWindow *Tags; 101 102 private: 103 void SetDimensions(size_t, size_t); 104 105 std::vector<MPD::MutableSong *> EditedSongs; 106 NC::Menu<std::string> *FParserDialog; 107 NC::Menu<std::string> *FParser; 108 NC::Scrollpad *FParserHelper; 109 NC::Scrollpad *FParserLegend; 110 NC::Scrollpad *FParserPreview; 111 bool FParserUsePreview; 112 113 std::string itsBrowsedDir; 114 std::string itsHighlightedDir; 115 116 Regex::Filter<std::pair<std::string, std::string>> m_directories_search_predicate; 117 Regex::Filter<MPD::MutableSong> m_songs_search_predicate; 118 }; 119 120 extern TagEditor *myTagEditor; 121 122 #endif // HAVE_TAGLIB_H 123 124 #endif // NCMPCPP_TAG_EDITOR_H 125 126