adjust indentation of remaining classes in headers
This commit is contained in:
123
src/browser.h
123
src/browser.h
@@ -25,69 +25,68 @@
|
|||||||
#include "mpdpp.h"
|
#include "mpdpp.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
class Browser : public Screen< NC::Menu<MPD::Item> >, public Filterable, public HasSongs, public Searchable
|
struct Browser : public Screen< NC::Menu<MPD::Item> >, public Filterable, public HasSongs, public Searchable
|
||||||
{
|
{
|
||||||
public:
|
Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/") { }
|
||||||
Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/") { }
|
|
||||||
|
// Screen< NC::Menu<MPD::Item> > implementation
|
||||||
// Screen< NC::Menu<MPD::Item> > implementation
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void update() OVERRIDE { }
|
||||||
virtual void update() OVERRIDE { }
|
|
||||||
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void spacePressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
|
||||||
|
virtual bool isTabbable() OVERRIDE { return true; }
|
||||||
virtual bool isTabbable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
|
||||||
|
// Filterable implementation
|
||||||
// Filterable implementation
|
virtual bool allowsFiltering() OVERRIDE;
|
||||||
virtual bool allowsFiltering() OVERRIDE;
|
virtual std::string currentFilter() OVERRIDE;
|
||||||
virtual std::string currentFilter() OVERRIDE;
|
virtual void applyFilter(const std::string &filter) OVERRIDE;
|
||||||
virtual void applyFilter(const std::string &filter) OVERRIDE;
|
|
||||||
|
// Searchable implementation
|
||||||
// Searchable implementation
|
virtual bool allowsSearching() OVERRIDE;
|
||||||
virtual bool allowsSearching() OVERRIDE;
|
virtual bool search(const std::string &constraint) OVERRIDE;
|
||||||
virtual bool search(const std::string &constraint) OVERRIDE;
|
virtual void nextFound(bool wrap) OVERRIDE;
|
||||||
virtual void nextFound(bool wrap) OVERRIDE;
|
virtual void prevFound(bool wrap) OVERRIDE;
|
||||||
virtual void prevFound(bool wrap) OVERRIDE;
|
|
||||||
|
// HasSongs implementation
|
||||||
// HasSongs implementation
|
virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
|
||||||
virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
|
|
||||||
|
virtual bool allowsSelection() OVERRIDE;
|
||||||
virtual bool allowsSelection() OVERRIDE;
|
virtual void reverseSelection() OVERRIDE;
|
||||||
virtual void reverseSelection() OVERRIDE;
|
virtual MPD::SongList getSelectedSongs() OVERRIDE;
|
||||||
virtual MPD::SongList getSelectedSongs() OVERRIDE;
|
|
||||||
|
// private members
|
||||||
// private members
|
const std::string &CurrentDir() { return itsBrowsedDir; }
|
||||||
const std::string &CurrentDir() { return itsBrowsedDir; }
|
|
||||||
|
bool isLocal() { return itsBrowseLocally; }
|
||||||
bool isLocal() { return itsBrowseLocally; }
|
void LocateSong(const MPD::Song &);
|
||||||
void LocateSong(const MPD::Song &);
|
void GetDirectory(std::string, std::string = "/");
|
||||||
void GetDirectory(std::string, std::string = "/");
|
# ifndef WIN32
|
||||||
# ifndef WIN32
|
void GetLocalDirectory(MPD::ItemList &, const std::string & = "", bool = 0) const;
|
||||||
void GetLocalDirectory(MPD::ItemList &, const std::string & = "", bool = 0) const;
|
void ClearDirectory(const std::string &) const;
|
||||||
void ClearDirectory(const std::string &) const;
|
void ChangeBrowseMode();
|
||||||
void ChangeBrowseMode();
|
bool deleteItem(const MPD::Item &);
|
||||||
bool deleteItem(const MPD::Item &);
|
# endif // !WIN32
|
||||||
# endif // !WIN32
|
|
||||||
|
static bool isParentDirectory(const MPD::Item &item) {
|
||||||
static bool isParentDirectory(const MPD::Item &item) {
|
return item.type == MPD::itDirectory && item.name == "..";
|
||||||
return item.type == MPD::itDirectory && item.name == "..";
|
}
|
||||||
}
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init() OVERRIDE;
|
||||||
virtual void init() OVERRIDE;
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
|
||||||
|
private:
|
||||||
private:
|
bool itsBrowseLocally;
|
||||||
bool itsBrowseLocally;
|
size_t itsScrollBeginning;
|
||||||
size_t itsScrollBeginning;
|
std::string itsBrowsedDir;
|
||||||
std::string itsBrowsedDir;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Browser *myBrowser;
|
extern Browser *myBrowser;
|
||||||
|
|||||||
63
src/clock.h
63
src/clock.h
@@ -28,39 +28,38 @@
|
|||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
class Clock : public Screen<NC::Window>
|
struct Clock : public Screen<NC::Window>
|
||||||
{
|
{
|
||||||
public:
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void update() OVERRIDE;
|
||||||
virtual void update() OVERRIDE;
|
virtual void scroll(NC::Where) OVERRIDE { }
|
||||||
virtual void scroll(NC::Where) OVERRIDE { }
|
|
||||||
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void spacePressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE { }
|
virtual void mouseButtonPressed(MEVENT) OVERRIDE { }
|
||||||
virtual void mouseButtonPressed(MEVENT) OVERRIDE { }
|
|
||||||
|
virtual bool isTabbable() OVERRIDE { return true; }
|
||||||
virtual bool isTabbable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init() OVERRIDE;
|
||||||
virtual void init() OVERRIDE;
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
|
||||||
|
private:
|
||||||
private:
|
NC::Window *itsPane;
|
||||||
NC::Window *itsPane;
|
|
||||||
|
static void Prepare();
|
||||||
static void Prepare();
|
static void Set(int, int);
|
||||||
static void Set(int, int);
|
|
||||||
|
static short disp[11];
|
||||||
static short disp[11];
|
static long older[6], next[6], newer[6], mask;
|
||||||
static long older[6], next[6], newer[6], mask;
|
|
||||||
|
static size_t Width;
|
||||||
static size_t Width;
|
static const size_t Height;
|
||||||
static const size_t Height;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Clock *myClock;
|
extern Clock *myClock;
|
||||||
|
|||||||
@@ -26,31 +26,28 @@
|
|||||||
#include "mutable_song.h"
|
#include "mutable_song.h"
|
||||||
#include "search_engine.h"
|
#include "search_engine.h"
|
||||||
|
|
||||||
namespace Display
|
namespace Display {//
|
||||||
{
|
|
||||||
std::string Columns(size_t);
|
std::string Columns(size_t);
|
||||||
|
|
||||||
template <typename T> void Default(NC::Menu<T> &menu)
|
template <typename ItemT>
|
||||||
{
|
void Default(NC::Menu<ItemT> &menu) { menu << menu.drawn()->value(); }
|
||||||
menu << menu.drawn()->value();
|
|
||||||
}
|
template <typename A, typename B>
|
||||||
|
void Pair(NC::Menu< std::pair<A, B> > &menu) { menu << menu.drawn()->value().first; }
|
||||||
template <typename A, typename B> void Pair(NC::Menu< std::pair<A, B> > &menu)
|
|
||||||
{
|
void SongsInColumns(NC::Menu<MPD::Song> &menu, HasSongs *screen);
|
||||||
menu << menu.drawn()->value().first;
|
|
||||||
}
|
void Songs(NC::Menu<MPD::Song> &menu, HasSongs *screen, const std::string &format);
|
||||||
|
|
||||||
void SongsInColumns(NC::Menu<MPD::Song> &menu, HasSongs *screen);
|
void Tags(NC::Menu<MPD::MutableSong> &menu);
|
||||||
|
|
||||||
void Songs(NC::Menu<MPD::Song> &menu, HasSongs *screen, const std::string &format);
|
void Outputs(NC::Menu<MPD::Output> &menu);
|
||||||
|
|
||||||
void Tags(NC::Menu<MPD::MutableSong> &menu);
|
void SearchEngine(NC::Menu<SEItem> &menu);
|
||||||
|
|
||||||
void Outputs(NC::Menu<MPD::Output> &menu);
|
void Items(NC::Menu<MPD::Item> &menu);
|
||||||
|
|
||||||
void SearchEngine(NC::Menu<SEItem> &menu);
|
|
||||||
|
|
||||||
void Items(NC::Menu<MPD::Item> &menu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -20,20 +20,24 @@
|
|||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
BasicScreen *Global::myScreen;
|
namespace Global {//
|
||||||
BasicScreen *Global::myOldScreen;
|
|
||||||
BasicScreen *Global::myPrevScreen;
|
|
||||||
BasicScreen *Global::myLockedScreen;
|
|
||||||
BasicScreen *Global::myInactiveScreen;
|
|
||||||
|
|
||||||
NC::Window *Global::wHeader;
|
BasicScreen *myScreen;
|
||||||
NC::Window *Global::wFooter;
|
BasicScreen *myOldScreen;
|
||||||
|
BasicScreen *myPrevScreen;
|
||||||
|
BasicScreen *myLockedScreen;
|
||||||
|
BasicScreen *myInactiveScreen;
|
||||||
|
|
||||||
size_t Global::MainStartY;
|
NC::Window *wHeader;
|
||||||
size_t Global::MainHeight;
|
NC::Window *wFooter;
|
||||||
|
|
||||||
bool Global::ShowMessages = false;
|
size_t MainStartY;
|
||||||
bool Global::SeekingInProgress = false;
|
size_t MainHeight;
|
||||||
|
|
||||||
std::string Global::VolumeState;
|
bool ShowMessages = false;
|
||||||
timeval Global::Timer;
|
bool SeekingInProgress = false;
|
||||||
|
|
||||||
|
std::string VolumeState;
|
||||||
|
timeval Timer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
83
src/global.h
83
src/global.h
@@ -26,47 +26,48 @@
|
|||||||
#include "mpdpp.h"
|
#include "mpdpp.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
namespace Global
|
namespace Global {//
|
||||||
{
|
|
||||||
// currently active screen (displayed in main window)
|
// currently active screen (displayed in main window)
|
||||||
extern BasicScreen *myScreen;
|
extern BasicScreen *myScreen;
|
||||||
|
|
||||||
// for info, lyrics, popups to remember which screen return to
|
// for info, lyrics, popups to remember which screen return to
|
||||||
extern BasicScreen *myOldScreen;
|
extern BasicScreen *myOldScreen;
|
||||||
|
|
||||||
// "real" screen switching (browser, search, etc.)
|
// "real" screen switching (browser, search, etc.)
|
||||||
extern BasicScreen *myPrevScreen;
|
extern BasicScreen *myPrevScreen;
|
||||||
|
|
||||||
// points at the screen that was locked (or is null if no screen is locked)
|
// points at the screen that was locked (or is null if no screen is locked)
|
||||||
extern BasicScreen *myLockedScreen;
|
extern BasicScreen *myLockedScreen;
|
||||||
|
|
||||||
// points at inactive screen, if locking was enabled and two screens are displayed
|
// points at inactive screen, if locking was enabled and two screens are displayed
|
||||||
extern BasicScreen *myInactiveScreen;
|
extern BasicScreen *myInactiveScreen;
|
||||||
|
|
||||||
// header window (above main window)
|
// header window (above main window)
|
||||||
extern NC::Window *wHeader;
|
extern NC::Window *wHeader;
|
||||||
|
|
||||||
// footer window (below main window)
|
// footer window (below main window)
|
||||||
extern NC::Window *wFooter;
|
extern NC::Window *wFooter;
|
||||||
|
|
||||||
// Y coordinate of top of main window
|
// Y coordinate of top of main window
|
||||||
extern size_t MainStartY;
|
extern size_t MainStartY;
|
||||||
|
|
||||||
// height of main window
|
// height of main window
|
||||||
extern size_t MainHeight;
|
extern size_t MainHeight;
|
||||||
|
|
||||||
// indicates whether messages from Statusbar::msg function should be shown
|
// indicates whether messages from Statusbar::msg function should be shown
|
||||||
extern bool ShowMessages;
|
extern bool ShowMessages;
|
||||||
|
|
||||||
// indicates whether seeking action in currently in progress
|
// indicates whether seeking action in currently in progress
|
||||||
extern bool SeekingInProgress;
|
extern bool SeekingInProgress;
|
||||||
|
|
||||||
// string that represents volume in right top corner. being global
|
// string that represents volume in right top corner. being global
|
||||||
// to be used for calculating width offsets in various files.
|
// to be used for calculating width offsets in various files.
|
||||||
extern std::string VolumeState;
|
extern std::string VolumeState;
|
||||||
|
|
||||||
// global timer
|
// global timer
|
||||||
extern timeval Timer;
|
extern timeval Timer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
57
src/help.h
57
src/help.h
@@ -24,36 +24,35 @@
|
|||||||
#include "actions.h"
|
#include "actions.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
class Help : public Screen<NC::Scrollpad>
|
struct Help : public Screen<NC::Scrollpad>
|
||||||
{
|
{
|
||||||
public:
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void update() OVERRIDE { }
|
||||||
virtual void update() OVERRIDE { }
|
|
||||||
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void spacePressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
|
virtual bool isTabbable() OVERRIDE { return true; }
|
||||||
virtual bool isTabbable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init() OVERRIDE;
|
||||||
virtual void init() OVERRIDE;
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
|
||||||
|
private:
|
||||||
private:
|
void KeysSection(const char *title) { Section("Keys", title); }
|
||||||
void KeysSection(const char *title) { Section("Keys", title); }
|
void MouseSection(const char *title) { Section("Mouse", title); }
|
||||||
void MouseSection(const char *title) { Section("Mouse", title); }
|
void Section(const char *type, const char *title);
|
||||||
void Section(const char *type, const char *title);
|
void KeyDesc(const ActionType at, const char *desc);
|
||||||
void KeyDesc(const ActionType at, const char *desc);
|
void MouseDesc(std::string action, const char *desc, bool indent = false);
|
||||||
void MouseDesc(std::string action, const char *desc, bool indent = false);
|
void MouseColumn(const char *column);
|
||||||
void MouseColumn(const char *column);
|
|
||||||
|
std::string DisplayKeys(const ActionType at);
|
||||||
std::string DisplayKeys(const ActionType at);
|
void GetKeybindings();
|
||||||
void GetKeybindings();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Help *myHelp;
|
extern Help *myHelp;
|
||||||
|
|||||||
99
src/lastfm.h
99
src/lastfm.h
@@ -31,57 +31,56 @@
|
|||||||
#include "lastfm_service.h"
|
#include "lastfm_service.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
class Lastfm : public Screen<NC::Scrollpad>
|
struct Lastfm : public Screen<NC::Scrollpad>
|
||||||
{
|
{
|
||||||
public:
|
Lastfm() : isReadyToTake(0), isDownloadInProgress(0) { }
|
||||||
Lastfm() : isReadyToTake(0), isDownloadInProgress(0) { }
|
|
||||||
|
// Screen<NC::Scrollpad>
|
||||||
// Screen<NC::Scrollpad>
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void update() OVERRIDE;
|
||||||
virtual void update() OVERRIDE;
|
|
||||||
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void spacePressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
virtual bool isTabbable() OVERRIDE { return false; }
|
||||||
virtual bool isTabbable() OVERRIDE { return false; }
|
|
||||||
|
// private members
|
||||||
// private members
|
void Refetch();
|
||||||
void Refetch();
|
|
||||||
|
bool isDownloading() { return isDownloadInProgress && !isReadyToTake; }
|
||||||
bool isDownloading() { return isDownloadInProgress && !isReadyToTake; }
|
bool SetArtistInfoArgs(const std::string &artist, const std::string &lang = "");
|
||||||
bool SetArtistInfoArgs(const std::string &artist, const std::string &lang = "");
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init() OVERRIDE;
|
||||||
virtual void init() OVERRIDE;
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
|
||||||
|
private:
|
||||||
private:
|
std::wstring itsTitle;
|
||||||
std::wstring itsTitle;
|
|
||||||
|
std::string itsArtist;
|
||||||
std::string itsArtist;
|
std::string itsFilename;
|
||||||
std::string itsFilename;
|
|
||||||
|
std::string itsFolder;
|
||||||
std::string itsFolder;
|
|
||||||
|
std::auto_ptr<LastfmService> itsService;
|
||||||
std::auto_ptr<LastfmService> itsService;
|
LastfmService::Args itsArgs;
|
||||||
LastfmService::Args itsArgs;
|
|
||||||
|
void Load();
|
||||||
void Load();
|
void Save(const std::string &data);
|
||||||
void Save(const std::string &data);
|
void SetTitleAndFolder();
|
||||||
void SetTitleAndFolder();
|
|
||||||
|
void Download();
|
||||||
void Download();
|
static void *DownloadWrapper(void *);
|
||||||
static void *DownloadWrapper(void *);
|
|
||||||
|
void Take();
|
||||||
void Take();
|
bool isReadyToTake;
|
||||||
bool isReadyToTake;
|
bool isDownloadInProgress;
|
||||||
bool isDownloadInProgress;
|
pthread_t itsDownloader;
|
||||||
pthread_t itsDownloader;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Lastfm *myLastfm;
|
extern Lastfm *myLastfm;
|
||||||
|
|||||||
@@ -41,16 +41,16 @@ struct LastfmService
|
|||||||
virtual bool checkArgs(const Args &args) = 0;
|
virtual bool checkArgs(const Args &args) = 0;
|
||||||
virtual void colorizeOutput(NC::Scrollpad &w) = 0;
|
virtual void colorizeOutput(NC::Scrollpad &w) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool actionFailed(const std::string &data);
|
virtual bool actionFailed(const std::string &data);
|
||||||
|
|
||||||
virtual bool parse(std::string &data) = 0;
|
virtual bool parse(std::string &data) = 0;
|
||||||
virtual void postProcess(std::string &data);
|
virtual void postProcess(std::string &data);
|
||||||
|
|
||||||
virtual const char *methodName() = 0;
|
virtual const char *methodName() = 0;
|
||||||
|
|
||||||
static const char *baseURL;
|
static const char *baseURL;
|
||||||
static const char *msgParseFailed;
|
static const char *msgParseFailed;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ArtistInfo : public LastfmService
|
struct ArtistInfo : public LastfmService
|
||||||
@@ -60,10 +60,10 @@ struct ArtistInfo : public LastfmService
|
|||||||
virtual bool checkArgs(const Args &args);
|
virtual bool checkArgs(const Args &args);
|
||||||
virtual void colorizeOutput(NC::Scrollpad &w);
|
virtual void colorizeOutput(NC::Scrollpad &w);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool parse(std::string &data);
|
virtual bool parse(std::string &data);
|
||||||
|
|
||||||
virtual const char *methodName() { return "artist.getinfo"; }
|
virtual const char *methodName() { return "artist.getinfo"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HAVE_CURL_CURL_H
|
#endif // HAVE_CURL_CURL_H
|
||||||
|
|||||||
141
src/lyrics.h
141
src/lyrics.h
@@ -28,78 +28,77 @@
|
|||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "lyrics_fetcher.h"
|
#include "lyrics_fetcher.h"
|
||||||
|
|
||||||
class Lyrics : public Screen<NC::Scrollpad>
|
struct Lyrics : public Screen<NC::Scrollpad>
|
||||||
{
|
{
|
||||||
public:
|
Lyrics() : ReloadNP(0),
|
||||||
Lyrics() : ReloadNP(0),
|
# ifdef HAVE_CURL_CURL_H
|
||||||
# ifdef HAVE_CURL_CURL_H
|
isReadyToTake(0), isDownloadInProgress(0),
|
||||||
isReadyToTake(0), isDownloadInProgress(0),
|
# endif // HAVE_CURL_CURL_H
|
||||||
# endif // HAVE_CURL_CURL_H
|
itsScrollBegin(0) { }
|
||||||
itsScrollBegin(0) { }
|
|
||||||
|
// Screen<NC::Scrollpad> implementation
|
||||||
// Screen<NC::Scrollpad> implementation
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void update() OVERRIDE;
|
||||||
virtual void update() OVERRIDE;
|
|
||||||
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void spacePressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE;
|
|
||||||
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
virtual bool isTabbable() OVERRIDE { return false; }
|
||||||
virtual bool isTabbable() OVERRIDE { return false; }
|
|
||||||
|
// private members
|
||||||
// private members
|
void Edit();
|
||||||
void Edit();
|
|
||||||
|
# ifdef HAVE_CURL_CURL_H
|
||||||
# ifdef HAVE_CURL_CURL_H
|
void Refetch();
|
||||||
void Refetch();
|
|
||||||
|
static void ToggleFetcher();
|
||||||
static void ToggleFetcher();
|
static void DownloadInBackground(const MPD::Song &s);
|
||||||
static void DownloadInBackground(const MPD::Song &s);
|
# endif // HAVE_CURL_CURL_H
|
||||||
# endif // HAVE_CURL_CURL_H
|
|
||||||
|
bool ReloadNP;
|
||||||
bool ReloadNP;
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init() OVERRIDE;
|
||||||
virtual void init() OVERRIDE;
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
|
||||||
|
private:
|
||||||
private:
|
void Load();
|
||||||
void Load();
|
|
||||||
|
# ifdef HAVE_CURL_CURL_H
|
||||||
# ifdef HAVE_CURL_CURL_H
|
static void *DownloadInBackgroundImpl(void *song_ptr);
|
||||||
static void *DownloadInBackgroundImpl(void *song_ptr);
|
static void DownloadInBackgroundImplHelper(const MPD::Song &s);
|
||||||
static void DownloadInBackgroundImplHelper(const MPD::Song &s);
|
// lock for allowing exclusive access to itsToDownload and itsWorkersNumber
|
||||||
// lock for allowing exclusive access to itsToDownload and itsWorkersNumber
|
static pthread_mutex_t itsDIBLock;
|
||||||
static pthread_mutex_t itsDIBLock;
|
// storage for songs for which lyrics are scheduled to be downloaded
|
||||||
// storage for songs for which lyrics are scheduled to be downloaded
|
static std::queue<MPD::Song *> itsToDownload;
|
||||||
static std::queue<MPD::Song *> itsToDownload;
|
// current worker threads (ie. downloading lyrics)
|
||||||
// current worker threads (ie. downloading lyrics)
|
static size_t itsWorkersNumber;
|
||||||
static size_t itsWorkersNumber;
|
// maximum number of worker threads. if it's reached, next lyrics requests
|
||||||
// maximum number of worker threads. if it's reached, next lyrics requests
|
// are put into itsToDownload queue.
|
||||||
// are put into itsToDownload queue.
|
static const size_t itsMaxWorkersNumber = 4;
|
||||||
static const size_t itsMaxWorkersNumber = 4;
|
|
||||||
|
void *Download();
|
||||||
void *Download();
|
static void *DownloadWrapper(void *);
|
||||||
static void *DownloadWrapper(void *);
|
static void Save(const std::string &filename, const std::string &lyrics);
|
||||||
static void Save(const std::string &filename, const std::string &lyrics);
|
|
||||||
|
void Take();
|
||||||
void Take();
|
bool isReadyToTake;
|
||||||
bool isReadyToTake;
|
bool isDownloadInProgress;
|
||||||
bool isDownloadInProgress;
|
pthread_t itsDownloader;
|
||||||
pthread_t itsDownloader;
|
|
||||||
|
static LyricsFetcher **itsFetcher;
|
||||||
static LyricsFetcher **itsFetcher;
|
# endif // HAVE_CURL_CURL_H
|
||||||
# endif // HAVE_CURL_CURL_H
|
|
||||||
|
size_t itsScrollBegin;
|
||||||
size_t itsScrollBegin;
|
MPD::Song itsSong;
|
||||||
MPD::Song itsSong;
|
std::string itsFilename;
|
||||||
std::string itsFilename;
|
|
||||||
|
static std::string GenerateFilename(const MPD::Song &s);
|
||||||
static std::string GenerateFilename(const MPD::Song &s);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Lyrics *myLyrics;
|
extern Lyrics *myLyrics;
|
||||||
|
|||||||
@@ -34,27 +34,27 @@ struct LyricsFetcher
|
|||||||
virtual const char *name() = 0;
|
virtual const char *name() = 0;
|
||||||
virtual Result fetch(const std::string &artist, const std::string &title);
|
virtual Result fetch(const std::string &artist, const std::string &title);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getURL() = 0;
|
virtual const char *getURL() = 0;
|
||||||
virtual const char *getOpenTag() = 0;
|
virtual const char *getOpenTag() = 0;
|
||||||
virtual const char *getCloseTag() = 0;
|
virtual const char *getCloseTag() = 0;
|
||||||
|
|
||||||
virtual bool notLyrics(const std::string &) { return false; }
|
virtual bool notLyrics(const std::string &) { return false; }
|
||||||
virtual void postProcess(std::string &data);
|
virtual void postProcess(std::string &data);
|
||||||
|
|
||||||
bool getContent(const char *open_tag, const char *close_tag, std::string &data);
|
bool getContent(const char *open_tag, const char *close_tag, std::string &data);
|
||||||
|
|
||||||
static const char msgNotFound[];
|
static const char msgNotFound[];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LyrcComArFetcher : public LyricsFetcher
|
struct LyrcComArFetcher : public LyricsFetcher
|
||||||
{
|
{
|
||||||
virtual const char *name() { return "lyrc.com.ar"; }
|
virtual const char *name() { return "lyrc.com.ar"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getURL() { return "http://lyrc.com.ar/tema1es.php?artist=%artist%&songname=%title%"; }
|
virtual const char *getURL() { return "http://lyrc.com.ar/tema1es.php?artist=%artist%&songname=%title%"; }
|
||||||
virtual const char *getOpenTag() { return "</table>"; }
|
virtual const char *getOpenTag() { return "</table>"; }
|
||||||
virtual const char *getCloseTag() { return "<p>"; }
|
virtual const char *getCloseTag() { return "<p>"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LyricwikiFetcher : public LyricsFetcher
|
struct LyricwikiFetcher : public LyricsFetcher
|
||||||
@@ -62,12 +62,12 @@ struct LyricwikiFetcher : public LyricsFetcher
|
|||||||
virtual const char *name() { return "lyricwiki.com"; }
|
virtual const char *name() { return "lyricwiki.com"; }
|
||||||
virtual Result fetch(const std::string &artist, const std::string &title);
|
virtual Result fetch(const std::string &artist, const std::string &title);
|
||||||
|
|
||||||
protected:
|
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 *getURL() { return "http://lyrics.wikia.com/api.php?action=lyrics&fmt=xml&func=getSong&artist=%artist%&song=%title%"; }
|
||||||
virtual const char *getOpenTag() { return "<url>"; }
|
virtual const char *getOpenTag() { return "<url>"; }
|
||||||
virtual const char *getCloseTag() { return "</url>"; }
|
virtual const char *getCloseTag() { return "</url>"; }
|
||||||
|
|
||||||
virtual bool notLyrics(const std::string &data);
|
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);
|
virtual Result fetch(const std::string &artist, const std::string &title);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getSiteKeyword() = 0;
|
virtual const char *getSiteKeyword() = 0;
|
||||||
virtual const char *getURL() { return URL; }
|
virtual const char *getURL() { return URL; }
|
||||||
|
|
||||||
virtual bool isURLOk(const std::string &url);
|
virtual bool isURLOk(const std::string &url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char *URL;
|
const char *URL;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LyricstimeFetcher : public GoogleLyricsFetcher
|
struct LyricstimeFetcher : public GoogleLyricsFetcher
|
||||||
{
|
{
|
||||||
virtual const char *name() { return "lyricstime.com"; }
|
virtual const char *name() { return "lyricstime.com"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getSiteKeyword() { return "lyricstime"; }
|
virtual const char *getSiteKeyword() { return "lyricstime"; }
|
||||||
virtual const char *getOpenTag() { return "<div id=\"songlyrics\" >"; }
|
virtual const char *getOpenTag() { return "<div id=\"songlyrics\" >"; }
|
||||||
virtual const char *getCloseTag() { return "</div>"; }
|
virtual const char *getCloseTag() { return "</div>"; }
|
||||||
|
|
||||||
virtual bool isURLOk(const std::string &url);
|
virtual bool isURLOk(const std::string &url);
|
||||||
|
|
||||||
virtual void postProcess(std::string &data);
|
virtual void postProcess(std::string &data);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MetrolyricsFetcher : public GoogleLyricsFetcher
|
struct MetrolyricsFetcher : public GoogleLyricsFetcher
|
||||||
{
|
{
|
||||||
virtual const char *name() { return "metrolyrics.com"; }
|
virtual const char *name() { return "metrolyrics.com"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getSiteKeyword() { return "metrolyrics"; }
|
virtual const char *getSiteKeyword() { return "metrolyrics"; }
|
||||||
virtual const char *getOpenTag() { return "<div id=\"lyrics\">"; }
|
virtual const char *getOpenTag() { return "<div id=\"lyrics\">"; }
|
||||||
virtual const char *getCloseTag() { return "</div>"; }
|
virtual const char *getCloseTag() { return "</div>"; }
|
||||||
|
|
||||||
virtual bool isURLOk(const std::string &url);
|
virtual bool isURLOk(const std::string &url);
|
||||||
|
|
||||||
virtual void postProcess(std::string &data);
|
virtual void postProcess(std::string &data);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LyricsmaniaFetcher : public GoogleLyricsFetcher
|
struct LyricsmaniaFetcher : public GoogleLyricsFetcher
|
||||||
{
|
{
|
||||||
virtual const char *name() { return "lyricsmania.com"; }
|
virtual const char *name() { return "lyricsmania.com"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getSiteKeyword() { return "lyricsmania"; }
|
virtual const char *getSiteKeyword() { return "lyricsmania"; }
|
||||||
virtual const char *getOpenTag() { return "</strong> :<br />"; }
|
virtual const char *getOpenTag() { return "</strong> :<br />"; }
|
||||||
virtual const char *getCloseTag() { return "[ <a"; }
|
virtual const char *getCloseTag() { return "[ <a"; }
|
||||||
|
|
||||||
virtual void postProcess(std::string &data);
|
virtual void postProcess(std::string &data);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SonglyricsFetcher : public GoogleLyricsFetcher
|
struct SonglyricsFetcher : public GoogleLyricsFetcher
|
||||||
{
|
{
|
||||||
virtual const char *name() { return "songlyrics.com"; }
|
virtual const char *name() { return "songlyrics.com"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getSiteKeyword() { return "songlyrics"; }
|
virtual const char *getSiteKeyword() { return "songlyrics"; }
|
||||||
virtual const char *getOpenTag() { return "-6000px;\">"; }
|
virtual const char *getOpenTag() { return "-6000px;\">"; }
|
||||||
virtual const char *getCloseTag() { return "</p>"; }
|
virtual const char *getCloseTag() { return "</p>"; }
|
||||||
|
|
||||||
virtual void postProcess(std::string &data);
|
virtual void postProcess(std::string &data);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LyriczzFetcher : public GoogleLyricsFetcher
|
struct LyriczzFetcher : public GoogleLyricsFetcher
|
||||||
{
|
{
|
||||||
virtual const char *name() { return "lyriczz.com"; }
|
virtual const char *name() { return "lyriczz.com"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getSiteKeyword() { return "lyriczz"; }
|
virtual const char *getSiteKeyword() { return "lyriczz"; }
|
||||||
virtual const char *getOpenTag() { return "border=0 /></a>"; }
|
virtual const char *getOpenTag() { return "border=0 /></a>"; }
|
||||||
virtual const char *getCloseTag() { return "<a href"; }
|
virtual const char *getCloseTag() { return "<a href"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Sing365Fetcher : public GoogleLyricsFetcher
|
struct Sing365Fetcher : public GoogleLyricsFetcher
|
||||||
{
|
{
|
||||||
virtual const char *name() { return "sing365.com"; }
|
virtual const char *name() { return "sing365.com"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getSiteKeyword() { return "sing365"; }
|
virtual const char *getSiteKeyword() { return "sing365"; }
|
||||||
virtual const char *getOpenTag() { return "<br><br></div>"; }
|
virtual const char *getOpenTag() { return "<br><br></div>"; }
|
||||||
virtual const char *getCloseTag() { return "<div align"; }
|
virtual const char *getCloseTag() { return "<div align"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LyricsvipFetcher : public GoogleLyricsFetcher
|
struct LyricsvipFetcher : public GoogleLyricsFetcher
|
||||||
{
|
{
|
||||||
virtual const char *name() { return "lyricsvip.com"; }
|
virtual const char *name() { return "lyricsvip.com"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getSiteKeyword() { return "lyricsvip"; }
|
virtual const char *getSiteKeyword() { return "lyricsvip"; }
|
||||||
virtual const char *getOpenTag() { return "</h2>"; }
|
virtual const char *getOpenTag() { return "</h2>"; }
|
||||||
virtual const char *getCloseTag() { return "</td>"; }
|
virtual const char *getCloseTag() { return "</td>"; }
|
||||||
|
|
||||||
virtual void postProcess(std::string &data);
|
virtual void postProcess(std::string &data);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct JustSomeLyricsFetcher : public GoogleLyricsFetcher
|
struct JustSomeLyricsFetcher : public GoogleLyricsFetcher
|
||||||
{
|
{
|
||||||
virtual const char *name() { return "justsomelyrics.com"; }
|
virtual const char *name() { return "justsomelyrics.com"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getSiteKeyword() { return "justsomelyrics"; }
|
virtual const char *getSiteKeyword() { return "justsomelyrics"; }
|
||||||
virtual const char *getOpenTag() { return "alt=\"phone\" />\n</div>"; }
|
virtual const char *getOpenTag() { return "alt=\"phone\" />\n</div>"; }
|
||||||
virtual const char *getCloseTag() { return "<div class=\"adsdiv\">"; }
|
virtual const char *getCloseTag() { return "<div class=\"adsdiv\">"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LoloLyricsFetcher : public GoogleLyricsFetcher
|
struct LoloLyricsFetcher : public GoogleLyricsFetcher
|
||||||
{
|
{
|
||||||
virtual const char *name() { return "lololyrics.com"; }
|
virtual const char *name() { return "lololyrics.com"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getSiteKeyword() { return "lololyrics"; }
|
virtual const char *getSiteKeyword() { return "lololyrics"; }
|
||||||
virtual const char *getOpenTag() { return "<div class=\"lyrics_txt\" id=\"lyrics_txt\" style=\"font-size:12px; letter-spacing:0.2px; line-height:20px;\">"; }
|
virtual const char *getOpenTag() { return "<div class=\"lyrics_txt\" id=\"lyrics_txt\" style=\"font-size:12px; letter-spacing:0.2px; line-height:20px;\">"; }
|
||||||
virtual const char *getCloseTag() { return "</div>"; }
|
virtual const char *getCloseTag() { return "</div>"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct InternetLyricsFetcher : public GoogleLyricsFetcher
|
struct InternetLyricsFetcher : public GoogleLyricsFetcher
|
||||||
@@ -195,15 +195,15 @@ struct InternetLyricsFetcher : public GoogleLyricsFetcher
|
|||||||
virtual const char *name() { return "the Internet"; }
|
virtual const char *name() { return "the Internet"; }
|
||||||
virtual Result fetch(const std::string &artist, const std::string &title);
|
virtual Result fetch(const std::string &artist, const std::string &title);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char *getSiteKeyword() { return "lyrics"; }
|
virtual const char *getSiteKeyword() { return "lyrics"; }
|
||||||
virtual const char *getOpenTag() { return ""; }
|
virtual const char *getOpenTag() { return ""; }
|
||||||
virtual const char *getCloseTag() { return ""; }
|
virtual const char *getCloseTag() { return ""; }
|
||||||
|
|
||||||
virtual bool isURLOk(const std::string &url);
|
virtual bool isURLOk(const std::string &url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string URL;
|
std::string URL;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern LyricsFetcher *lyricsPlugins[];
|
extern LyricsFetcher *lyricsPlugins[];
|
||||||
|
|||||||
@@ -24,77 +24,76 @@
|
|||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
class MediaLibrary : public Screen<NC::Window>, public Filterable, public HasColumns, public HasSongs, public Searchable
|
struct MediaLibrary : public Screen<NC::Window>, public Filterable, public HasColumns, public HasSongs, public Searchable
|
||||||
{
|
{
|
||||||
public:
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
virtual void resize() 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<ProxySongList> 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<ProxySongList> 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;
|
std::string PrimaryTag;
|
||||||
|
std::string Album;
|
||||||
virtual void refresh() OVERRIDE;
|
std::string Date;
|
||||||
virtual void update() OVERRIDE;
|
};
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE;
|
NC::Menu<std::string> *Tags;
|
||||||
virtual void spacePressed() OVERRIDE;
|
NC::Menu<SearchConstraints> *Albums;
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
NC::Menu<MPD::Song> *Songs;
|
||||||
|
|
||||||
virtual bool isTabbable() OVERRIDE { return true; }
|
protected:
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
virtual void init();
|
||||||
|
virtual bool isLockable() { return true; }
|
||||||
// Filterable implementation
|
|
||||||
virtual bool allowsFiltering() OVERRIDE;
|
private:
|
||||||
virtual std::string currentFilter() OVERRIDE;
|
void AddToPlaylist(bool);
|
||||||
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<ProxySongList> 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<ProxySongList> 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<std::string> *Tags;
|
|
||||||
NC::Menu<SearchConstraints> *Albums;
|
|
||||||
NC::Menu<MPD::Song> *Songs;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void init();
|
|
||||||
virtual bool isLockable() { return true; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
void AddToPlaylist(bool);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MediaLibrary *myLibrary;
|
extern MediaLibrary *myLibrary;
|
||||||
|
|||||||
@@ -29,31 +29,29 @@
|
|||||||
#include "mpdpp.h"
|
#include "mpdpp.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
class Outputs : public Screen< NC::Menu<MPD::Output> >
|
struct Outputs : public Screen< NC::Menu<MPD::Output> >
|
||||||
{
|
{
|
||||||
public:
|
// Screen< NC::Menu<MPD::Output> > implementation
|
||||||
|
virtual void switchTo() OVERRIDE;
|
||||||
// Screen< NC::Menu<MPD::Output> > implementation
|
virtual void resize() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
|
||||||
virtual void resize() OVERRIDE;
|
virtual std::wstring title() OVERRIDE;
|
||||||
|
|
||||||
virtual std::wstring title() OVERRIDE;
|
virtual void update() OVERRIDE { }
|
||||||
|
|
||||||
virtual void update() OVERRIDE { }
|
virtual void enterPressed() OVERRIDE;
|
||||||
|
virtual void spacePressed() OVERRIDE { }
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
virtual bool isTabbable() OVERRIDE { return true; }
|
||||||
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isTabbable() OVERRIDE { return true; }
|
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
// private members
|
||||||
|
void FetchList();
|
||||||
// private members
|
|
||||||
void FetchList();
|
protected:
|
||||||
|
virtual void init() OVERRIDE;
|
||||||
protected:
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
virtual void init() OVERRIDE;
|
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Outputs *myOutputs;
|
extern Outputs *myOutputs;
|
||||||
|
|||||||
153
src/playlist.h
153
src/playlist.h
@@ -27,84 +27,83 @@
|
|||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
|
|
||||||
class Playlist : public Screen<NC::Menu<MPD::Song>>, public Filterable, public HasSongs, public Searchable
|
struct Playlist : public Screen<NC::Menu<MPD::Song>>, public Filterable, public HasSongs, public Searchable
|
||||||
{
|
{
|
||||||
public:
|
Playlist() : itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0) { }
|
||||||
Playlist() : itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0) { }
|
~Playlist() { }
|
||||||
~Playlist() { }
|
|
||||||
|
// Screen<NC::Menu<MPD::Song>> implementation
|
||||||
// Screen<NC::Menu<MPD::Song>> implementation
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void update() OVERRIDE { }
|
||||||
virtual void update() OVERRIDE { }
|
|
||||||
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void spacePressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
|
||||||
|
virtual bool isTabbable() OVERRIDE { return true; }
|
||||||
virtual bool isTabbable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
|
||||||
|
// Filterable implementation
|
||||||
// Filterable implementation
|
virtual bool allowsFiltering() OVERRIDE;
|
||||||
virtual bool allowsFiltering() OVERRIDE;
|
virtual std::string currentFilter() OVERRIDE;
|
||||||
virtual std::string currentFilter() OVERRIDE;
|
virtual void applyFilter(const std::string &filter) OVERRIDE;
|
||||||
virtual void applyFilter(const std::string &filter) OVERRIDE;
|
|
||||||
|
// Searchable implementation
|
||||||
// Searchable implementation
|
virtual bool allowsSearching();
|
||||||
virtual bool allowsSearching();
|
virtual bool search(const std::string &constraint) OVERRIDE;
|
||||||
virtual bool search(const std::string &constraint) OVERRIDE;
|
virtual void nextFound(bool wrap) OVERRIDE;
|
||||||
virtual void nextFound(bool wrap) OVERRIDE;
|
virtual void prevFound(bool wrap) OVERRIDE;
|
||||||
virtual void prevFound(bool wrap) OVERRIDE;
|
|
||||||
|
// HasSongs implementation
|
||||||
// HasSongs implementation
|
virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
|
||||||
virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
|
|
||||||
|
virtual bool allowsSelection() OVERRIDE;
|
||||||
virtual bool allowsSelection() OVERRIDE;
|
virtual void reverseSelection() OVERRIDE;
|
||||||
virtual void reverseSelection() OVERRIDE;
|
virtual MPD::SongList getSelectedSongs() OVERRIDE;
|
||||||
virtual MPD::SongList getSelectedSongs() OVERRIDE;
|
|
||||||
|
// private members
|
||||||
// private members
|
MPD::Song nowPlayingSong();
|
||||||
MPD::Song nowPlayingSong();
|
|
||||||
|
bool isFiltered();
|
||||||
bool isFiltered();
|
void Reverse();
|
||||||
void Reverse();
|
|
||||||
|
void EnableHighlighting();
|
||||||
void EnableHighlighting();
|
void UpdateTimer();
|
||||||
void UpdateTimer();
|
timeval Timer() const { return itsTimer; }
|
||||||
timeval Timer() const { return itsTimer; }
|
|
||||||
|
bool Add(const MPD::Song &s, bool play, int position = -1);
|
||||||
bool Add(const MPD::Song &s, bool play, int position = -1);
|
bool Add(const MPD::SongList &l, bool play, int position = -1);
|
||||||
bool Add(const MPD::SongList &l, bool play, int position = -1);
|
void PlayNewlyAddedSongs();
|
||||||
void PlayNewlyAddedSongs();
|
|
||||||
|
void SetSelectedItemsPriority(int prio);
|
||||||
void SetSelectedItemsPriority(int prio);
|
|
||||||
|
bool checkForSong(const MPD::Song &s);
|
||||||
bool checkForSong(const MPD::Song &s);
|
|
||||||
|
void registerHash(size_t hash);
|
||||||
void registerHash(size_t hash);
|
void unregisterHash(size_t hash);
|
||||||
void unregisterHash(size_t hash);
|
|
||||||
|
static bool ReloadTotalLength;
|
||||||
static bool ReloadTotalLength;
|
static bool ReloadRemaining;
|
||||||
static bool ReloadRemaining;
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init() OVERRIDE;
|
||||||
virtual void init() OVERRIDE;
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
|
||||||
|
private:
|
||||||
private:
|
std::string TotalLength();
|
||||||
std::string TotalLength();
|
std::string itsBufferedStats;
|
||||||
std::string itsBufferedStats;
|
|
||||||
|
std::map<size_t, int> itsSongHashes;
|
||||||
std::map<size_t, int> itsSongHashes;
|
|
||||||
|
size_t itsTotalLength;
|
||||||
size_t itsTotalLength;
|
size_t itsRemainingTime;
|
||||||
size_t itsRemainingTime;
|
size_t itsScrollBegin;
|
||||||
size_t itsScrollBegin;
|
|
||||||
|
timeval itsTimer;
|
||||||
timeval itsTimer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Playlist *myPlaylist;
|
extern Playlist *myPlaylist;
|
||||||
|
|||||||
@@ -24,69 +24,68 @@
|
|||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
class PlaylistEditor : public Screen<NC::Window>, public Filterable, public HasColumns, public HasSongs, public Searchable
|
struct PlaylistEditor : public Screen<NC::Window>, public Filterable, public HasColumns, public HasSongs, public Searchable
|
||||||
{
|
{
|
||||||
public:
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void refresh() OVERRIDE;
|
||||||
virtual void refresh() OVERRIDE;
|
virtual void update() OVERRIDE;
|
||||||
virtual void update() OVERRIDE;
|
|
||||||
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void spacePressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
|
||||||
|
virtual bool isTabbable() OVERRIDE { return true; }
|
||||||
virtual bool isTabbable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
|
||||||
|
// Filterable implementation
|
||||||
// Filterable implementation
|
virtual bool allowsFiltering() OVERRIDE;
|
||||||
virtual bool allowsFiltering() OVERRIDE;
|
virtual std::string currentFilter() OVERRIDE;
|
||||||
virtual std::string currentFilter() OVERRIDE;
|
virtual void applyFilter(const std::string &filter) OVERRIDE;
|
||||||
virtual void applyFilter(const std::string &filter) OVERRIDE;
|
|
||||||
|
// Searchable implementation
|
||||||
// Searchable implementation
|
virtual bool allowsSearching() OVERRIDE;
|
||||||
virtual bool allowsSearching() OVERRIDE;
|
virtual bool search(const std::string &constraint) OVERRIDE;
|
||||||
virtual bool search(const std::string &constraint) OVERRIDE;
|
virtual void nextFound(bool wrap) OVERRIDE;
|
||||||
virtual void nextFound(bool wrap) OVERRIDE;
|
virtual void prevFound(bool wrap) OVERRIDE;
|
||||||
virtual void prevFound(bool wrap) OVERRIDE;
|
|
||||||
|
// HasSongs implementation
|
||||||
// HasSongs implementation
|
virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
|
||||||
virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
|
|
||||||
|
virtual bool allowsSelection() OVERRIDE;
|
||||||
virtual bool allowsSelection() OVERRIDE;
|
virtual void reverseSelection() OVERRIDE;
|
||||||
virtual void reverseSelection() OVERRIDE;
|
virtual MPD::SongList getSelectedSongs() OVERRIDE;
|
||||||
virtual MPD::SongList getSelectedSongs() OVERRIDE;
|
|
||||||
|
// HasColumns implementation
|
||||||
// HasColumns implementation
|
virtual bool previousColumnAvailable() OVERRIDE;
|
||||||
virtual bool previousColumnAvailable() OVERRIDE;
|
virtual void previousColumn() OVERRIDE;
|
||||||
virtual void previousColumn() OVERRIDE;
|
|
||||||
|
virtual bool nextColumnAvailable() OVERRIDE;
|
||||||
virtual bool nextColumnAvailable() OVERRIDE;
|
virtual void nextColumn() OVERRIDE;
|
||||||
virtual void nextColumn() OVERRIDE;
|
|
||||||
|
// private members
|
||||||
// private members
|
void requestPlaylistsUpdate() { playlistsUpdateRequested = true; }
|
||||||
void requestPlaylistsUpdate() { playlistsUpdateRequested = true; }
|
void requestContentsUpdate() { contentUpdateRequested = true; }
|
||||||
void requestContentsUpdate() { contentUpdateRequested = true; }
|
|
||||||
|
virtual void Locate(const std::string &);
|
||||||
virtual void Locate(const std::string &);
|
bool isContentFiltered();
|
||||||
bool isContentFiltered();
|
std::shared_ptr<ProxySongList> contentProxyList();
|
||||||
std::shared_ptr<ProxySongList> contentProxyList();
|
|
||||||
|
NC::Menu<std::string> *Playlists;
|
||||||
NC::Menu<std::string> *Playlists;
|
NC::Menu<MPD::Song> *Content;
|
||||||
NC::Menu<MPD::Song> *Content;
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init() OVERRIDE;
|
||||||
virtual void init() OVERRIDE;
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
|
||||||
|
private:
|
||||||
private:
|
void AddToPlaylist(bool);
|
||||||
void AddToPlaylist(bool);
|
|
||||||
|
bool playlistsUpdateRequested;
|
||||||
bool playlistsUpdateRequested;
|
bool contentUpdateRequested;
|
||||||
bool contentUpdateRequested;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern PlaylistEditor *myPlaylistEditor;
|
extern PlaylistEditor *myPlaylistEditor;
|
||||||
|
|||||||
@@ -73,66 +73,65 @@ struct SEItem
|
|||||||
MPD::Song itsSong;
|
MPD::Song itsSong;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SearchEngine : public Screen< NC::Menu<SEItem> >, public Filterable, public HasSongs, public Searchable
|
struct SearchEngine : public Screen< NC::Menu<SEItem> >, public Filterable, public HasSongs, public Searchable
|
||||||
{
|
{
|
||||||
public:
|
// Screen< NC::Menu<SEItem> > implementation
|
||||||
// Screen< NC::Menu<SEItem> > implementation
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void update() OVERRIDE { }
|
||||||
virtual void update() OVERRIDE { }
|
|
||||||
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void spacePressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
|
||||||
|
virtual bool isTabbable() OVERRIDE { return true; }
|
||||||
virtual bool isTabbable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
|
||||||
|
// Filterable implementation
|
||||||
// Filterable implementation
|
virtual bool allowsFiltering() OVERRIDE;
|
||||||
virtual bool allowsFiltering() OVERRIDE;
|
virtual std::string currentFilter() OVERRIDE;
|
||||||
virtual std::string currentFilter() OVERRIDE;
|
virtual void applyFilter(const std::string &filter) OVERRIDE;
|
||||||
virtual void applyFilter(const std::string &filter) OVERRIDE;
|
|
||||||
|
// Searchable implementation
|
||||||
// Searchable implementation
|
virtual bool allowsSearching() OVERRIDE;
|
||||||
virtual bool allowsSearching() OVERRIDE;
|
virtual bool search(const std::string &constraint) OVERRIDE;
|
||||||
virtual bool search(const std::string &constraint) OVERRIDE;
|
virtual void nextFound(bool wrap) OVERRIDE;
|
||||||
virtual void nextFound(bool wrap) OVERRIDE;
|
virtual void prevFound(bool wrap) OVERRIDE;
|
||||||
virtual void prevFound(bool wrap) OVERRIDE;
|
|
||||||
|
// HasSongs implementation
|
||||||
// HasSongs implementation
|
virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
|
||||||
virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
|
|
||||||
|
virtual bool allowsSelection() OVERRIDE;
|
||||||
virtual bool allowsSelection() OVERRIDE;
|
virtual void reverseSelection() OVERRIDE;
|
||||||
virtual void reverseSelection() OVERRIDE;
|
virtual MPD::SongList getSelectedSongs() OVERRIDE;
|
||||||
virtual MPD::SongList getSelectedSongs() OVERRIDE;
|
|
||||||
|
// private members
|
||||||
// private members
|
|
||||||
|
static size_t StaticOptions;
|
||||||
static size_t StaticOptions;
|
static size_t SearchButton;
|
||||||
static size_t SearchButton;
|
static size_t ResetButton;
|
||||||
static size_t ResetButton;
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init() OVERRIDE;
|
||||||
virtual void init() OVERRIDE;
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
|
||||||
|
private:
|
||||||
private:
|
void Prepare();
|
||||||
void Prepare();
|
void Search();
|
||||||
void Search();
|
void reset();
|
||||||
void reset();
|
|
||||||
|
const char **SearchMode;
|
||||||
const char **SearchMode;
|
|
||||||
|
static const char *SearchModes[];
|
||||||
static const char *SearchModes[];
|
|
||||||
|
static const size_t ConstraintsNumber = 11;
|
||||||
static const size_t ConstraintsNumber = 11;
|
static const char *ConstraintsNames[];
|
||||||
static const char *ConstraintsNames[];
|
std::string itsConstraints[ConstraintsNumber];
|
||||||
std::string itsConstraints[ConstraintsNumber];
|
|
||||||
|
static bool MatchToPattern;
|
||||||
static bool MatchToPattern;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SearchEngine *mySearcher;
|
extern SearchEngine *mySearcher;
|
||||||
|
|||||||
@@ -23,42 +23,41 @@
|
|||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
class SelectedItemsAdder : public Screen< NC::Menu<std::string> >
|
struct SelectedItemsAdder : public Screen< NC::Menu<std::string> >
|
||||||
{
|
{
|
||||||
public:
|
SelectedItemsAdder() : itsPSWidth(35), itsPSHeight(11) { }
|
||||||
SelectedItemsAdder() : itsPSWidth(35), itsPSHeight(11) { }
|
|
||||||
|
// Screen< NC::Menu<std::string> > implementation
|
||||||
// Screen< NC::Menu<std::string> > implementation
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
virtual void refresh() OVERRIDE;
|
||||||
virtual void refresh() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void update() OVERRIDE { }
|
||||||
virtual void update() OVERRIDE { }
|
|
||||||
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void spacePressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE { }
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
|
||||||
|
virtual bool isMergable() OVERRIDE { return false; }
|
||||||
virtual bool isMergable() OVERRIDE { return false; }
|
virtual bool isTabbable() OVERRIDE { return false; }
|
||||||
virtual bool isTabbable() OVERRIDE { return false; }
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init() OVERRIDE;
|
||||||
virtual void init() OVERRIDE;
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
|
||||||
|
private:
|
||||||
private:
|
void SetDimensions();
|
||||||
void SetDimensions();
|
|
||||||
|
NC::Menu<std::string> *itsPlaylistSelector;
|
||||||
NC::Menu<std::string> *itsPlaylistSelector;
|
NC::Menu<std::string> *itsPositionSelector;
|
||||||
NC::Menu<std::string> *itsPositionSelector;
|
|
||||||
|
size_t itsPSWidth;
|
||||||
size_t itsPSWidth;
|
size_t itsPSHeight;
|
||||||
size_t itsPSHeight;
|
|
||||||
|
size_t itsWidth;
|
||||||
size_t itsWidth;
|
size_t itsHeight;
|
||||||
size_t itsHeight;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SelectedItemsAdder *mySelectedItemsAdder;
|
extern SelectedItemsAdder *mySelectedItemsAdder;
|
||||||
|
|||||||
@@ -23,35 +23,34 @@
|
|||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
class ServerInfo : public Screen<NC::Scrollpad>
|
struct ServerInfo : public Screen<NC::Scrollpad>
|
||||||
{
|
{
|
||||||
public:
|
// Screen<NC::Scrollpad> implementation
|
||||||
// Screen<NC::Scrollpad> implementation
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void update() OVERRIDE;
|
||||||
virtual void update() OVERRIDE;
|
|
||||||
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void spacePressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
|
virtual bool isMergable() OVERRIDE { return false; }
|
||||||
virtual bool isMergable() OVERRIDE { return false; }
|
virtual bool isTabbable() OVERRIDE { return false; }
|
||||||
virtual bool isTabbable() OVERRIDE { return false; }
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init() OVERRIDE;
|
||||||
virtual void init() OVERRIDE;
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
|
||||||
|
private:
|
||||||
private:
|
void SetDimensions();
|
||||||
void SetDimensions();
|
|
||||||
|
MPD::StringList itsURLHandlers;
|
||||||
MPD::StringList itsURLHandlers;
|
MPD::StringList itsTagTypes;
|
||||||
MPD::StringList itsTagTypes;
|
|
||||||
|
size_t itsWidth;
|
||||||
size_t itsWidth;
|
size_t itsHeight;
|
||||||
size_t itsHeight;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ServerInfo *myServerInfo;
|
extern ServerInfo *myServerInfo;
|
||||||
|
|||||||
@@ -192,11 +192,11 @@ struct Configuration
|
|||||||
|
|
||||||
SortMode browser_sort_mode;
|
SortMode browser_sort_mode;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MakeProperPath(std::string &dir);
|
void MakeProperPath(std::string &dir);
|
||||||
|
|
||||||
std::string home_directory;
|
std::string home_directory;
|
||||||
std::string config_file_path;
|
std::string config_file_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Configuration Config;
|
extern Configuration Config;
|
||||||
|
|||||||
14
src/song.h
14
src/song.h
@@ -79,13 +79,13 @@ struct Song
|
|||||||
|
|
||||||
static const char FormatEscapeCharacter = 1;
|
static const char FormatEscapeCharacter = 1;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char *getTag(mpd_tag_type type, unsigned idx) const;
|
const char *getTag(mpd_tag_type type, unsigned idx) const;
|
||||||
std::string ParseFormat(std::string::const_iterator &it, const std::string &tags_separator,
|
std::string ParseFormat(std::string::const_iterator &it, const std::string &tags_separator,
|
||||||
const std::string &escape_chars) const;
|
const std::string &escape_chars) const;
|
||||||
|
|
||||||
std::shared_ptr<mpd_song> m_song;
|
std::shared_ptr<mpd_song> m_song;
|
||||||
size_t m_hash;
|
size_t m_hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<Song> SongList;
|
typedef std::vector<Song> SongList;
|
||||||
|
|||||||
@@ -24,40 +24,38 @@
|
|||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "mutable_song.h"
|
#include "mutable_song.h"
|
||||||
|
|
||||||
class SongInfo : public Screen<NC::Scrollpad>
|
struct SongInfo : public Screen<NC::Scrollpad>
|
||||||
{
|
{
|
||||||
public:
|
struct Metadata
|
||||||
struct Metadata
|
{
|
||||||
{
|
const char *Name;
|
||||||
const char *Name;
|
MPD::Song::GetFunction Get;
|
||||||
MPD::Song::GetFunction Get;
|
MPD::MutableSong::SetFunction Set;
|
||||||
MPD::MutableSong::SetFunction Set;
|
};
|
||||||
};
|
|
||||||
|
// Screen<NC::Scrollpad> implementation
|
||||||
// Screen<NC::Scrollpad> implementation
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void update() OVERRIDE { }
|
||||||
virtual void update() OVERRIDE { }
|
|
||||||
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void spacePressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
virtual bool isTabbable() OVERRIDE { return false; }
|
||||||
virtual bool isTabbable() OVERRIDE { return false; }
|
|
||||||
|
// private members
|
||||||
// private members
|
static const Metadata Tags[];
|
||||||
|
|
||||||
static const Metadata Tags[];
|
protected:
|
||||||
|
virtual void init() OVERRIDE;
|
||||||
protected:
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
virtual void init() OVERRIDE;
|
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
private:
|
||||||
|
void PrepareSong(MPD::Song &);
|
||||||
private:
|
|
||||||
void PrepareSong(MPD::Song &);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SongInfo *mySongInfo;
|
extern SongInfo *mySongInfo;
|
||||||
|
|||||||
139
src/tag_editor.h
139
src/tag_editor.h
@@ -33,77 +33,76 @@
|
|||||||
#include "regex_filter.h"
|
#include "regex_filter.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
class TagEditor : public Screen<NC::Window>, public Filterable, public HasColumns, public HasSongs, public Searchable
|
struct TagEditor : public Screen<NC::Window>, public Filterable, public HasColumns, public HasSongs, public Searchable
|
||||||
{
|
{
|
||||||
public:
|
TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParserPreview(0), itsBrowsedDir("/") { }
|
||||||
TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParserPreview(0), itsBrowsedDir("/") { }
|
|
||||||
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void refresh() OVERRIDE;
|
||||||
virtual void refresh() OVERRIDE;
|
virtual void update() OVERRIDE;
|
||||||
virtual void update() OVERRIDE;
|
|
||||||
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void spacePressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT) OVERRIDE;
|
||||||
virtual void mouseButtonPressed(MEVENT) OVERRIDE;
|
|
||||||
|
virtual bool isTabbable() OVERRIDE { return true; }
|
||||||
virtual bool isTabbable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
|
||||||
|
// Filterable implementation
|
||||||
// Filterable implementation
|
virtual bool allowsFiltering() OVERRIDE;
|
||||||
virtual bool allowsFiltering() OVERRIDE;
|
virtual std::string currentFilter() OVERRIDE;
|
||||||
virtual std::string currentFilter() OVERRIDE;
|
virtual void applyFilter(const std::string &filter) OVERRIDE;
|
||||||
virtual void applyFilter(const std::string &filter) OVERRIDE;
|
|
||||||
|
// Searchable implementation
|
||||||
// Searchable implementation
|
virtual bool allowsSearching() OVERRIDE;
|
||||||
virtual bool allowsSearching() OVERRIDE;
|
virtual bool search(const std::string &constraint) OVERRIDE;
|
||||||
virtual bool search(const std::string &constraint) OVERRIDE;
|
virtual void nextFound(bool wrap) OVERRIDE;
|
||||||
virtual void nextFound(bool wrap) OVERRIDE;
|
virtual void prevFound(bool wrap) OVERRIDE;
|
||||||
virtual void prevFound(bool wrap) OVERRIDE;
|
|
||||||
|
// HasSongs implementation
|
||||||
// HasSongs implementation
|
virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
|
||||||
virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
|
|
||||||
|
virtual bool allowsSelection() OVERRIDE;
|
||||||
virtual bool allowsSelection() OVERRIDE;
|
virtual void reverseSelection() OVERRIDE;
|
||||||
virtual void reverseSelection() OVERRIDE;
|
virtual MPD::SongList getSelectedSongs() OVERRIDE;
|
||||||
virtual MPD::SongList getSelectedSongs() OVERRIDE;
|
|
||||||
|
// HasColumns implementation
|
||||||
// HasColumns implementation
|
virtual bool previousColumnAvailable() OVERRIDE;
|
||||||
virtual bool previousColumnAvailable() OVERRIDE;
|
virtual void previousColumn() OVERRIDE;
|
||||||
virtual void previousColumn() OVERRIDE;
|
|
||||||
|
virtual bool nextColumnAvailable() OVERRIDE;
|
||||||
virtual bool nextColumnAvailable() OVERRIDE;
|
virtual void nextColumn() OVERRIDE;
|
||||||
virtual void nextColumn() OVERRIDE;
|
|
||||||
|
// private members
|
||||||
// private members
|
bool ifAnyModifiedAskForDiscarding();
|
||||||
bool ifAnyModifiedAskForDiscarding();
|
void LocateSong(const MPD::Song &s);
|
||||||
void LocateSong(const MPD::Song &s);
|
const std::string &CurrentDir() { return itsBrowsedDir; }
|
||||||
const std::string &CurrentDir() { return itsBrowsedDir; }
|
|
||||||
|
NC::Menu< std::pair<std::string, std::string> > *Dirs;
|
||||||
NC::Menu< std::pair<std::string, std::string> > *Dirs;
|
NC::Menu<std::string> *TagTypes;
|
||||||
NC::Menu<std::string> *TagTypes;
|
NC::Menu<MPD::MutableSong> *Tags;
|
||||||
NC::Menu<MPD::MutableSong> *Tags;
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init();
|
||||||
virtual void init();
|
virtual bool isLockable() { return true; }
|
||||||
virtual bool isLockable() { return true; }
|
|
||||||
|
private:
|
||||||
private:
|
void SetDimensions(size_t, size_t);
|
||||||
void SetDimensions(size_t, size_t);
|
|
||||||
|
std::vector<MPD::MutableSong *> EditedSongs;
|
||||||
std::vector<MPD::MutableSong *> EditedSongs;
|
NC::Menu<std::string> *FParserDialog;
|
||||||
NC::Menu<std::string> *FParserDialog;
|
NC::Menu<std::string> *FParser;
|
||||||
NC::Menu<std::string> *FParser;
|
NC::Scrollpad *FParserHelper;
|
||||||
NC::Scrollpad *FParserHelper;
|
NC::Scrollpad *FParserLegend;
|
||||||
NC::Scrollpad *FParserLegend;
|
NC::Scrollpad *FParserPreview;
|
||||||
NC::Scrollpad *FParserPreview;
|
bool FParserUsePreview;
|
||||||
bool FParserUsePreview;
|
|
||||||
|
std::string itsBrowsedDir;
|
||||||
std::string itsBrowsedDir;
|
std::string itsHighlightedDir;
|
||||||
std::string itsHighlightedDir;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TagEditor *myTagEditor;
|
extern TagEditor *myTagEditor;
|
||||||
|
|||||||
@@ -28,34 +28,33 @@
|
|||||||
#include "mutable_song.h"
|
#include "mutable_song.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
class TinyTagEditor : public Screen< NC::Menu<NC::Buffer> >
|
struct TinyTagEditor : public Screen< NC::Menu<NC::Buffer> >
|
||||||
{
|
{
|
||||||
public:
|
// Screen< NC::Menu<NC::Buffer> > implementation
|
||||||
// Screen< NC::Menu<NC::Buffer> > implementation
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void update() OVERRIDE { }
|
||||||
virtual void update() OVERRIDE { }
|
|
||||||
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void spacePressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE { }
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
|
||||||
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
virtual bool isTabbable() OVERRIDE { return false; }
|
||||||
virtual bool isTabbable() OVERRIDE { return false; }
|
|
||||||
|
// private members
|
||||||
// private members
|
void SetEdited(const MPD::Song &);
|
||||||
void SetEdited(const MPD::Song &);
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init() OVERRIDE;
|
||||||
virtual void init() OVERRIDE;
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
|
||||||
|
private:
|
||||||
private:
|
bool getTags();
|
||||||
bool getTags();
|
MPD::MutableSong itsEdited;
|
||||||
MPD::MutableSong itsEdited;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TinyTagEditor *myTinyTagEditor;
|
extern TinyTagEditor *myTinyTagEditor;
|
||||||
|
|||||||
@@ -32,53 +32,52 @@
|
|||||||
# include <fftw3.h>
|
# include <fftw3.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class Visualizer : public Screen<NC::Window>
|
struct Visualizer : public Screen<NC::Window>
|
||||||
{
|
{
|
||||||
public:
|
virtual void switchTo() OVERRIDE;
|
||||||
virtual void switchTo() OVERRIDE;
|
virtual void resize() OVERRIDE;
|
||||||
virtual void resize() OVERRIDE;
|
|
||||||
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual std::wstring title() OVERRIDE;
|
|
||||||
|
virtual void update() OVERRIDE;
|
||||||
virtual void update() OVERRIDE;
|
virtual void scroll(NC::Where) OVERRIDE { }
|
||||||
virtual void scroll(NC::Where) OVERRIDE { }
|
|
||||||
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void spacePressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT) OVERRIDE { }
|
||||||
virtual void mouseButtonPressed(MEVENT) OVERRIDE { }
|
|
||||||
|
virtual bool isTabbable() OVERRIDE { return true; }
|
||||||
virtual bool isTabbable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
|
||||||
|
// private members
|
||||||
// private members
|
void SetFD();
|
||||||
void SetFD();
|
void ResetFD();
|
||||||
void ResetFD();
|
void FindOutputID();
|
||||||
void FindOutputID();
|
|
||||||
|
static const int WindowTimeout;
|
||||||
static const int WindowTimeout;
|
|
||||||
|
protected:
|
||||||
protected:
|
virtual void init();
|
||||||
virtual void init();
|
virtual bool isLockable() { return true; }
|
||||||
virtual bool isLockable() { return true; }
|
|
||||||
|
private:
|
||||||
private:
|
void DrawSoundWave(int16_t *, ssize_t, size_t, size_t);
|
||||||
void DrawSoundWave(int16_t *, ssize_t, size_t, size_t);
|
# ifdef HAVE_FFTW3_H
|
||||||
# ifdef HAVE_FFTW3_H
|
void DrawFrequencySpectrum(int16_t *, ssize_t, size_t, size_t);
|
||||||
void DrawFrequencySpectrum(int16_t *, ssize_t, size_t, size_t);
|
# endif // HAVE_FFTW3_H
|
||||||
# endif // HAVE_FFTW3_H
|
|
||||||
|
int itsOutputID;
|
||||||
int itsOutputID;
|
timeval itsTimer;
|
||||||
timeval itsTimer;
|
|
||||||
|
int itsFifo;
|
||||||
int itsFifo;
|
unsigned itsSamples;
|
||||||
unsigned itsSamples;
|
# ifdef HAVE_FFTW3_H
|
||||||
# ifdef HAVE_FFTW3_H
|
unsigned itsFFTResults;
|
||||||
unsigned itsFFTResults;
|
unsigned *itsFreqsMagnitude;
|
||||||
unsigned *itsFreqsMagnitude;
|
double *itsInput;
|
||||||
double *itsInput;
|
fftw_complex *itsOutput;
|
||||||
fftw_complex *itsOutput;
|
fftw_plan itsPlan;
|
||||||
fftw_plan itsPlan;
|
# endif // HAVE_FFTW3_H
|
||||||
# endif // HAVE_FFTW3_H
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Visualizer *myVisualizer;
|
extern Visualizer *myVisualizer;
|
||||||
|
|||||||
Reference in New Issue
Block a user