From 58a26b1e18057c7cbd1868db8457d183b0a24300 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Thu, 13 Sep 2012 22:09:39 +0200 Subject: [PATCH] adjust indentation of remaining classes in headers --- src/browser.h | 123 +++++++++++++++-------------- src/clock.h | 63 ++++++++------- src/display.h | 47 ++++++----- src/global.cpp | 30 +++---- src/global.h | 83 ++++++++++---------- src/help.h | 57 +++++++------- src/lastfm.h | 99 ++++++++++++------------ src/lastfm_service.h | 28 +++---- src/lyrics.h | 141 +++++++++++++++++---------------- src/lyrics_fetcher.h | 176 +++++++++++++++++++++--------------------- src/media_library.h | 137 ++++++++++++++++---------------- src/outputs.h | 46 ++++++----- src/playlist.h | 153 ++++++++++++++++++------------------ src/playlist_editor.h | 123 +++++++++++++++-------------- src/search_engine.h | 117 ++++++++++++++-------------- src/sel_items_adder.h | 69 ++++++++--------- src/server_info.h | 55 +++++++------ src/settings.h | 10 +-- src/song.h | 14 ++-- src/song_info.h | 64 ++++++++------- src/tag_editor.h | 139 +++++++++++++++++---------------- src/tiny_tag_editor.h | 53 +++++++------ src/visualizer.h | 91 +++++++++++----------- 23 files changed, 951 insertions(+), 967 deletions(-) diff --git a/src/browser.h b/src/browser.h index 6641e988..3ae18d59 100644 --- a/src/browser.h +++ b/src/browser.h @@ -25,69 +25,68 @@ #include "mpdpp.h" #include "screen.h" -class Browser : public Screen< NC::Menu >, public Filterable, public HasSongs, public Searchable +struct Browser : public Screen< NC::Menu >, public Filterable, public HasSongs, public Searchable { - public: - Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/") { } - - // Screen< NC::Menu > implementation - virtual void resize() OVERRIDE; - virtual void switchTo() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE { } - - virtual void enterPressed() OVERRIDE; - virtual void spacePressed() OVERRIDE; - virtual void mouseButtonPressed(MEVENT me) OVERRIDE; - - virtual bool isTabbable() OVERRIDE { return true; } - virtual bool isMergable() OVERRIDE { return true; } - - // Filterable implementation - virtual bool allowsFiltering() OVERRIDE; - virtual std::string currentFilter() OVERRIDE; - virtual void applyFilter(const std::string &filter) OVERRIDE; - - // Searchable implementation - virtual bool allowsSearching() OVERRIDE; - virtual bool search(const std::string &constraint) OVERRIDE; - virtual void nextFound(bool wrap) OVERRIDE; - virtual void prevFound(bool wrap) OVERRIDE; - - // HasSongs implementation - virtual std::shared_ptr getProxySongList() OVERRIDE; - - virtual bool allowsSelection() OVERRIDE; - virtual void reverseSelection() OVERRIDE; - virtual MPD::SongList getSelectedSongs() OVERRIDE; - - // private members - const std::string &CurrentDir() { return itsBrowsedDir; } - - bool isLocal() { return itsBrowseLocally; } - void LocateSong(const MPD::Song &); - void GetDirectory(std::string, std::string = "/"); -# ifndef WIN32 - void GetLocalDirectory(MPD::ItemList &, const std::string & = "", bool = 0) const; - void ClearDirectory(const std::string &) const; - void ChangeBrowseMode(); - bool deleteItem(const MPD::Item &); -# endif // !WIN32 - - static bool isParentDirectory(const MPD::Item &item) { - return item.type == MPD::itDirectory && item.name == ".."; - } - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return true; } - - private: - bool itsBrowseLocally; - size_t itsScrollBeginning; - std::string itsBrowsedDir; + Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/") { } + + // Screen< NC::Menu > implementation + virtual void resize() OVERRIDE; + virtual void switchTo() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE { } + + virtual void enterPressed() OVERRIDE; + virtual void spacePressed() OVERRIDE; + virtual void mouseButtonPressed(MEVENT me) OVERRIDE; + + virtual bool isTabbable() OVERRIDE { return true; } + virtual bool isMergable() OVERRIDE { return true; } + + // Filterable implementation + virtual bool allowsFiltering() OVERRIDE; + virtual std::string currentFilter() OVERRIDE; + virtual void applyFilter(const std::string &filter) OVERRIDE; + + // Searchable implementation + virtual bool allowsSearching() OVERRIDE; + virtual bool search(const std::string &constraint) OVERRIDE; + virtual void nextFound(bool wrap) OVERRIDE; + virtual void prevFound(bool wrap) OVERRIDE; + + // HasSongs implementation + virtual std::shared_ptr getProxySongList() OVERRIDE; + + virtual bool allowsSelection() OVERRIDE; + virtual void reverseSelection() OVERRIDE; + virtual MPD::SongList getSelectedSongs() OVERRIDE; + + // private members + const std::string &CurrentDir() { return itsBrowsedDir; } + + bool isLocal() { return itsBrowseLocally; } + void LocateSong(const MPD::Song &); + void GetDirectory(std::string, std::string = "/"); +# ifndef WIN32 + void GetLocalDirectory(MPD::ItemList &, const std::string & = "", bool = 0) const; + void ClearDirectory(const std::string &) const; + void ChangeBrowseMode(); + bool deleteItem(const MPD::Item &); +# endif // !WIN32 + + static bool isParentDirectory(const MPD::Item &item) { + return item.type == MPD::itDirectory && item.name == ".."; + } + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return true; } + +private: + bool itsBrowseLocally; + size_t itsScrollBeginning; + std::string itsBrowsedDir; }; extern Browser *myBrowser; diff --git a/src/clock.h b/src/clock.h index b61f7dbc..4758ff4e 100644 --- a/src/clock.h +++ b/src/clock.h @@ -28,39 +28,38 @@ #include "window.h" #include "screen.h" -class Clock : public Screen +struct Clock : public Screen { - public: - virtual void resize() OVERRIDE; - virtual void switchTo() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE; - virtual void scroll(NC::Where) OVERRIDE { } - - virtual void enterPressed() OVERRIDE { } - virtual void spacePressed() OVERRIDE { } - virtual void mouseButtonPressed(MEVENT) OVERRIDE { } - - virtual bool isTabbable() OVERRIDE { return true; } - virtual bool isMergable() OVERRIDE { return true; } - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return false; } - - private: - NC::Window *itsPane; - - static void Prepare(); - static void Set(int, int); - - static short disp[11]; - static long older[6], next[6], newer[6], mask; - - static size_t Width; - static const size_t Height; + virtual void resize() OVERRIDE; + virtual void switchTo() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE; + virtual void scroll(NC::Where) OVERRIDE { } + + virtual void enterPressed() OVERRIDE { } + virtual void spacePressed() OVERRIDE { } + virtual void mouseButtonPressed(MEVENT) OVERRIDE { } + + virtual bool isTabbable() OVERRIDE { return true; } + virtual bool isMergable() OVERRIDE { return true; } + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return false; } + +private: + NC::Window *itsPane; + + static void Prepare(); + static void Set(int, int); + + static short disp[11]; + static long older[6], next[6], newer[6], mask; + + static size_t Width; + static const size_t Height; }; extern Clock *myClock; diff --git a/src/display.h b/src/display.h index 948882f5..d6606642 100644 --- a/src/display.h +++ b/src/display.h @@ -26,31 +26,28 @@ #include "mutable_song.h" #include "search_engine.h" -namespace Display -{ - std::string Columns(size_t); - - template void Default(NC::Menu &menu) - { - menu << menu.drawn()->value(); - } - - template void Pair(NC::Menu< std::pair > &menu) - { - menu << menu.drawn()->value().first; - } - - void SongsInColumns(NC::Menu &menu, HasSongs *screen); - - void Songs(NC::Menu &menu, HasSongs *screen, const std::string &format); - - void Tags(NC::Menu &menu); - - void Outputs(NC::Menu &menu); - - void SearchEngine(NC::Menu &menu); - - void Items(NC::Menu &menu); +namespace Display {// + +std::string Columns(size_t); + +template +void Default(NC::Menu &menu) { menu << menu.drawn()->value(); } + +template +void Pair(NC::Menu< std::pair > &menu) { menu << menu.drawn()->value().first; } + +void SongsInColumns(NC::Menu &menu, HasSongs *screen); + +void Songs(NC::Menu &menu, HasSongs *screen, const std::string &format); + +void Tags(NC::Menu &menu); + +void Outputs(NC::Menu &menu); + +void SearchEngine(NC::Menu &menu); + +void Items(NC::Menu &menu); + } #endif diff --git a/src/global.cpp b/src/global.cpp index cbeff616..cc55beab 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -20,20 +20,24 @@ #include "global.h" -BasicScreen *Global::myScreen; -BasicScreen *Global::myOldScreen; -BasicScreen *Global::myPrevScreen; -BasicScreen *Global::myLockedScreen; -BasicScreen *Global::myInactiveScreen; +namespace Global {// -NC::Window *Global::wHeader; -NC::Window *Global::wFooter; +BasicScreen *myScreen; +BasicScreen *myOldScreen; +BasicScreen *myPrevScreen; +BasicScreen *myLockedScreen; +BasicScreen *myInactiveScreen; -size_t Global::MainStartY; -size_t Global::MainHeight; +NC::Window *wHeader; +NC::Window *wFooter; -bool Global::ShowMessages = false; -bool Global::SeekingInProgress = false; +size_t MainStartY; +size_t MainHeight; -std::string Global::VolumeState; -timeval Global::Timer; +bool ShowMessages = false; +bool SeekingInProgress = false; + +std::string VolumeState; +timeval Timer; + +} diff --git a/src/global.h b/src/global.h index faf5551d..e63eb9ae 100644 --- a/src/global.h +++ b/src/global.h @@ -26,47 +26,48 @@ #include "mpdpp.h" #include "screen.h" -namespace Global -{ - // currently active screen (displayed in main window) - extern BasicScreen *myScreen; - - // for info, lyrics, popups to remember which screen return to - extern BasicScreen *myOldScreen; - - // "real" screen switching (browser, search, etc.) - extern BasicScreen *myPrevScreen; - - // points at the screen that was locked (or is null if no screen is locked) - extern BasicScreen *myLockedScreen; - - // points at inactive screen, if locking was enabled and two screens are displayed - extern BasicScreen *myInactiveScreen; - - // header window (above main window) - extern NC::Window *wHeader; - - // footer window (below main window) - extern NC::Window *wFooter; - - // Y coordinate of top of main window - extern size_t MainStartY; - - // height of main window - extern size_t MainHeight; - - // indicates whether messages from Statusbar::msg function should be shown - extern bool ShowMessages; - - // indicates whether seeking action in currently in progress - extern bool SeekingInProgress; - - // string that represents volume in right top corner. being global - // to be used for calculating width offsets in various files. - extern std::string VolumeState; - - // global timer - extern timeval Timer; +namespace Global {// + +// currently active screen (displayed in main window) +extern BasicScreen *myScreen; + +// for info, lyrics, popups to remember which screen return to +extern BasicScreen *myOldScreen; + +// "real" screen switching (browser, search, etc.) +extern BasicScreen *myPrevScreen; + +// points at the screen that was locked (or is null if no screen is locked) +extern BasicScreen *myLockedScreen; + +// points at inactive screen, if locking was enabled and two screens are displayed +extern BasicScreen *myInactiveScreen; + +// header window (above main window) +extern NC::Window *wHeader; + +// footer window (below main window) +extern NC::Window *wFooter; + +// Y coordinate of top of main window +extern size_t MainStartY; + +// height of main window +extern size_t MainHeight; + +// indicates whether messages from Statusbar::msg function should be shown +extern bool ShowMessages; + +// indicates whether seeking action in currently in progress +extern bool SeekingInProgress; + +// string that represents volume in right top corner. being global +// to be used for calculating width offsets in various files. +extern std::string VolumeState; + +// global timer +extern timeval Timer; + } #endif diff --git a/src/help.h b/src/help.h index 66537060..a2b322de 100644 --- a/src/help.h +++ b/src/help.h @@ -24,36 +24,35 @@ #include "actions.h" #include "screen.h" -class Help : public Screen +struct Help : public Screen { - public: - virtual void resize() OVERRIDE; - virtual void switchTo() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE { } - - virtual void enterPressed() OVERRIDE { } - virtual void spacePressed() OVERRIDE { } - - virtual bool isTabbable() OVERRIDE { return true; } - virtual bool isMergable() OVERRIDE { return true; } - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return true; } - - private: - void KeysSection(const char *title) { Section("Keys", title); } - void MouseSection(const char *title) { Section("Mouse", title); } - void Section(const char *type, const char *title); - void KeyDesc(const ActionType at, const char *desc); - void MouseDesc(std::string action, const char *desc, bool indent = false); - void MouseColumn(const char *column); - - std::string DisplayKeys(const ActionType at); - void GetKeybindings(); + virtual void resize() OVERRIDE; + virtual void switchTo() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE { } + + virtual void enterPressed() OVERRIDE { } + virtual void spacePressed() OVERRIDE { } + + virtual bool isTabbable() OVERRIDE { return true; } + virtual bool isMergable() OVERRIDE { return true; } + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return true; } + +private: + void KeysSection(const char *title) { Section("Keys", title); } + void MouseSection(const char *title) { Section("Mouse", title); } + void Section(const char *type, const char *title); + void KeyDesc(const ActionType at, const char *desc); + void MouseDesc(std::string action, const char *desc, bool indent = false); + void MouseColumn(const char *column); + + std::string DisplayKeys(const ActionType at); + void GetKeybindings(); }; extern Help *myHelp; diff --git a/src/lastfm.h b/src/lastfm.h index f0e7e409..349b3177 100644 --- a/src/lastfm.h +++ b/src/lastfm.h @@ -31,57 +31,56 @@ #include "lastfm_service.h" #include "screen.h" -class Lastfm : public Screen +struct Lastfm : public Screen { - public: - Lastfm() : isReadyToTake(0), isDownloadInProgress(0) { } - - // Screen - virtual void switchTo() OVERRIDE; - virtual void resize() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE; - - virtual void enterPressed() OVERRIDE { } - virtual void spacePressed() OVERRIDE { } - - virtual bool isMergable() OVERRIDE { return true; } - virtual bool isTabbable() OVERRIDE { return false; } - - // private members - void Refetch(); - - bool isDownloading() { return isDownloadInProgress && !isReadyToTake; } - bool SetArtistInfoArgs(const std::string &artist, const std::string &lang = ""); - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return false; } - - private: - std::wstring itsTitle; - - std::string itsArtist; - std::string itsFilename; - - std::string itsFolder; - - std::auto_ptr itsService; - LastfmService::Args itsArgs; - - void Load(); - void Save(const std::string &data); - void SetTitleAndFolder(); - - void Download(); - static void *DownloadWrapper(void *); - - void Take(); - bool isReadyToTake; - bool isDownloadInProgress; - pthread_t itsDownloader; + Lastfm() : isReadyToTake(0), isDownloadInProgress(0) { } + + // Screen + virtual void switchTo() OVERRIDE; + virtual void resize() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE; + + virtual void enterPressed() OVERRIDE { } + virtual void spacePressed() OVERRIDE { } + + virtual bool isMergable() OVERRIDE { return true; } + virtual bool isTabbable() OVERRIDE { return false; } + + // private members + void Refetch(); + + bool isDownloading() { return isDownloadInProgress && !isReadyToTake; } + bool SetArtistInfoArgs(const std::string &artist, const std::string &lang = ""); + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return false; } + +private: + std::wstring itsTitle; + + std::string itsArtist; + std::string itsFilename; + + std::string itsFolder; + + std::auto_ptr itsService; + LastfmService::Args itsArgs; + + void Load(); + void Save(const std::string &data); + void SetTitleAndFolder(); + + void Download(); + static void *DownloadWrapper(void *); + + void Take(); + bool isReadyToTake; + bool isDownloadInProgress; + pthread_t itsDownloader; }; extern Lastfm *myLastfm; diff --git a/src/lastfm_service.h b/src/lastfm_service.h index e49c7685..14cb9936 100644 --- a/src/lastfm_service.h +++ b/src/lastfm_service.h @@ -41,16 +41,16 @@ struct LastfmService virtual bool checkArgs(const Args &args) = 0; virtual void colorizeOutput(NC::Scrollpad &w) = 0; - protected: - virtual bool actionFailed(const std::string &data); - - virtual bool parse(std::string &data) = 0; - virtual void postProcess(std::string &data); - - virtual const char *methodName() = 0; - - static const char *baseURL; - static const char *msgParseFailed; +protected: + virtual bool actionFailed(const std::string &data); + + virtual bool parse(std::string &data) = 0; + virtual void postProcess(std::string &data); + + virtual const char *methodName() = 0; + + static const char *baseURL; + static const char *msgParseFailed; }; struct ArtistInfo : public LastfmService @@ -60,10 +60,10 @@ struct ArtistInfo : public LastfmService virtual bool checkArgs(const Args &args); virtual void colorizeOutput(NC::Scrollpad &w); - protected: - virtual bool parse(std::string &data); - - virtual const char *methodName() { return "artist.getinfo"; } +protected: + virtual bool parse(std::string &data); + + virtual const char *methodName() { return "artist.getinfo"; } }; #endif // HAVE_CURL_CURL_H diff --git a/src/lyrics.h b/src/lyrics.h index aa980c89..209d8aab 100644 --- a/src/lyrics.h +++ b/src/lyrics.h @@ -28,78 +28,77 @@ #include "screen.h" #include "lyrics_fetcher.h" -class Lyrics : public Screen +struct Lyrics : public Screen { - public: - Lyrics() : ReloadNP(0), -# ifdef HAVE_CURL_CURL_H - isReadyToTake(0), isDownloadInProgress(0), -# endif // HAVE_CURL_CURL_H - itsScrollBegin(0) { } - - // Screen implementation - virtual void resize() OVERRIDE; - virtual void switchTo() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE; - - virtual void enterPressed() OVERRIDE { } - virtual void spacePressed() OVERRIDE; - - virtual bool isMergable() OVERRIDE { return true; } - virtual bool isTabbable() OVERRIDE { return false; } - - // private members - void Edit(); - -# ifdef HAVE_CURL_CURL_H - void Refetch(); - - static void ToggleFetcher(); - static void DownloadInBackground(const MPD::Song &s); -# endif // HAVE_CURL_CURL_H - - bool ReloadNP; - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return false; } - - private: - void Load(); - -# ifdef HAVE_CURL_CURL_H - static void *DownloadInBackgroundImpl(void *song_ptr); - static void DownloadInBackgroundImplHelper(const MPD::Song &s); - // lock for allowing exclusive access to itsToDownload and itsWorkersNumber - static pthread_mutex_t itsDIBLock; - // storage for songs for which lyrics are scheduled to be downloaded - static std::queue itsToDownload; - // current worker threads (ie. downloading lyrics) - static size_t itsWorkersNumber; - // maximum number of worker threads. if it's reached, next lyrics requests - // are put into itsToDownload queue. - static const size_t itsMaxWorkersNumber = 4; - - void *Download(); - static void *DownloadWrapper(void *); - static void Save(const std::string &filename, const std::string &lyrics); - - void Take(); - bool isReadyToTake; - bool isDownloadInProgress; - pthread_t itsDownloader; - - static LyricsFetcher **itsFetcher; -# endif // HAVE_CURL_CURL_H - - size_t itsScrollBegin; - MPD::Song itsSong; - std::string itsFilename; - - static std::string GenerateFilename(const MPD::Song &s); + Lyrics() : ReloadNP(0), +# ifdef HAVE_CURL_CURL_H + isReadyToTake(0), isDownloadInProgress(0), +# endif // HAVE_CURL_CURL_H + itsScrollBegin(0) { } + + // Screen implementation + virtual void resize() OVERRIDE; + virtual void switchTo() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE; + + virtual void enterPressed() OVERRIDE { } + virtual void spacePressed() OVERRIDE; + + virtual bool isMergable() OVERRIDE { return true; } + virtual bool isTabbable() OVERRIDE { return false; } + + // private members + void Edit(); + +# ifdef HAVE_CURL_CURL_H + void Refetch(); + + static void ToggleFetcher(); + static void DownloadInBackground(const MPD::Song &s); +# endif // HAVE_CURL_CURL_H + + bool ReloadNP; + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return false; } + +private: + void Load(); + +# ifdef HAVE_CURL_CURL_H + static void *DownloadInBackgroundImpl(void *song_ptr); + static void DownloadInBackgroundImplHelper(const MPD::Song &s); + // lock for allowing exclusive access to itsToDownload and itsWorkersNumber + static pthread_mutex_t itsDIBLock; + // storage for songs for which lyrics are scheduled to be downloaded + static std::queue itsToDownload; + // current worker threads (ie. downloading lyrics) + static size_t itsWorkersNumber; + // maximum number of worker threads. if it's reached, next lyrics requests + // are put into itsToDownload queue. + static const size_t itsMaxWorkersNumber = 4; + + void *Download(); + static void *DownloadWrapper(void *); + static void Save(const std::string &filename, const std::string &lyrics); + + void Take(); + bool isReadyToTake; + bool isDownloadInProgress; + pthread_t itsDownloader; + + static LyricsFetcher **itsFetcher; +# endif // HAVE_CURL_CURL_H + + size_t itsScrollBegin; + MPD::Song itsSong; + std::string itsFilename; + + static std::string GenerateFilename(const MPD::Song &s); }; extern Lyrics *myLyrics; diff --git a/src/lyrics_fetcher.h b/src/lyrics_fetcher.h index c6b88cc0..5ac60bc4 100644 --- a/src/lyrics_fetcher.h +++ b/src/lyrics_fetcher.h @@ -34,27 +34,27 @@ struct LyricsFetcher virtual const char *name() = 0; virtual Result fetch(const std::string &artist, const std::string &title); - protected: - virtual const char *getURL() = 0; - virtual const char *getOpenTag() = 0; - virtual const char *getCloseTag() = 0; - - virtual bool notLyrics(const std::string &) { return false; } - virtual void postProcess(std::string &data); - - bool getContent(const char *open_tag, const char *close_tag, std::string &data); - - static const char msgNotFound[]; +protected: + virtual const char *getURL() = 0; + virtual const char *getOpenTag() = 0; + virtual const char *getCloseTag() = 0; + + virtual bool notLyrics(const std::string &) { return false; } + virtual void postProcess(std::string &data); + + bool getContent(const char *open_tag, const char *close_tag, std::string &data); + + static const char msgNotFound[]; }; struct LyrcComArFetcher : public LyricsFetcher { virtual const char *name() { return "lyrc.com.ar"; } - protected: - virtual const char *getURL() { return "http://lyrc.com.ar/tema1es.php?artist=%artist%&songname=%title%"; } - virtual const char *getOpenTag() { return ""; } - virtual const char *getCloseTag() { return "

