diff --git a/src/media_library.cpp b/src/media_library.cpp index 746b2429..9976bdf7 100644 --- a/src/media_library.cpp +++ b/src/media_library.cpp @@ -182,7 +182,7 @@ std::basic_string MediaLibrary::Title() void MediaLibrary::Update() { - if (!hasTwoColumns && Artists->Empty()) + if (!hasTwoColumns && Artists->ReallyEmpty()) { MPD::TagList list; Albums->Clear(); @@ -201,7 +201,7 @@ void MediaLibrary::Update() Artists->Refresh(); } - if (!hasTwoColumns && !Artists->Empty() && Albums->Empty() && Songs->Empty()) + if (!hasTwoColumns && !Artists->ReallyEmpty() && Albums->ReallyEmpty() && Songs->ReallyEmpty()) { // idle has to be blocked for now since it would be enabled and // disabled a few times by each mpd command, which makes no sense @@ -247,7 +247,7 @@ void MediaLibrary::Update() Albums->Refresh(); Mpd.BlockIdle(0); } - else if (hasTwoColumns && Albums->Empty()) + else if (hasTwoColumns && Albums->ReallyEmpty()) { Songs->Clear(); MPD::TagList artists; @@ -303,14 +303,14 @@ void MediaLibrary::Update() Albums->Refresh(); } - if (!hasTwoColumns && !Artists->Empty() && w == Albums && Albums->Empty()) + if (!hasTwoColumns && !Artists->ReallyEmpty() && w == Albums && Albums->ReallyEmpty()) { Albums->HighlightColor(Config.main_highlight_color); Artists->HighlightColor(Config.active_column_color); w = Artists; } - if (!(hasTwoColumns ? Albums->Empty() : Artists->Empty()) && Songs->Empty()) + if (!(hasTwoColumns ? Albums->ReallyEmpty() : Artists->ReallyEmpty()) && Songs->ReallyEmpty()) { Songs->Reset(); MPD::SongList list; @@ -545,16 +545,16 @@ void MediaLibrary::NextColumn() { if (w == Artists) { - if (!hasTwoColumns && Songs->Empty()) + if (!hasTwoColumns && Songs->ReallyEmpty()) return; Artists->HighlightColor(Config.main_highlight_color); w->Refresh(); w = Albums; Albums->HighlightColor(Config.active_column_color); - if (!Albums->Empty()) + if (!Albums->ReallyEmpty()) return; } - if (w == Albums && !Songs->Empty()) + if (w == Albums && !Songs->ReallyEmpty()) { Albums->HighlightColor(Config.main_highlight_color); w->Refresh(); @@ -571,7 +571,7 @@ void MediaLibrary::PrevColumn() w->Refresh(); w = Albums; Albums->HighlightColor(Config.active_column_color); - if (!Albums->Empty()) + if (!Albums->ReallyEmpty()) return; } if (w == Albums && !hasTwoColumns) diff --git a/src/menu.h b/src/menu.h index ecb2e7e1..123adb33 100644 --- a/src/menu.h +++ b/src/menu.h @@ -448,9 +448,17 @@ namespace NCurses /// Checks if list is empty /// @return true if list is empty, false otherwise + /// @see ReallyEmpty() /// virtual bool Empty() const { return itsOptionsPtr->empty(); } + /// Checks if list is really empty since Empty() may not + /// be accurate if filter is set) + /// @return true if list is empty, false otherwise + /// @see Empty() + /// + virtual bool ReallyEmpty() const { return itsOptions.empty(); } + /// @return size of the list /// virtual size_t Size() const; diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 96e68666..2423ff3f 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -1461,7 +1461,7 @@ int main(int argc, char *argv[]) { myTinyTagEditor->SwitchTo(); } - else if (myScreen->ActiveWindow() == myLibrary->Artists) + else if (myScreen->ActiveWindow() == myLibrary->Artists && !myLibrary->Artists->Empty()) { LockStatusbar(); Statusbar() << fmtBold << IntoStr(Config.media_lib_primary_tag) << fmtBoldEnd << ": "; @@ -1500,7 +1500,7 @@ int main(int argc, char *argv[]) FreeSongList(list); } } - else if (myScreen->ActiveWindow() == myLibrary->Albums) + else if (myScreen->ActiveWindow() == myLibrary->Albums && !myLibrary->Albums->Empty()) { LockStatusbar(); Statusbar() << fmtBold << "Album: " << fmtBoldEnd;