make use of override keyword if available

This commit is contained in:
Andrzej Rybczak
2012-09-04 19:19:37 +02:00
parent 6d87ebbc43
commit f6fb2ed54c
21 changed files with 298 additions and 292 deletions

View File

@@ -84,6 +84,18 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <functional>], [[int a = 5; std::fu
AC_MSG_ERROR([[Your compiler doesn't seem to support lambda functions, please upgrade (GCC >= 4.5)]]) AC_MSG_ERROR([[Your compiler doesn't seem to support lambda functions, please upgrade (GCC >= 4.5)]])
) )
dnl =========================================
dnl = checking for override keyword support =
dnl =========================================
AH_TEMPLATE([OVERRIDE], [override keyword used in C++11])
AC_MSG_CHECKING([whether compiler supports override keyword])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[struct A { virtual void foo() { } }; struct B : public A { virtual void foo() override { } };]], [])],
AC_MSG_RESULT([yes])
AC_DEFINE([OVERRIDE], [override]),
AC_MSG_RESULT([no])
AC_DEFINE([OVERRIDE], []),
)
dnl ============================== dnl ==============================
dnl = checking for regex (win32) = dnl = checking for regex (win32) =
dnl ============================== dnl ==============================

View File

@@ -320,22 +320,6 @@ std::shared_ptr<ProxySongList> Browser::getProxySongList()
}); });
} }
MPD::Song *Browser::getSong(size_t pos)
{
MPD::Song *ptr = 0;
if ((*w)[pos].value().type == itSong)
ptr = (*w)[pos].value().song.get();
return ptr;
}
MPD::Song *Browser::currentSong()
{
if (w->empty())
return 0;
else
return getSong(w->choice());
}
bool Browser::allowsSelection() bool Browser::allowsSelection()
{ {
return true; return true;

View File

@@ -30,38 +30,40 @@ class Browser : public Screen< NC::Menu<MPD::Item> >, public Filterable, public
public: public:
Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/") { } Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/") { }
virtual void Resize(); // Screen< NC::Menu<MPD::Item> > implementation
virtual void SwitchTo(); virtual void Resize() OVERRIDE;
virtual void SwitchTo() OVERRIDE;
virtual std::basic_string<my_char_t> Title(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void EnterPressed(); virtual void Update() OVERRIDE { }
virtual void SpacePressed();
virtual void MouseButtonPressed(MEVENT);
virtual bool isTabbable() { return true; }
/// Filterable implementation virtual void EnterPressed() OVERRIDE;
virtual bool allowsFiltering(); virtual void SpacePressed() OVERRIDE;
virtual std::string currentFilter(); virtual void MouseButtonPressed(MEVENT me) OVERRIDE;
virtual void applyFilter(const std::string &filter);
/// Searchable implementation virtual bool isTabbable() OVERRIDE { return true; }
virtual bool allowsSearching(); virtual bool isMergable() OVERRIDE { return true; }
virtual bool search(const std::string &constraint);
virtual void nextFound(bool wrap);
virtual void prevFound(bool wrap);
/// HasSongs implementation // Filterable implementation
virtual MPD::Song *getSong(size_t pos); virtual bool allowsFiltering() OVERRIDE;
virtual MPD::Song *currentSong(); virtual std::string currentFilter() OVERRIDE;
virtual std::shared_ptr<ProxySongList> getProxySongList(); virtual void applyFilter(const std::string &filter) OVERRIDE;
virtual bool allowsSelection(); // Searchable implementation
virtual void reverseSelection(); virtual bool allowsSearching() OVERRIDE;
virtual MPD::SongList getSelectedSongs(); virtual bool search(const std::string &constraint) OVERRIDE;
virtual void nextFound(bool wrap) OVERRIDE;
virtual void prevFound(bool wrap) OVERRIDE;
virtual bool isMergable() { return true; } // HasSongs implementation
virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
virtual bool allowsSelection() OVERRIDE;
virtual void reverseSelection() OVERRIDE;
virtual MPD::SongList getSelectedSongs() OVERRIDE;
// private members
const std::string &CurrentDir() { return itsBrowsedDir; } const std::string &CurrentDir() { return itsBrowsedDir; }
bool isLocal() { return itsBrowseLocally; } bool isLocal() { return itsBrowseLocally; }
@@ -79,8 +81,8 @@ class Browser : public Screen< NC::Menu<MPD::Item> >, public Filterable, public
} }
protected: protected:
virtual void Init(); virtual void Init() OVERRIDE;
virtual bool isLockable() { return true; } virtual bool isLockable() OVERRIDE { return true; }
private: private:
bool itsBrowseLocally; bool itsBrowseLocally;