"; } +protected: + virtual const char *getURL() { return "http://lyrc.com.ar/tema1es.php?artist=%artist%&songname=%title%"; } + virtual const char *getOpenTag() { return ""; } + virtual const char *getCloseTag() { return "

"; } }; struct LyricwikiFetcher : public LyricsFetcher @@ -62,12 +62,12 @@ struct LyricwikiFetcher : public LyricsFetcher virtual const char *name() { return "lyricwiki.com"; } virtual Result fetch(const std::string &artist, const std::string &title); - protected: - virtual const char *getURL() { return "http://lyrics.wikia.com/api.php?action=lyrics&fmt=xml&func=getSong&artist=%artist%&song=%title%"; } - virtual const char *getOpenTag() { return ""; } - virtual const char *getCloseTag() { return ""; } - - virtual bool notLyrics(const std::string &data); +protected: + virtual const char *getURL() { return "http://lyrics.wikia.com/api.php?action=lyrics&fmt=xml&func=getSong&artist=%artist%&song=%title%"; } + virtual const char *getOpenTag() { return ""; } + virtual const char *getCloseTag() { return ""; } + + virtual bool notLyrics(const std::string &data); }; /**********************************************************************/ @@ -76,118 +76,118 @@ struct GoogleLyricsFetcher : public LyricsFetcher { virtual Result fetch(const std::string &artist, const std::string &title); - protected: - virtual const char *getSiteKeyword() = 0; - virtual const char *getURL() { return URL; } - - virtual bool isURLOk(const std::string &url); - - private: - const char *URL; +protected: + virtual const char *getSiteKeyword() = 0; + virtual const char *getURL() { return URL; } + + virtual bool isURLOk(const std::string &url); + +private: + const char *URL; }; struct LyricstimeFetcher : public GoogleLyricsFetcher { virtual const char *name() { return "lyricstime.com"; } - protected: - virtual const char *getSiteKeyword() { return "lyricstime"; } - virtual const char *getOpenTag() { return "

