media library: fix filter issues

This commit is contained in:
Andrzej Rybczak
2010-08-16 13:46:57 +02:00
parent 17c340408f
commit 2aa053d7e1
3 changed files with 19 additions and 11 deletions

View File

@@ -182,7 +182,7 @@ std::basic_string<my_char_t> 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)

View File

@@ -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;

View File

@@ -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;