View File

@@ -27,20 +27,22 @@
class Help : public Screen<NC::Scrollpad> class Help : public Screen<NC::Scrollpad>
{ {
public: public:
virtual void Resize(); virtual void Resize() OVERRIDE;
virtual void SwitchTo(); virtual void SwitchTo() OVERRIDE;
virtual std::basic_string<my_char_t> Title(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void EnterPressed() { } virtual void Update() OVERRIDE { }
virtual void SpacePressed() { }
virtual bool isTabbable() { return true; }
virtual bool isMergable() { return true; } virtual void EnterPressed() OVERRIDE { }
virtual void SpacePressed() OVERRIDE { }
virtual bool isTabbable() OVERRIDE { return true; }
virtual bool isMergable() OVERRIDE { return true; }
protected: protected:
virtual void Init(); virtual void Init() OVERRIDE;
virtual bool isLockable() { 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); }

View File

@@ -36,26 +36,29 @@ class Lastfm : public Screen<NC::Scrollpad>
public: public:
Lastfm() : isReadyToTake(0), isDownloadInProgress(0) { } Lastfm() : isReadyToTake(0), isDownloadInProgress(0) { }
virtual void SwitchTo(); // Screen<NC::Scrollpad>
virtual void Resize(); virtual void SwitchTo() OVERRIDE;
virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void Update(); virtual void Update() OVERRIDE;
virtual void EnterPressed() { } virtual void EnterPressed() OVERRIDE { }
virtual void SpacePressed() { } virtual void SpacePressed() OVERRIDE { }
virtual bool isMergable() { return true; } virtual bool isMergable() OVERRIDE { return true; }
virtual bool isTabbable() OVERRIDE { return false; }
// 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(); virtual void Init() OVERRIDE;
virtual bool isLockable() { return false; } virtual bool isLockable() OVERRIDE { return false; }
private: private:
std::basic_string<my_char_t> itsTitle; std::basic_string<my_char_t> itsTitle;

View File

@@ -37,18 +37,21 @@ class Lyrics : public Screen<NC::Scrollpad>
# endif // HAVE_CURL_CURL_H # endif // HAVE_CURL_CURL_H
itsScrollBegin(0) { } itsScrollBegin(0) { }
virtual void Resize(); // Screen<NC::Scrollpad> implementation
virtual void SwitchTo(); virtual void Resize() OVERRIDE;
virtual void SwitchTo() OVERRIDE;
virtual std::basic_string<my_char_t> Title(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void Update(); virtual void Update() OVERRIDE;
virtual void EnterPressed() { } virtual void EnterPressed() OVERRIDE { }
virtual void SpacePressed(); virtual void SpacePressed() OVERRIDE;
virtual bool isMergable() { return true; } virtual bool isMergable() OVERRIDE { return true; }
virtual bool isTabbable() OVERRIDE { return false; }
// private members
void Edit(); void Edit();
# ifdef HAVE_CURL_CURL_H # ifdef HAVE_CURL_CURL_H
@@ -61,8 +64,8 @@ class Lyrics : public Screen<NC::Scrollpad>
bool ReloadNP; bool ReloadNP;
protected: protected:
virtual void Init(); virtual void Init() OVERRIDE;
virtual bool isLockable() { return false; } virtual bool isLockable() OVERRIDE { return false; }
private: private:
void Load(); void Load();

View File

@@ -336,6 +336,11 @@ void MediaLibrary::Update()
} }
} }
void MediaLibrary::EnterPressed()
{
AddToPlaylist(true);
}
void MediaLibrary::SpacePressed() void MediaLibrary::SpacePressed()
{ {
if (Config.space_selects) if (Config.space_selects)

View File

@@ -27,39 +27,40 @@
class MediaLibrary : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable class MediaLibrary : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable
{ {
public: public:
virtual void SwitchTo(); virtual void SwitchTo() OVERRIDE;
virtual void Resize(); virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void Refresh(); virtual void Refresh() OVERRIDE;
virtual void Update(); virtual void Update() OVERRIDE;
virtual void EnterPressed() { AddToPlaylist(1); } virtual void EnterPressed() OVERRIDE;
virtual void SpacePressed(); virtual void SpacePressed() OVERRIDE;
virtual void MouseButtonPressed(MEVENT); virtual void MouseButtonPressed(MEVENT me) OVERRIDE;
virtual bool isTabbable() { return true; }
virtual bool isTabbable() OVERRIDE { return true; }
virtual bool isMergable() OVERRIDE { return true; }
/// Filterable implementation /// Filterable implementation
virtual bool allowsFiltering(); virtual bool allowsFiltering() OVERRIDE;
virtual std::string currentFilter(); virtual std::string currentFilter() OVERRIDE;
virtual void applyFilter(const std::string &filter); virtual void applyFilter(const std::string &filter) OVERRIDE;
/// Searchable implementation /// Searchable implementation
virtual bool allowsSearching(); virtual bool allowsSearching() OVERRIDE;
virtual bool search(const std::string &constraint); virtual bool search(const std::string &constraint) OVERRIDE;
virtual void nextFound(bool wrap); virtual void nextFound(bool wrap) OVERRIDE;
virtual void prevFound(bool wrap); virtual void prevFound(bool wrap) OVERRIDE;
/// HasSongs implementation /// HasSongs implementation
virtual std::shared_ptr<ProxySongList> getProxySongList(); virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
virtual bool allowsSelection(); virtual bool allowsSelection() OVERRIDE;
virtual void reverseSelection(); virtual void reverseSelection() OVERRIDE;
virtual MPD::SongList getSelectedSongs(); virtual MPD::SongList getSelectedSongs() OVERRIDE;
virtual bool isMergable() { return true; }
// private members
int Columns(); int Columns();
bool isNextColumnAvailable(); bool isNextColumnAvailable();
void NextColumn(); void NextColumn();

View File

@@ -283,16 +283,16 @@ template <typename T> struct Menu : public Window
/// Refreshes the menu window /// Refreshes the menu window
/// @see Window::Refresh() /// @see Window::Refresh()
virtual void refresh(); virtual void refresh() OVERRIDE;
/// Scrolls by given amount of lines /// Scrolls by given amount of lines
/// @param where indicated where exactly one wants to go /// @param where indicated where exactly one wants to go
/// @see Window::Scroll() /// @see Window::Scroll()
virtual void scroll(Where where); virtual void scroll(Where where) OVERRIDE;
/// Cleares all options, used filters etc. It doesn't reset highlighted position though. /// Cleares all options, used filters etc. It doesn't reset highlighted position though.
/// @see reset() /// @see reset()
virtual void clear(); virtual void clear() OVERRIDE;
/// Sets highlighted position to 0 /// Sets highlighted position to 0
void reset(); void reset();

View File

@@ -32,23 +32,28 @@
class Outputs : public Screen< NC::Menu<MPD::Output> > class Outputs : public Screen< NC::Menu<MPD::Output> >
{ {
public: public:
virtual void SwitchTo();
virtual void Resize();
virtual std::basic_string<my_char_t> Title(); // Screen< NC::Menu<MPD::Output> > implementation
virtual void SwitchTo() OVERRIDE;
virtual void Resize() OVERRIDE;
virtual void EnterPressed(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void SpacePressed() { }
virtual void MouseButtonPressed(MEVENT);
virtual bool isTabbable() { return true; }
virtual bool isMergable() { return true; } 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(); void FetchList();
protected: protected:
virtual void Init(); virtual void Init() OVERRIDE;
virtual bool isLockable() { return true; } virtual bool isLockable() OVERRIDE { return true; }
}; };
extern Outputs *myOutputs; extern Outputs *myOutputs;

View File

@@ -338,22 +338,6 @@ std::shared_ptr<ProxySongList> Playlist::getProxySongList()
return ptr; return ptr;
} }
MPD::Song *Playlist::getSong(size_t pos)
{
MPD::Song *ptr = 0;
if (w == Items)
ptr = &(*Items)[pos].value();
return ptr;
}
MPD::Song *Playlist::currentSong()
{
if (Items->empty())
return 0;
else
return getSong(Items->choice());
}
bool Playlist::allowsSelection() bool Playlist::allowsSelection()
{ {
return w == Items; return w == Items;

View File

@@ -35,38 +35,40 @@ class Playlist : public Screen<NC::Window>, public Filterable, public HasSongs,
Playlist() : NowPlaying(-1), itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0) { } Playlist() : NowPlaying(-1), itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0) { }
~Playlist() { } ~Playlist() { }
virtual void SwitchTo(); // Screen<NC::Window> implementation
virtual void Resize(); virtual void SwitchTo() OVERRIDE;
virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void EnterPressed(); virtual void Update() OVERRIDE { }
virtual void SpacePressed();
virtual void MouseButtonPressed(MEVENT);
virtual bool isTabbable() { return true; }
/// Filterable implementation virtual void EnterPressed() OVERRIDE;
virtual bool allowsFiltering(); virtual void SpacePressed() OVERRIDE;
virtual std::string currentFilter(); virtual void MouseButtonPressed(MEVENT me) OVERRIDE;
virtual void applyFilter(const std::string &filter);
/// Searchable implementation 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 allowsSearching();
virtual bool search(const std::string &constraint); virtual bool search(const std::string &constraint) OVERRIDE;
virtual void nextFound(bool wrap); virtual void nextFound(bool wrap) OVERRIDE;
virtual void prevFound(bool wrap); virtual void prevFound(bool wrap) OVERRIDE;
/// HasSongs implementation // HasSongs implementation
virtual MPD::Song *getSong(size_t pos); virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
virtual MPD::Song *currentSong();
virtual std::shared_ptr<ProxySongList> getProxySongList();
virtual bool allowsSelection(); virtual bool allowsSelection() OVERRIDE;
virtual void reverseSelection(); virtual void reverseSelection() OVERRIDE;
virtual MPD::SongList getSelectedSongs(); virtual MPD::SongList getSelectedSongs() OVERRIDE;
virtual bool isMergable() { return true; }
// private members
bool isFiltered(); bool isFiltered();
bool isPlaying() { return NowPlaying >= 0 && !Items->empty(); } bool isPlaying() { return NowPlaying >= 0 && !Items->empty(); }
const MPD::Song *NowPlayingSong(); const MPD::Song *NowPlayingSong();
@@ -93,9 +95,6 @@ class Playlist : public Screen<NC::Window>, public Filterable, public HasSongs,
void registerHash(size_t hash); void registerHash(size_t hash);
void unregisterHash(size_t hash); void unregisterHash(size_t hash);
//static std::string SongToString(const MPD::Song &s);
//static std::string SongInColumnsToString(const MPD::Song &s);
NC::Menu< MPD::Song > *Items; NC::Menu< MPD::Song > *Items;
int NowPlaying; int NowPlaying;
@@ -104,8 +103,8 @@ class Playlist : public Screen<NC::Window>, public Filterable, public HasSongs,
static bool ReloadRemaining; static bool ReloadRemaining;
protected: protected:
virtual void Init(); virtual void Init() OVERRIDE;
virtual bool isLockable() { return true; } virtual bool isLockable() OVERRIDE { return true; }
private: private:
std::string TotalLength(); std::string TotalLength();

View File

@@ -312,6 +312,11 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play)
w->scroll(NC::wDown); w->scroll(NC::wDown);
} }
void PlaylistEditor::EnterPressed()
{
AddToPlaylist(true);
}
void PlaylistEditor::SpacePressed() void PlaylistEditor::SpacePressed()
{ {
if (Config.space_selects) if (Config.space_selects)

View File

@@ -26,41 +26,42 @@
class PlaylistEditor : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable class PlaylistEditor : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable
{ {
public: public:
virtual void SwitchTo(); virtual void SwitchTo() OVERRIDE;
virtual void Resize(); virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void Refresh(); virtual void Refresh() OVERRIDE;
virtual void Update(); virtual void Update() OVERRIDE;
virtual void EnterPressed() { AddToPlaylist(1); } virtual void EnterPressed() OVERRIDE;
virtual void SpacePressed(); virtual void SpacePressed() OVERRIDE;
virtual void MouseButtonPressed(MEVENT); virtual void MouseButtonPressed(MEVENT me) OVERRIDE;
virtual bool isTabbable() { return true; }
virtual bool isTabbable() OVERRIDE { return true; }
virtual bool isMergable() OVERRIDE { return true; }
/// Filterable implementation /// Filterable implementation
virtual bool allowsFiltering(); virtual bool allowsFiltering() OVERRIDE;
virtual std::string currentFilter(); virtual std::string currentFilter() OVERRIDE;
virtual void applyFilter(const std::string &filter); virtual void applyFilter(const std::string &filter) OVERRIDE;
/// Searchable implementation /// Searchable implementation
virtual bool allowsSearching(); virtual bool allowsSearching() OVERRIDE;
virtual bool search(const std::string &constraint); virtual bool search(const std::string &constraint) OVERRIDE;
virtual void nextFound(bool wrap); virtual void nextFound(bool wrap) OVERRIDE;
virtual void prevFound(bool wrap); virtual void prevFound(bool wrap) OVERRIDE;
/// HasSongs implementation /// HasSongs implementation
virtual std::shared_ptr<ProxySongList> getProxySongList(); virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
virtual bool allowsSelection(); virtual bool allowsSelection() OVERRIDE;
virtual void reverseSelection(); virtual void reverseSelection() OVERRIDE;
virtual MPD::SongList getSelectedSongs(); virtual MPD::SongList getSelectedSongs() OVERRIDE;
// private members
virtual void Locate(const std::string &); virtual void Locate(const std::string &);
virtual bool isMergable() { return true; }
void MoveSelectedItems(Playlist::Movement where); void MoveSelectedItems(Playlist::Movement where);
void requestPlaylistsUpdate() { playlistsUpdateRequested = true; } void requestPlaylistsUpdate() { playlistsUpdateRequested = true; }
@@ -78,8 +79,8 @@ class PlaylistEditor : public Screen<NC::Window>, public Filterable, public HasS
NC::Menu<MPD::Song> *Content; NC::Menu<MPD::Song> *Content;
protected: protected:
virtual void Init(); virtual void Init() OVERRIDE;
virtual bool isLockable() { return true; } virtual bool isLockable() OVERRIDE { return true; }
private: private:
void AddToPlaylist(bool); void AddToPlaylist(bool);

View File

@@ -30,12 +30,10 @@ void ScrollpadMouseButtonPressed(NC::Scrollpad *w, MEVENT me);
/// An interface for various instantiations of Screen template class. Since C++ doesn't like /// An interface for various instantiations of Screen template class. Since C++ doesn't like
/// comparison of two different instantiations of the same template class we need the most /// comparison of two different instantiations of the same template class we need the most
/// basic class to be non-template to allow it. /// basic class to be non-template to allow it.
///
class BasicScreen class BasicScreen
{ {
public: public:
/// Initializes all variables to zero /// Initializes all variables to zero
///
BasicScreen() : hasToBeResized(0), isInitialized(0) { } BasicScreen() : hasToBeResized(0), isInitialized(0) { }
virtual ~BasicScreen() { } virtual ~BasicScreen() { }
@@ -43,6 +41,15 @@ class BasicScreen
/// @see Screen::ActiveWindow() /// @see Screen::ActiveWindow()
virtual NC::Window *ActiveWindow() = 0; virtual NC::Window *ActiveWindow() = 0;
/// @see Screen::Refresh()
virtual void Refresh() = 0;
/// @see Screen::RefreshWindow()
virtual void RefreshWindow() = 0;
/// @see Screen::Scroll()
virtual void Scroll(NC::Where where) = 0;
/// Method used for switching to screen /// Method used for switching to screen
virtual void SwitchTo() = 0; virtual void SwitchTo() = 0;
@@ -55,16 +62,7 @@ class BasicScreen
/// If the screen contantly has to update itself /// If the screen contantly has to update itself
/// somehow, it should be called by this function. /// somehow, it should be called by this function.
virtual void Update() { } virtual void Update() = 0;
/// @see Screen::Refresh()
virtual void Refresh() = 0;
/// @see Screen::RefreshWindow()
virtual void RefreshWindow() = 0;
/// @see Screen::Scroll()
virtual void Scroll(NC::Where where) = 0;
/// Invoked after Enter was pressed /// Invoked after Enter was pressed
virtual void EnterPressed() = 0; virtual void EnterPressed() = 0;
@@ -73,11 +71,11 @@ class BasicScreen
virtual void SpacePressed() = 0; virtual void SpacePressed() = 0;
/// @see Screen::MouseButtonPressed() /// @see Screen::MouseButtonPressed()
virtual void MouseButtonPressed(MEVENT) { } virtual void MouseButtonPressed(MEVENT me) = 0;
/// When this is overwritten with a function returning true, the /// When this is overwritten with a function returning true, the
/// screen will be used in tab switching. /// screen will be used in tab switching.
virtual bool isTabbable() { return false; } virtual bool isTabbable() = 0;
/// @return true if screen is mergable, ie. can be "proper" subwindow /// @return true if screen is mergable, ie. can be "proper" subwindow
/// if one of the screens is locked. Screens that somehow resemble popups /// if one of the screens is locked. Screens that somehow resemble popups
@@ -100,7 +98,6 @@ class BasicScreen
/// this in the constructor. This function should be invoked /// this in the constructor. This function should be invoked
/// only once and after that isInitialized flag has to be set /// only once and after that isInitialized flag has to be set
/// to true to somehow avoid next attempt of initialization. /// to true to somehow avoid next attempt of initialization.
///
virtual void Init() = 0; virtual void Init() = 0;
/// @return true if screen can be locked. Note that returning /// @return true if screen can be locked. Note that returning
@@ -116,7 +113,6 @@ class BasicScreen
void GetWindowResizeParams(size_t &x_offset, size_t &width, bool adjust_locked_screen = true); void GetWindowResizeParams(size_t &x_offset, size_t &width, bool adjust_locked_screen = true);
/// Flag that inditates whether the screen is initialized or not /// Flag that inditates whether the screen is initialized or not
///
bool isInitialized; bool isInitialized;
}; };
@@ -138,27 +134,39 @@ template <typename WindowType> class Screen : public BasicScreen
/// it's useful to determine the one that is being /// it's useful to determine the one that is being
/// active /// active
/// @return address to window object cast to void * /// @return address to window object cast to void *
virtual NC::Window *ActiveWindow(); virtual NC::Window *ActiveWindow() OVERRIDE {
return w;
/// @return pointer to currently active window }
WindowType *Main();
/// Refreshes whole screen /// Refreshes whole screen
virtual void Refresh(); virtual void Refresh() OVERRIDE {
w->display();
}
/// Refreshes active window of the screen /// Refreshes active window of the screen
virtual void RefreshWindow(); virtual void RefreshWindow() OVERRIDE {
w->display();
}
/// Scrolls the screen by given amount of lines and /// Scrolls the screen by given amount of lines and
/// if fancy scrolling feature is disabled, enters the /// if fancy scrolling feature is disabled, enters the
/// loop that holds main loop until user releases the key /// loop that holds main loop until user releases the key
/// @param where indicates where one wants to scroll /// @param where indicates where one wants to scroll
virtual void Scroll(NC::Where where); virtual void Scroll(NC::Where where) OVERRIDE {
w->scroll(where);
}
/// Invoked after there was one of mouse buttons pressed /// Invoked after there was one of mouse buttons pressed
/// @param me struct that contains coords of where the click /// @param me struct that contains coords of where the click
/// had its place and button actions /// had its place and button actions
virtual void MouseButtonPressed(MEVENT me); virtual void MouseButtonPressed(MEVENT me) OVERRIDE {
GenericMouseButtonPressed(w, me);
}
/// @return pointer to currently active window
WindowType *Main() {
return w;
}
protected: protected:
/// Template parameter that should indicate the main type /// Template parameter that should indicate the main type
@@ -168,36 +176,6 @@ template <typename WindowType> class Screen : public BasicScreen
WindowType *w; WindowType *w;
}; };
template <typename WindowType> NC::Window *Screen<WindowType>::ActiveWindow()
{
return w;
}
template <typename WindowType> WindowType *Screen<WindowType>::Main()
{
return w;
}
template <typename WindowType> void Screen<WindowType>::Refresh()
{
w->display();
}
template <typename WindowType> void Screen<WindowType>::RefreshWindow()
{
w->display();
}
template <typename WindowType> void Screen<WindowType>::Scroll(NC::Where where)
{
w->scroll(where);
}
template <typename WindowType> void Screen<WindowType>::MouseButtonPressed(MEVENT me)
{
GenericMouseButtonPressed(w, me);
}
/// Specialization for Screen<Scrollpad>::MouseButtonPressed, that should /// Specialization for Screen<Scrollpad>::MouseButtonPressed, that should
/// not scroll whole page, but rather a few lines (the number of them is /// not scroll whole page, but rather a few lines (the number of them is
/// defined in the config) /// defined in the config)

View File

@@ -79,25 +79,25 @@ struct Scrollpad: public Window
/// Refreshes the window /// Refreshes the window
/// @see Window::Refresh() /// @see Window::Refresh()
/// ///
virtual void refresh(); virtual void refresh() OVERRIDE;
/// Scrolls by given amount of lines /// Scrolls by given amount of lines
/// @param where indicates where exactly one wants to go /// @param where indicates where exactly one wants to go
/// @see Window::Scroll() /// @see Window::Scroll()
/// ///
virtual void scroll(Where where); virtual void scroll(Where where) OVERRIDE;
/// Resizes the window /// Resizes the window
/// @param new_width new window's width /// @param new_width new window's width
/// @param new_height new window's height /// @param new_height new window's height
/// @see Window::Resize() /// @see Window::Resize()
/// ///
virtual void resize(size_t new_width, size_t new_height); virtual void resize(size_t new_width, size_t new_height) OVERRIDE;
/// Cleares the content of scrollpad /// Cleares the content of scrollpad
/// @see Window::clear() /// @see Window::clear()
/// ///
virtual void clear(); virtual void clear() OVERRIDE;
/// Sets starting position to the beginning /// Sets starting position to the beginning
/// ///

View File

@@ -76,43 +76,48 @@ struct SEItem
class SearchEngine : public Screen< NC::Menu<SEItem> >, public Filterable, public HasSongs, public Searchable class SearchEngine : public Screen< NC::Menu<SEItem> >, public Filterable, public HasSongs, public Searchable
{ {
public: public:
virtual void Resize(); // Screen< NC::Menu<SEItem> > implementation
virtual void SwitchTo(); virtual void Resize() OVERRIDE;
virtual void SwitchTo() OVERRIDE;
virtual std::basic_string<my_char_t> Title(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void EnterPressed(); virtual void Update() OVERRIDE { }
virtual void SpacePressed();
virtual void MouseButtonPressed(MEVENT);
virtual bool isTabbable() { return true; }
/// Filterable implementation virtual void EnterPressed() OVERRIDE;
virtual bool allowsFiltering(); virtual void SpacePressed() OVERRIDE;
virtual std::string currentFilter(); virtual void MouseButtonPressed(MEVENT me) OVERRIDE;
virtual void applyFilter(const std::string &filter);
/// Searchable implementation virtual bool isTabbable() OVERRIDE { return true; }
virtual bool allowsSearching(); virtual bool isMergable() OVERRIDE { return true; }
virtual bool search(const std::string &constraint);
virtual void nextFound(bool wrap);
virtual void prevFound(bool wrap);
/// HasSongs implementation // Filterable implementation
virtual std::shared_ptr<ProxySongList> getProxySongList(); virtual bool allowsFiltering() OVERRIDE;
virtual std::string currentFilter() OVERRIDE;
virtual void applyFilter(const std::string &filter) OVERRIDE;
virtual bool allowsSelection(); // Searchable implementation
virtual void reverseSelection(); virtual bool allowsSearching() OVERRIDE;
virtual MPD::SongList getSelectedSongs(); virtual bool search(const std::string &constraint) OVERRIDE;
virtual void nextFound(bool wrap) OVERRIDE;
virtual void prevFound(bool wrap) OVERRIDE;
virtual bool isMergable() { return true; } // HasSongs implementation
virtual std::shared_ptr<ProxySongList> getProxySongList() OVERRIDE;
virtual bool allowsSelection() OVERRIDE;
virtual void reverseSelection() OVERRIDE;
virtual MPD::SongList getSelectedSongs() OVERRIDE;
// 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(); virtual void Init() OVERRIDE;
virtual bool isLockable() { return true; } virtual bool isLockable() OVERRIDE { return true; }
private: private:
void Prepare(); void Prepare();

View File

@@ -28,21 +28,25 @@ class SelectedItemsAdder : public Screen< NC::Menu<std::string> >
public: public:
SelectedItemsAdder() : itsPSWidth(35), itsPSHeight(11) { } SelectedItemsAdder() : itsPSWidth(35), itsPSHeight(11) { }
virtual void SwitchTo(); // Screen< NC::Menu<std::string> > implementation
virtual void Resize(); virtual void SwitchTo() OVERRIDE;
virtual void Refresh(); virtual void Resize() OVERRIDE;
virtual void Refresh() OVERRIDE;
virtual std::basic_string<my_char_t> Title(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void EnterPressed(); virtual void Update() OVERRIDE { }
virtual void SpacePressed() { }
virtual void MouseButtonPressed(MEVENT);
virtual bool isMergable() { return false; } 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: protected:
virtual void Init(); virtual void Init() OVERRIDE;
virtual bool isLockable() { return false; } virtual bool isLockable() OVERRIDE { return false; }
private: private:
void SetDimensions(); void SetDimensions();

View File

@@ -26,21 +26,23 @@
class ServerInfo : public Screen<NC::Scrollpad> class ServerInfo : public Screen<NC::Scrollpad>
{ {
public: public:
virtual void SwitchTo(); // Screen<NC::Scrollpad> implementation
virtual void Resize(); virtual void SwitchTo() OVERRIDE;
virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void Update(); virtual void Update() OVERRIDE;
virtual void EnterPressed() { } virtual void EnterPressed() OVERRIDE { }
virtual void SpacePressed() { } virtual void SpacePressed() OVERRIDE { }
virtual bool isMergable() { return false; } virtual bool isMergable() OVERRIDE { return false; }
virtual bool isTabbable() OVERRIDE { return false; }
protected: protected:
virtual void Init(); virtual void Init() OVERRIDE;
virtual bool isLockable() { return false; } virtual bool isLockable() OVERRIDE { return false; }
private: private:
void SetDimensions(); void SetDimensions();

View File

@@ -34,21 +34,27 @@ class SongInfo : public Screen<NC::Scrollpad>
MPD::MutableSong::SetFunction Set; MPD::MutableSong::SetFunction Set;
}; };
virtual void SwitchTo(); // Screen<NC::Scrollpad> implementation
virtual void Resize(); virtual void SwitchTo() OVERRIDE;
virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void EnterPressed() { } virtual void Update() OVERRIDE { }
virtual void SpacePressed() { }
virtual bool isMergable() { return true; } 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[]; static const Metadata Tags[];
protected: protected:
virtual void Init(); virtual void Init() OVERRIDE;
virtual bool isLockable() { return false; } virtual bool isLockable() OVERRIDE { return false; }
private: private:
void PrepareSong(MPD::Song &); void PrepareSong(MPD::Song &);

View File

@@ -34,22 +34,27 @@
class TinyTagEditor : public Screen< NC::Menu<NC::Buffer> > class TinyTagEditor : public Screen< NC::Menu<NC::Buffer> >
{ {
public: public:
virtual void Resize(); // Screen< NC::Menu<NC::Buffer> > implementation
virtual void SwitchTo(); virtual void Resize() OVERRIDE;
virtual void SwitchTo() OVERRIDE;
virtual std::basic_string<my_char_t> Title(); virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual void EnterPressed(); virtual void Update() OVERRIDE { }
virtual void SpacePressed() { }
virtual void MouseButtonPressed(MEVENT);
virtual bool isMergable() { return true; } 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 &); void SetEdited(const MPD::Song &);
protected: protected:
virtual void Init(); virtual void Init() OVERRIDE;
virtual bool isLockable() { return true; } virtual bool isLockable() OVERRIDE { return true; }
private: private:
bool getTags(); bool getTags();