"; } - virtual const char *getCloseTag() { return "
"; } - - virtual bool isURLOk(const std::string &url); - - virtual void postProcess(std::string &data); +protected: + virtual const char *getSiteKeyword() { return "lyricstime"; } + virtual const char *getOpenTag() { return "
"; } + virtual const char *getCloseTag() { return "
"; } + + virtual bool isURLOk(const std::string &url); + + virtual void postProcess(std::string &data); }; struct MetrolyricsFetcher : public GoogleLyricsFetcher { virtual const char *name() { return "metrolyrics.com"; } - protected: - virtual const char *getSiteKeyword() { return "metrolyrics"; } - virtual const char *getOpenTag() { return "
"; } - virtual const char *getCloseTag() { return "
"; } - - virtual bool isURLOk(const std::string &url); - - virtual void postProcess(std::string &data); +protected: + virtual const char *getSiteKeyword() { return "metrolyrics"; } + virtual const char *getOpenTag() { return "
"; } + virtual const char *getCloseTag() { return "
"; } + + virtual bool isURLOk(const std::string &url); + + virtual void postProcess(std::string &data); }; struct LyricsmaniaFetcher : public GoogleLyricsFetcher { virtual const char *name() { return "lyricsmania.com"; } - protected: - virtual const char *getSiteKeyword() { return "lyricsmania"; } - virtual const char *getOpenTag() { return " :
"; } - virtual const char *getCloseTag() { return "[ :
"; } + virtual const char *getCloseTag() { return "[ "; } - virtual const char *getCloseTag() { return "

"; } - - virtual void postProcess(std::string &data); +protected: + virtual const char *getSiteKeyword() { return "songlyrics"; } + virtual const char *getOpenTag() { return "-6000px;\">"; } + virtual const char *getCloseTag() { return "

"; } + + virtual void postProcess(std::string &data); }; struct LyriczzFetcher : public GoogleLyricsFetcher { virtual const char *name() { return "lyriczz.com"; } - protected: - virtual const char *getSiteKeyword() { return "lyriczz"; } - virtual const char *getOpenTag() { return "border=0 />"; } - virtual const char *getCloseTag() { return ""; } + virtual const char *getCloseTag() { return "
"; } - virtual const char *getCloseTag() { return "

"; } + virtual const char *getCloseTag() { return "
"; } - virtual const char *getCloseTag() { return ""; } - - virtual void postProcess(std::string &data); +protected: + virtual const char *getSiteKeyword() { return "lyricsvip"; } + virtual const char *getOpenTag() { return ""; } + virtual const char *getCloseTag() { return ""; } + + virtual void postProcess(std::string &data); }; struct JustSomeLyricsFetcher : public GoogleLyricsFetcher { virtual const char *name() { return "justsomelyrics.com"; } - protected: - virtual const char *getSiteKeyword() { return "justsomelyrics"; } - virtual const char *getOpenTag() { return "alt=\"phone\" />\n
"; } - virtual const char *getCloseTag() { return "
"; } +protected: + virtual const char *getSiteKeyword() { return "justsomelyrics"; } + virtual const char *getOpenTag() { return "alt=\"phone\" />\n
"; } + virtual const char *getCloseTag() { return "
"; } }; struct LoloLyricsFetcher : public GoogleLyricsFetcher { virtual const char *name() { return "lololyrics.com"; } - protected: - virtual const char *getSiteKeyword() { return "lololyrics"; } - virtual const char *getOpenTag() { return "
"; } - virtual const char *getCloseTag() { return "
"; } +protected: + virtual const char *getSiteKeyword() { return "lololyrics"; } + virtual const char *getOpenTag() { return "
"; } + virtual const char *getCloseTag() { return "
"; } }; struct InternetLyricsFetcher : public GoogleLyricsFetcher @@ -195,15 +195,15 @@ struct InternetLyricsFetcher : public GoogleLyricsFetcher virtual const char *name() { return "the Internet"; } virtual Result fetch(const std::string &artist, const std::string &title); - protected: - virtual const char *getSiteKeyword() { return "lyrics"; } - virtual const char *getOpenTag() { return ""; } - virtual const char *getCloseTag() { return ""; } - - virtual bool isURLOk(const std::string &url); - - private: - std::string URL; +protected: + virtual const char *getSiteKeyword() { return "lyrics"; } + virtual const char *getOpenTag() { return ""; } + virtual const char *getCloseTag() { return ""; } + + virtual bool isURLOk(const std::string &url); + +private: + std::string URL; }; extern LyricsFetcher *lyricsPlugins[]; diff --git a/src/media_library.h b/src/media_library.h index 6359da57..090f7ded 100644 --- a/src/media_library.h +++ b/src/media_library.h @@ -24,77 +24,76 @@ #include "interfaces.h" #include "screen.h" -class MediaLibrary : public Screen, public Filterable, public HasColumns, public HasSongs, public Searchable +struct MediaLibrary : public Screen, public Filterable, public HasColumns, public HasSongs, public Searchable { - public: - virtual void switchTo() OVERRIDE; - virtual void resize() OVERRIDE; + virtual void switchTo() OVERRIDE; + virtual void resize() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void refresh() OVERRIDE; + virtual void update() OVERRIDE; + + virtual void enterPressed() OVERRIDE; + virtual void spacePressed() OVERRIDE; + virtual void mouseButtonPressed(MEVENT me) OVERRIDE; + + virtual bool isTabbable() OVERRIDE { return true; } + virtual bool isMergable() OVERRIDE { return true; } + + // Filterable implementation + virtual bool allowsFiltering() OVERRIDE; + virtual std::string currentFilter() OVERRIDE; + virtual void applyFilter(const std::string &filter) OVERRIDE; + + // Searchable implementation + virtual bool allowsSearching() OVERRIDE; + virtual bool search(const std::string &constraint) OVERRIDE; + virtual void nextFound(bool wrap) OVERRIDE; + virtual void prevFound(bool wrap) OVERRIDE; + + // HasSongs implementation + virtual std::shared_ptr getProxySongList() OVERRIDE; + + virtual bool allowsSelection() OVERRIDE; + virtual void reverseSelection() OVERRIDE; + virtual MPD::SongList getSelectedSongs() OVERRIDE; + + // HasColumns implementation + virtual bool previousColumnAvailable() OVERRIDE; + virtual void previousColumn() OVERRIDE; + + virtual bool nextColumnAvailable() OVERRIDE; + virtual void nextColumn() OVERRIDE; + + // private members + int Columns(); + void LocateSong(const MPD::Song &); + std::shared_ptr songsProxyList(); + + struct SearchConstraints + { + SearchConstraints() { } + SearchConstraints(const std::string &tag, const std::string &album, const std::string &date) + : PrimaryTag(tag), Album(album), Date(date) { } + SearchConstraints(const std::string &album, const std::string &date) + : Album(album), Date(date) { } - virtual std::wstring title() OVERRIDE; - - virtual void refresh() OVERRIDE; - virtual void update() OVERRIDE; - - virtual void enterPressed() OVERRIDE; - virtual void spacePressed() OVERRIDE; - virtual void mouseButtonPressed(MEVENT me) OVERRIDE; - - virtual bool isTabbable() OVERRIDE { return true; } - virtual bool isMergable() OVERRIDE { return true; } - - // Filterable implementation - virtual bool allowsFiltering() OVERRIDE; - virtual std::string currentFilter() OVERRIDE; - virtual void applyFilter(const std::string &filter) OVERRIDE; - - // Searchable implementation - virtual bool allowsSearching() OVERRIDE; - virtual bool search(const std::string &constraint) OVERRIDE; - virtual void nextFound(bool wrap) OVERRIDE; - virtual void prevFound(bool wrap) OVERRIDE; - - // HasSongs implementation - virtual std::shared_ptr getProxySongList() OVERRIDE; - - virtual bool allowsSelection() OVERRIDE; - virtual void reverseSelection() OVERRIDE; - virtual MPD::SongList getSelectedSongs() OVERRIDE; - - // HasColumns implementation - virtual bool previousColumnAvailable() OVERRIDE; - virtual void previousColumn() OVERRIDE; - - virtual bool nextColumnAvailable() OVERRIDE; - virtual void nextColumn() OVERRIDE; - - // private members - int Columns(); - void LocateSong(const MPD::Song &); - std::shared_ptr songsProxyList(); - - struct SearchConstraints - { - SearchConstraints() { } - SearchConstraints(const std::string &tag, const std::string &album, const std::string &date) - : PrimaryTag(tag), Album(album), Date(date) { } - SearchConstraints(const std::string &album, const std::string &date) - : Album(album), Date(date) { } - - std::string PrimaryTag; - std::string Album; - std::string Date; - }; - - NC::Menu *Tags; - NC::Menu *Albums; - NC::Menu *Songs; - - protected: - virtual void init(); - virtual bool isLockable() { return true; } - - private: - void AddToPlaylist(bool); + std::string PrimaryTag; + std::string Album; + std::string Date; + }; + + NC::Menu *Tags; + NC::Menu *Albums; + NC::Menu *Songs; + +protected: + virtual void init(); + virtual bool isLockable() { return true; } + +private: + void AddToPlaylist(bool); }; extern MediaLibrary *myLibrary; diff --git a/src/outputs.h b/src/outputs.h index 8954f6fa..1145a65e 100644 --- a/src/outputs.h +++ b/src/outputs.h @@ -29,31 +29,29 @@ #include "mpdpp.h" #include "screen.h" -class Outputs : public Screen< NC::Menu > +struct Outputs : public Screen< NC::Menu > { - public: - - // Screen< NC::Menu > implementation - virtual void switchTo() OVERRIDE; - virtual void resize() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE { } - - virtual void enterPressed() OVERRIDE; - virtual void spacePressed() OVERRIDE { } - virtual void mouseButtonPressed(MEVENT me) OVERRIDE; - - virtual bool isTabbable() OVERRIDE { return true; } - virtual bool isMergable() OVERRIDE { return true; } - - // private members - void FetchList(); - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return true; } + // Screen< NC::Menu > implementation + virtual void switchTo() OVERRIDE; + virtual void resize() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE { } + + virtual void enterPressed() OVERRIDE; + virtual void spacePressed() OVERRIDE { } + virtual void mouseButtonPressed(MEVENT me) OVERRIDE; + + virtual bool isTabbable() OVERRIDE { return true; } + virtual bool isMergable() OVERRIDE { return true; } + + // private members + void FetchList(); + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return true; } }; extern Outputs *myOutputs; diff --git a/src/playlist.h b/src/playlist.h index f024e72e..4a02e408 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -27,84 +27,83 @@ #include "screen.h" #include "song.h" -class Playlist : public Screen>, public Filterable, public HasSongs, public Searchable +struct Playlist : public Screen>, public Filterable, public HasSongs, public Searchable { - public: - Playlist() : itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0) { } - ~Playlist() { } - - // Screen> implementation - virtual void switchTo() OVERRIDE; - virtual void resize() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE { } - - virtual void enterPressed() OVERRIDE; - virtual void spacePressed() OVERRIDE; - virtual void mouseButtonPressed(MEVENT me) OVERRIDE; - - virtual bool isTabbable() OVERRIDE { return true; } - virtual bool isMergable() OVERRIDE { return true; } - - // Filterable implementation - virtual bool allowsFiltering() OVERRIDE; - virtual std::string currentFilter() OVERRIDE; - virtual void applyFilter(const std::string &filter) OVERRIDE; - - // Searchable implementation - virtual bool allowsSearching(); - virtual bool search(const std::string &constraint) OVERRIDE; - virtual void nextFound(bool wrap) OVERRIDE; - virtual void prevFound(bool wrap) OVERRIDE; - - // HasSongs implementation - virtual std::shared_ptr getProxySongList() OVERRIDE; - - virtual bool allowsSelection() OVERRIDE; - virtual void reverseSelection() OVERRIDE; - virtual MPD::SongList getSelectedSongs() OVERRIDE; - - // private members - MPD::Song nowPlayingSong(); - - bool isFiltered(); - void Reverse(); - - void EnableHighlighting(); - void UpdateTimer(); - timeval Timer() const { return itsTimer; } - - bool Add(const MPD::Song &s, bool play, int position = -1); - bool Add(const MPD::SongList &l, bool play, int position = -1); - void PlayNewlyAddedSongs(); - - void SetSelectedItemsPriority(int prio); - - bool checkForSong(const MPD::Song &s); - - void registerHash(size_t hash); - void unregisterHash(size_t hash); - - static bool ReloadTotalLength; - static bool ReloadRemaining; - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return true; } - - private: - std::string TotalLength(); - std::string itsBufferedStats; - - std::map itsSongHashes; - - size_t itsTotalLength; - size_t itsRemainingTime; - size_t itsScrollBegin; - - timeval itsTimer; + Playlist() : itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0) { } + ~Playlist() { } + + // Screen> implementation + virtual void switchTo() OVERRIDE; + virtual void resize() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE { } + + virtual void enterPressed() OVERRIDE; + virtual void spacePressed() OVERRIDE; + virtual void mouseButtonPressed(MEVENT me) OVERRIDE; + + virtual bool isTabbable() OVERRIDE { return true; } + virtual bool isMergable() OVERRIDE { return true; } + + // Filterable implementation + virtual bool allowsFiltering() OVERRIDE; + virtual std::string currentFilter() OVERRIDE; + virtual void applyFilter(const std::string &filter) OVERRIDE; + + // Searchable implementation + virtual bool allowsSearching(); + virtual bool search(const std::string &constraint) OVERRIDE; + virtual void nextFound(bool wrap) OVERRIDE; + virtual void prevFound(bool wrap) OVERRIDE; + + // HasSongs implementation + virtual std::shared_ptr getProxySongList() OVERRIDE; + + virtual bool allowsSelection() OVERRIDE; + virtual void reverseSelection() OVERRIDE; + virtual MPD::SongList getSelectedSongs() OVERRIDE; + + // private members + MPD::Song nowPlayingSong(); + + bool isFiltered(); + void Reverse(); + + void EnableHighlighting(); + void UpdateTimer(); + timeval Timer() const { return itsTimer; } + + bool Add(const MPD::Song &s, bool play, int position = -1); + bool Add(const MPD::SongList &l, bool play, int position = -1); + void PlayNewlyAddedSongs(); + + void SetSelectedItemsPriority(int prio); + + bool checkForSong(const MPD::Song &s); + + void registerHash(size_t hash); + void unregisterHash(size_t hash); + + static bool ReloadTotalLength; + static bool ReloadRemaining; + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return true; } + +private: + std::string TotalLength(); + std::string itsBufferedStats; + + std::map itsSongHashes; + + size_t itsTotalLength; + size_t itsRemainingTime; + size_t itsScrollBegin; + + timeval itsTimer; }; extern Playlist *myPlaylist; diff --git a/src/playlist_editor.h b/src/playlist_editor.h index 7e6d37fe..7ca9f7ce 100644 --- a/src/playlist_editor.h +++ b/src/playlist_editor.h @@ -24,69 +24,68 @@ #include "interfaces.h" #include "screen.h" -class PlaylistEditor : public Screen, public Filterable, public HasColumns, public HasSongs, public Searchable +struct PlaylistEditor : public Screen, public Filterable, public HasColumns, public HasSongs, public Searchable { - public: - virtual void switchTo() OVERRIDE; - virtual void resize() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void refresh() OVERRIDE; - virtual void update() OVERRIDE; - - virtual void enterPressed() OVERRIDE; - virtual void spacePressed() OVERRIDE; - virtual void mouseButtonPressed(MEVENT me) OVERRIDE; - - virtual bool isTabbable() OVERRIDE { return true; } - virtual bool isMergable() OVERRIDE { return true; } - - // Filterable implementation - virtual bool allowsFiltering() OVERRIDE; - virtual std::string currentFilter() OVERRIDE; - virtual void applyFilter(const std::string &filter) OVERRIDE; - - // Searchable implementation - virtual bool allowsSearching() OVERRIDE; - virtual bool search(const std::string &constraint) OVERRIDE; - virtual void nextFound(bool wrap) OVERRIDE; - virtual void prevFound(bool wrap) OVERRIDE; - - // HasSongs implementation - virtual std::shared_ptr getProxySongList() OVERRIDE; - - virtual bool allowsSelection() OVERRIDE; - virtual void reverseSelection() OVERRIDE; - virtual MPD::SongList getSelectedSongs() OVERRIDE; - - // HasColumns implementation - virtual bool previousColumnAvailable() OVERRIDE; - virtual void previousColumn() OVERRIDE; - - virtual bool nextColumnAvailable() OVERRIDE; - virtual void nextColumn() OVERRIDE; - - // private members - void requestPlaylistsUpdate() { playlistsUpdateRequested = true; } - void requestContentsUpdate() { contentUpdateRequested = true; } - - virtual void Locate(const std::string &); - bool isContentFiltered(); - std::shared_ptr contentProxyList(); - - NC::Menu *Playlists; - NC::Menu *Content; - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return true; } - - private: - void AddToPlaylist(bool); - - bool playlistsUpdateRequested; - bool contentUpdateRequested; + virtual void switchTo() OVERRIDE; + virtual void resize() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void refresh() OVERRIDE; + virtual void update() OVERRIDE; + + virtual void enterPressed() OVERRIDE; + virtual void spacePressed() OVERRIDE; + virtual void mouseButtonPressed(MEVENT me) OVERRIDE; + + virtual bool isTabbable() OVERRIDE { return true; } + virtual bool isMergable() OVERRIDE { return true; } + + // Filterable implementation + virtual bool allowsFiltering() OVERRIDE; + virtual std::string currentFilter() OVERRIDE; + virtual void applyFilter(const std::string &filter) OVERRIDE; + + // Searchable implementation + virtual bool allowsSearching() OVERRIDE; + virtual bool search(const std::string &constraint) OVERRIDE; + virtual void nextFound(bool wrap) OVERRIDE; + virtual void prevFound(bool wrap) OVERRIDE; + + // HasSongs implementation + virtual std::shared_ptr getProxySongList() OVERRIDE; + + virtual bool allowsSelection() OVERRIDE; + virtual void reverseSelection() OVERRIDE; + virtual MPD::SongList getSelectedSongs() OVERRIDE; + + // HasColumns implementation + virtual bool previousColumnAvailable() OVERRIDE; + virtual void previousColumn() OVERRIDE; + + virtual bool nextColumnAvailable() OVERRIDE; + virtual void nextColumn() OVERRIDE; + + // private members + void requestPlaylistsUpdate() { playlistsUpdateRequested = true; } + void requestContentsUpdate() { contentUpdateRequested = true; } + + virtual void Locate(const std::string &); + bool isContentFiltered(); + std::shared_ptr contentProxyList(); + + NC::Menu *Playlists; + NC::Menu *Content; + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return true; } + +private: + void AddToPlaylist(bool); + + bool playlistsUpdateRequested; + bool contentUpdateRequested; }; extern PlaylistEditor *myPlaylistEditor; diff --git a/src/search_engine.h b/src/search_engine.h index 058caaab..785fcf1c 100644 --- a/src/search_engine.h +++ b/src/search_engine.h @@ -73,66 +73,65 @@ struct SEItem MPD::Song itsSong; }; -class SearchEngine : public Screen< NC::Menu >, public Filterable, public HasSongs, public Searchable +struct SearchEngine : public Screen< NC::Menu >, public Filterable, public HasSongs, public Searchable { - public: - // Screen< NC::Menu > implementation - virtual void resize() OVERRIDE; - virtual void switchTo() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE { } - - virtual void enterPressed() OVERRIDE; - virtual void spacePressed() OVERRIDE; - virtual void mouseButtonPressed(MEVENT me) OVERRIDE; - - virtual bool isTabbable() OVERRIDE { return true; } - virtual bool isMergable() OVERRIDE { return true; } - - // Filterable implementation - virtual bool allowsFiltering() OVERRIDE; - virtual std::string currentFilter() OVERRIDE; - virtual void applyFilter(const std::string &filter) OVERRIDE; - - // Searchable implementation - virtual bool allowsSearching() OVERRIDE; - virtual bool search(const std::string &constraint) OVERRIDE; - virtual void nextFound(bool wrap) OVERRIDE; - virtual void prevFound(bool wrap) OVERRIDE; - - // HasSongs implementation - virtual std::shared_ptr getProxySongList() OVERRIDE; - - virtual bool allowsSelection() OVERRIDE; - virtual void reverseSelection() OVERRIDE; - virtual MPD::SongList getSelectedSongs() OVERRIDE; - - // private members - - static size_t StaticOptions; - static size_t SearchButton; - static size_t ResetButton; - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return true; } - - private: - void Prepare(); - void Search(); - void reset(); - - const char **SearchMode; - - static const char *SearchModes[]; - - static const size_t ConstraintsNumber = 11; - static const char *ConstraintsNames[]; - std::string itsConstraints[ConstraintsNumber]; - - static bool MatchToPattern; + // Screen< NC::Menu > implementation + virtual void resize() OVERRIDE; + virtual void switchTo() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE { } + + virtual void enterPressed() OVERRIDE; + virtual void spacePressed() OVERRIDE; + virtual void mouseButtonPressed(MEVENT me) OVERRIDE; + + virtual bool isTabbable() OVERRIDE { return true; } + virtual bool isMergable() OVERRIDE { return true; } + + // Filterable implementation + virtual bool allowsFiltering() OVERRIDE; + virtual std::string currentFilter() OVERRIDE; + virtual void applyFilter(const std::string &filter) OVERRIDE; + + // Searchable implementation + virtual bool allowsSearching() OVERRIDE; + virtual bool search(const std::string &constraint) OVERRIDE; + virtual void nextFound(bool wrap) OVERRIDE; + virtual void prevFound(bool wrap) OVERRIDE; + + // HasSongs implementation + virtual std::shared_ptr getProxySongList() OVERRIDE; + + virtual bool allowsSelection() OVERRIDE; + virtual void reverseSelection() OVERRIDE; + virtual MPD::SongList getSelectedSongs() OVERRIDE; + + // private members + + static size_t StaticOptions; + static size_t SearchButton; + static size_t ResetButton; + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return true; } + +private: + void Prepare(); + void Search(); + void reset(); + + const char **SearchMode; + + static const char *SearchModes[]; + + static const size_t ConstraintsNumber = 11; + static const char *ConstraintsNames[]; + std::string itsConstraints[ConstraintsNumber]; + + static bool MatchToPattern; }; extern SearchEngine *mySearcher; diff --git a/src/sel_items_adder.h b/src/sel_items_adder.h index b83a48f3..fc620ece 100644 --- a/src/sel_items_adder.h +++ b/src/sel_items_adder.h @@ -23,42 +23,41 @@ #include "screen.h" -class SelectedItemsAdder : public Screen< NC::Menu > +struct SelectedItemsAdder : public Screen< NC::Menu > { - public: - SelectedItemsAdder() : itsPSWidth(35), itsPSHeight(11) { } - - // Screen< NC::Menu > implementation - virtual void switchTo() OVERRIDE; - virtual void resize() OVERRIDE; - virtual void refresh() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE { } - - virtual void enterPressed() OVERRIDE; - virtual void spacePressed() OVERRIDE { } - virtual void mouseButtonPressed(MEVENT me) OVERRIDE; - - virtual bool isMergable() OVERRIDE { return false; } - virtual bool isTabbable() OVERRIDE { return false; } - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return false; } - - private: - void SetDimensions(); - - NC::Menu *itsPlaylistSelector; - NC::Menu *itsPositionSelector; - - size_t itsPSWidth; - size_t itsPSHeight; - - size_t itsWidth; - size_t itsHeight; + SelectedItemsAdder() : itsPSWidth(35), itsPSHeight(11) { } + + // Screen< NC::Menu > implementation + virtual void switchTo() OVERRIDE; + virtual void resize() OVERRIDE; + virtual void refresh() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE { } + + virtual void enterPressed() OVERRIDE; + virtual void spacePressed() OVERRIDE { } + virtual void mouseButtonPressed(MEVENT me) OVERRIDE; + + virtual bool isMergable() OVERRIDE { return false; } + virtual bool isTabbable() OVERRIDE { return false; } + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return false; } + +private: + void SetDimensions(); + + NC::Menu *itsPlaylistSelector; + NC::Menu *itsPositionSelector; + + size_t itsPSWidth; + size_t itsPSHeight; + + size_t itsWidth; + size_t itsHeight; }; extern SelectedItemsAdder *mySelectedItemsAdder; diff --git a/src/server_info.h b/src/server_info.h index fbfa4c2c..f7a5eb3b 100644 --- a/src/server_info.h +++ b/src/server_info.h @@ -23,35 +23,34 @@ #include "screen.h" -class ServerInfo : public Screen +struct ServerInfo : public Screen { - public: - // Screen implementation - virtual void switchTo() OVERRIDE; - virtual void resize() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE; - - virtual void enterPressed() OVERRIDE { } - virtual void spacePressed() OVERRIDE { } - - virtual bool isMergable() OVERRIDE { return false; } - virtual bool isTabbable() OVERRIDE { return false; } - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return false; } - - private: - void SetDimensions(); - - MPD::StringList itsURLHandlers; - MPD::StringList itsTagTypes; - - size_t itsWidth; - size_t itsHeight; + // Screen implementation + virtual void switchTo() OVERRIDE; + virtual void resize() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE; + + virtual void enterPressed() OVERRIDE { } + virtual void spacePressed() OVERRIDE { } + + virtual bool isMergable() OVERRIDE { return false; } + virtual bool isTabbable() OVERRIDE { return false; } + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return false; } + +private: + void SetDimensions(); + + MPD::StringList itsURLHandlers; + MPD::StringList itsTagTypes; + + size_t itsWidth; + size_t itsHeight; }; extern ServerInfo *myServerInfo; diff --git a/src/settings.h b/src/settings.h index 9e48a08b..6a86d207 100644 --- a/src/settings.h +++ b/src/settings.h @@ -192,11 +192,11 @@ struct Configuration SortMode browser_sort_mode; - private: - void MakeProperPath(std::string &dir); - - std::string home_directory; - std::string config_file_path; +private: + void MakeProperPath(std::string &dir); + + std::string home_directory; + std::string config_file_path; }; extern Configuration Config; diff --git a/src/song.h b/src/song.h index 8338bf39..8d27f2a4 100644 --- a/src/song.h +++ b/src/song.h @@ -79,13 +79,13 @@ struct Song static const char FormatEscapeCharacter = 1; - private: - const char *getTag(mpd_tag_type type, unsigned idx) const; - std::string ParseFormat(std::string::const_iterator &it, const std::string &tags_separator, - const std::string &escape_chars) const; - - std::shared_ptr m_song; - size_t m_hash; +private: + const char *getTag(mpd_tag_type type, unsigned idx) const; + std::string ParseFormat(std::string::const_iterator &it, const std::string &tags_separator, + const std::string &escape_chars) const; + + std::shared_ptr m_song; + size_t m_hash; }; typedef std::vector SongList; diff --git a/src/song_info.h b/src/song_info.h index 0de082bd..63e8cf52 100644 --- a/src/song_info.h +++ b/src/song_info.h @@ -24,40 +24,38 @@ #include "screen.h" #include "mutable_song.h" -class SongInfo : public Screen +struct SongInfo : public Screen { - public: - struct Metadata - { - const char *Name; - MPD::Song::GetFunction Get; - MPD::MutableSong::SetFunction Set; - }; - - // Screen implementation - virtual void switchTo() OVERRIDE; - virtual void resize() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE { } - - virtual void enterPressed() OVERRIDE { } - virtual void spacePressed() OVERRIDE { } - - virtual bool isMergable() OVERRIDE { return true; } - virtual bool isTabbable() OVERRIDE { return false; } - - // private members - - static const Metadata Tags[]; - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return false; } - - private: - void PrepareSong(MPD::Song &); + struct Metadata + { + const char *Name; + MPD::Song::GetFunction Get; + MPD::MutableSong::SetFunction Set; + }; + + // Screen implementation + virtual void switchTo() OVERRIDE; + virtual void resize() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE { } + + virtual void enterPressed() OVERRIDE { } + virtual void spacePressed() OVERRIDE { } + + virtual bool isMergable() OVERRIDE { return true; } + virtual bool isTabbable() OVERRIDE { return false; } + + // private members + static const Metadata Tags[]; + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return false; } + +private: + void PrepareSong(MPD::Song &); }; extern SongInfo *mySongInfo; diff --git a/src/tag_editor.h b/src/tag_editor.h index d513aec8..3e89c8d9 100644 --- a/src/tag_editor.h +++ b/src/tag_editor.h @@ -33,77 +33,76 @@ #include "regex_filter.h" #include "screen.h" -class TagEditor : public Screen, public Filterable, public HasColumns, public HasSongs, public Searchable +struct TagEditor : public Screen, public Filterable, public HasColumns, public HasSongs, public Searchable { - public: - TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParserPreview(0), itsBrowsedDir("/") { } - - virtual void resize() OVERRIDE; - virtual void switchTo() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void refresh() OVERRIDE; - virtual void update() OVERRIDE; - - virtual void enterPressed() OVERRIDE; - virtual void spacePressed() OVERRIDE; - virtual void mouseButtonPressed(MEVENT) OVERRIDE; - - virtual bool isTabbable() OVERRIDE { return true; } - virtual bool isMergable() OVERRIDE { return true; } - - // Filterable implementation - virtual bool allowsFiltering() OVERRIDE; - virtual std::string currentFilter() OVERRIDE; - virtual void applyFilter(const std::string &filter) OVERRIDE; - - // Searchable implementation - virtual bool allowsSearching() OVERRIDE; - virtual bool search(const std::string &constraint) OVERRIDE; - virtual void nextFound(bool wrap) OVERRIDE; - virtual void prevFound(bool wrap) OVERRIDE; - - // HasSongs implementation - virtual std::shared_ptr getProxySongList() OVERRIDE; - - virtual bool allowsSelection() OVERRIDE; - virtual void reverseSelection() OVERRIDE; - virtual MPD::SongList getSelectedSongs() OVERRIDE; - - // HasColumns implementation - virtual bool previousColumnAvailable() OVERRIDE; - virtual void previousColumn() OVERRIDE; - - virtual bool nextColumnAvailable() OVERRIDE; - virtual void nextColumn() OVERRIDE; - - // private members - bool ifAnyModifiedAskForDiscarding(); - void LocateSong(const MPD::Song &s); - const std::string &CurrentDir() { return itsBrowsedDir; } - - NC::Menu< std::pair > *Dirs; - NC::Menu *TagTypes; - NC::Menu *Tags; - - protected: - virtual void init(); - virtual bool isLockable() { return true; } - - private: - void SetDimensions(size_t, size_t); - - std::vector EditedSongs; - NC::Menu *FParserDialog; - NC::Menu *FParser; - NC::Scrollpad *FParserHelper; - NC::Scrollpad *FParserLegend; - NC::Scrollpad *FParserPreview; - bool FParserUsePreview; - - std::string itsBrowsedDir; - std::string itsHighlightedDir; + TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParserPreview(0), itsBrowsedDir("/") { } + + virtual void resize() OVERRIDE; + virtual void switchTo() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void refresh() OVERRIDE; + virtual void update() OVERRIDE; + + virtual void enterPressed() OVERRIDE; + virtual void spacePressed() OVERRIDE; + virtual void mouseButtonPressed(MEVENT) OVERRIDE; + + virtual bool isTabbable() OVERRIDE { return true; } + virtual bool isMergable() OVERRIDE { return true; } + + // Filterable implementation + virtual bool allowsFiltering() OVERRIDE; + virtual std::string currentFilter() OVERRIDE; + virtual void applyFilter(const std::string &filter) OVERRIDE; + + // Searchable implementation + virtual bool allowsSearching() OVERRIDE; + virtual bool search(const std::string &constraint) OVERRIDE; + virtual void nextFound(bool wrap) OVERRIDE; + virtual void prevFound(bool wrap) OVERRIDE; + + // HasSongs implementation + virtual std::shared_ptr getProxySongList() OVERRIDE; + + virtual bool allowsSelection() OVERRIDE; + virtual void reverseSelection() OVERRIDE; + virtual MPD::SongList getSelectedSongs() OVERRIDE; + + // HasColumns implementation + virtual bool previousColumnAvailable() OVERRIDE; + virtual void previousColumn() OVERRIDE; + + virtual bool nextColumnAvailable() OVERRIDE; + virtual void nextColumn() OVERRIDE; + + // private members + bool ifAnyModifiedAskForDiscarding(); + void LocateSong(const MPD::Song &s); + const std::string &CurrentDir() { return itsBrowsedDir; } + + NC::Menu< std::pair > *Dirs; + NC::Menu *TagTypes; + NC::Menu *Tags; + +protected: + virtual void init(); + virtual bool isLockable() { return true; } + +private: + void SetDimensions(size_t, size_t); + + std::vector EditedSongs; + NC::Menu *FParserDialog; + NC::Menu *FParser; + NC::Scrollpad *FParserHelper; + NC::Scrollpad *FParserLegend; + NC::Scrollpad *FParserPreview; + bool FParserUsePreview; + + std::string itsBrowsedDir; + std::string itsHighlightedDir; }; extern TagEditor *myTagEditor; diff --git a/src/tiny_tag_editor.h b/src/tiny_tag_editor.h index b77daffa..4d177801 100644 --- a/src/tiny_tag_editor.h +++ b/src/tiny_tag_editor.h @@ -28,34 +28,33 @@ #include "mutable_song.h" #include "screen.h" -class TinyTagEditor : public Screen< NC::Menu > +struct TinyTagEditor : public Screen< NC::Menu > { - public: - // Screen< NC::Menu > implementation - virtual void resize() OVERRIDE; - virtual void switchTo() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE { } - - virtual void enterPressed() OVERRIDE; - virtual void spacePressed() OVERRIDE { } - virtual void mouseButtonPressed(MEVENT me) OVERRIDE; - - virtual bool isMergable() OVERRIDE { return true; } - virtual bool isTabbable() OVERRIDE { return false; } - - // private members - void SetEdited(const MPD::Song &); - - protected: - virtual void init() OVERRIDE; - virtual bool isLockable() OVERRIDE { return true; } - - private: - bool getTags(); - MPD::MutableSong itsEdited; + // Screen< NC::Menu > implementation + virtual void resize() OVERRIDE; + virtual void switchTo() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE { } + + virtual void enterPressed() OVERRIDE; + virtual void spacePressed() OVERRIDE { } + virtual void mouseButtonPressed(MEVENT me) OVERRIDE; + + virtual bool isMergable() OVERRIDE { return true; } + virtual bool isTabbable() OVERRIDE { return false; } + + // private members + void SetEdited(const MPD::Song &); + +protected: + virtual void init() OVERRIDE; + virtual bool isLockable() OVERRIDE { return true; } + +private: + bool getTags(); + MPD::MutableSong itsEdited; }; extern TinyTagEditor *myTinyTagEditor; diff --git a/src/visualizer.h b/src/visualizer.h index 10466ee0..2791ebe9 100644 --- a/src/visualizer.h +++ b/src/visualizer.h @@ -32,53 +32,52 @@ # include #endif -class Visualizer : public Screen +struct Visualizer : public Screen { - public: - virtual void switchTo() OVERRIDE; - virtual void resize() OVERRIDE; - - virtual std::wstring title() OVERRIDE; - - virtual void update() OVERRIDE; - virtual void scroll(NC::Where) OVERRIDE { } - - virtual void enterPressed() OVERRIDE { } - virtual void spacePressed() OVERRIDE; - virtual void mouseButtonPressed(MEVENT) OVERRIDE { } - - virtual bool isTabbable() OVERRIDE { return true; } - virtual bool isMergable() OVERRIDE { return true; } - - // private members - void SetFD(); - void ResetFD(); - void FindOutputID(); - - static const int WindowTimeout; - - protected: - virtual void init(); - virtual bool isLockable() { return true; } - - private: - void DrawSoundWave(int16_t *, ssize_t, size_t, size_t); -# ifdef HAVE_FFTW3_H - void DrawFrequencySpectrum(int16_t *, ssize_t, size_t, size_t); -# endif // HAVE_FFTW3_H - - int itsOutputID; - timeval itsTimer; - - int itsFifo; - unsigned itsSamples; -# ifdef HAVE_FFTW3_H - unsigned itsFFTResults; - unsigned *itsFreqsMagnitude; - double *itsInput; - fftw_complex *itsOutput; - fftw_plan itsPlan; -# endif // HAVE_FFTW3_H + virtual void switchTo() OVERRIDE; + virtual void resize() OVERRIDE; + + virtual std::wstring title() OVERRIDE; + + virtual void update() OVERRIDE; + virtual void scroll(NC::Where) OVERRIDE { } + + virtual void enterPressed() OVERRIDE { } + virtual void spacePressed() OVERRIDE; + virtual void mouseButtonPressed(MEVENT) OVERRIDE { } + + virtual bool isTabbable() OVERRIDE { return true; } + virtual bool isMergable() OVERRIDE { return true; } + + // private members + void SetFD(); + void ResetFD(); + void FindOutputID(); + + static const int WindowTimeout; + +protected: + virtual void init(); + virtual bool isLockable() { return true; } + +private: + void DrawSoundWave(int16_t *, ssize_t, size_t, size_t); +# ifdef HAVE_FFTW3_H + void DrawFrequencySpectrum(int16_t *, ssize_t, size_t, size_t); +# endif // HAVE_FFTW3_H + + int itsOutputID; + timeval itsTimer; + + int itsFifo; + unsigned itsSamples; +# ifdef HAVE_FFTW3_H + unsigned itsFFTResults; + unsigned *itsFreqsMagnitude; + double *itsInput; + fftw_complex *itsOutput; + fftw_plan itsPlan; +# endif // HAVE_FFTW3_H }; extern Visualizer *myVisualizer;