|
|
|
@@ -121,31 +121,31 @@ MediaLibrary::MediaLibrary()
|
|
|
|
itsRightColWidth = COLS-COLS/3*2-1;
|
|
|
|
itsRightColWidth = COLS-COLS/3*2-1;
|
|
|
|
itsRightColStartX = itsLeftColWidth+itsMiddleColWidth+2;
|
|
|
|
itsRightColStartX = itsLeftColWidth+itsMiddleColWidth+2;
|
|
|
|
|
|
|
|
|
|
|
|
Tags = new NC::Menu<std::string>(0, MainStartY, itsLeftColWidth, MainHeight, Config.titles_visibility ? tagTypeToString(Config.media_lib_primary_tag) + "s" : "", Config.main_color, NC::brNone);
|
|
|
|
Tags = NC::Menu<std::string>(0, MainStartY, itsLeftColWidth, MainHeight, Config.titles_visibility ? tagTypeToString(Config.media_lib_primary_tag) + "s" : "", Config.main_color, NC::brNone);
|
|
|
|
Tags->setHighlightColor(Config.active_column_color);
|
|
|
|
Tags.setHighlightColor(Config.active_column_color);
|
|
|
|
Tags->cyclicScrolling(Config.use_cyclic_scrolling);
|
|
|
|
Tags.cyclicScrolling(Config.use_cyclic_scrolling);
|
|
|
|
Tags->centeredCursor(Config.centered_cursor);
|
|
|
|
Tags.centeredCursor(Config.centered_cursor);
|
|
|
|
Tags->setSelectedPrefix(Config.selected_item_prefix);
|
|
|
|
Tags.setSelectedPrefix(Config.selected_item_prefix);
|
|
|
|
Tags->setSelectedSuffix(Config.selected_item_suffix);
|
|
|
|
Tags.setSelectedSuffix(Config.selected_item_suffix);
|
|
|
|
Tags->setItemDisplayer(DisplayPrimaryTags);
|
|
|
|
Tags.setItemDisplayer(DisplayPrimaryTags);
|
|
|
|
|
|
|
|
|
|
|
|
Albums = new NC::Menu<SearchConstraints>(itsMiddleColStartX, MainStartY, itsMiddleColWidth, MainHeight, Config.titles_visibility ? "Albums" : "", Config.main_color, NC::brNone);
|
|
|
|
Albums = NC::Menu<SearchConstraints>(itsMiddleColStartX, MainStartY, itsMiddleColWidth, MainHeight, Config.titles_visibility ? "Albums" : "", Config.main_color, NC::brNone);
|
|
|
|
Albums->setHighlightColor(Config.main_highlight_color);
|
|
|
|
Albums.setHighlightColor(Config.main_highlight_color);
|
|
|
|
Albums->cyclicScrolling(Config.use_cyclic_scrolling);
|
|
|
|
Albums.cyclicScrolling(Config.use_cyclic_scrolling);
|
|
|
|
Albums->centeredCursor(Config.centered_cursor);
|
|
|
|
Albums.centeredCursor(Config.centered_cursor);
|
|
|
|
Albums->setSelectedPrefix(Config.selected_item_prefix);
|
|
|
|
Albums.setSelectedPrefix(Config.selected_item_prefix);
|
|
|
|
Albums->setSelectedSuffix(Config.selected_item_suffix);
|
|
|
|
Albums.setSelectedSuffix(Config.selected_item_suffix);
|
|
|
|
Albums->setItemDisplayer(DisplayAlbums);
|
|
|
|
Albums.setItemDisplayer(DisplayAlbums);
|
|
|
|
|
|
|
|
|
|
|
|
Songs = new NC::Menu<MPD::Song>(itsRightColStartX, MainStartY, itsRightColWidth, MainHeight, Config.titles_visibility ? "Songs" : "", Config.main_color, NC::brNone);
|
|
|
|
Songs = NC::Menu<MPD::Song>(itsRightColStartX, MainStartY, itsRightColWidth, MainHeight, Config.titles_visibility ? "Songs" : "", Config.main_color, NC::brNone);
|
|
|
|
Songs->setHighlightColor(Config.main_highlight_color);
|
|
|
|
Songs.setHighlightColor(Config.main_highlight_color);
|
|
|
|
Songs->cyclicScrolling(Config.use_cyclic_scrolling);
|
|
|
|
Songs.cyclicScrolling(Config.use_cyclic_scrolling);
|
|
|
|
Songs->centeredCursor(Config.centered_cursor);
|
|
|
|
Songs.centeredCursor(Config.centered_cursor);
|
|
|
|
Songs->setSelectedPrefix(Config.selected_item_prefix);
|
|
|
|
Songs.setSelectedPrefix(Config.selected_item_prefix);
|
|
|
|
Songs->setSelectedSuffix(Config.selected_item_suffix);
|
|
|
|
Songs.setSelectedSuffix(Config.selected_item_suffix);
|
|
|
|
Songs->setItemDisplayer(std::bind(Display::Songs, _1, this, Config.song_library_format));
|
|
|
|
Songs.setItemDisplayer(std::bind(Display::Songs, _1, this, Config.song_library_format));
|
|
|
|
|
|
|
|
|
|
|
|
w = Tags;
|
|
|
|
w = &Tags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MediaLibrary::resize()
|
|
|
|
void MediaLibrary::resize()
|
|
|
|
@@ -169,28 +169,28 @@ void MediaLibrary::resize()
|
|
|
|
itsRightColWidth = width-itsMiddleColWidth-1;
|
|
|
|
itsRightColWidth = width-itsMiddleColWidth-1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Tags->resize(itsLeftColWidth, MainHeight);
|
|
|
|
Tags.resize(itsLeftColWidth, MainHeight);
|
|
|
|
Albums->resize(itsMiddleColWidth, MainHeight);
|
|
|
|
Albums.resize(itsMiddleColWidth, MainHeight);
|
|
|
|
Songs->resize(itsRightColWidth, MainHeight);
|
|
|
|
Songs.resize(itsRightColWidth, MainHeight);
|
|
|
|
|
|
|
|
|
|
|
|
Tags->moveTo(itsLeftColStartX, MainStartY);
|
|
|
|
Tags.moveTo(itsLeftColStartX, MainStartY);
|
|
|
|
Albums->moveTo(itsMiddleColStartX, MainStartY);
|
|
|
|
Albums.moveTo(itsMiddleColStartX, MainStartY);
|
|
|
|
Songs->moveTo(itsRightColStartX, MainStartY);
|
|
|
|
Songs.moveTo(itsRightColStartX, MainStartY);
|
|
|
|
|
|
|
|
|
|
|
|
hasToBeResized = 0;
|
|
|
|
hasToBeResized = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MediaLibrary::refresh()
|
|
|
|
void MediaLibrary::refresh()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Tags->display();
|
|
|
|
Tags.display();
|
|
|
|
mvvline(MainStartY, itsMiddleColStartX-1, 0, MainHeight);
|
|
|
|
mvvline(MainStartY, itsMiddleColStartX-1, 0, MainHeight);
|
|
|
|
Albums->display();
|
|
|
|
Albums.display();
|
|
|
|
mvvline(MainStartY, itsRightColStartX-1, 0, MainHeight);
|
|
|
|
mvvline(MainStartY, itsRightColStartX-1, 0, MainHeight);
|
|
|
|
Songs->display();
|
|
|
|
Songs.display();
|
|
|
|
if (Albums->empty())
|
|
|
|
if (Albums.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
*Albums << NC::XY(0, 0) << "No albums found.";
|
|
|
|
Albums << NC::XY(0, 0) << "No albums found.";
|
|
|
|
Albums->Window::refresh();
|
|
|
|
Albums.Window::refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -206,24 +206,24 @@ void MediaLibrary::switchTo()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hasTwoColumns = !hasTwoColumns;
|
|
|
|
hasTwoColumns = !hasTwoColumns;
|
|
|
|
hasToBeResized = 1;
|
|
|
|
hasToBeResized = 1;
|
|
|
|
Tags->clear();
|
|
|
|
Tags.clear();
|
|
|
|
Albums->clear();
|
|
|
|
Albums.clear();
|
|
|
|
Albums->reset();
|
|
|
|
Albums.reset();
|
|
|
|
Songs->clear();
|
|
|
|
Songs.clear();
|
|
|
|
if (hasTwoColumns)
|
|
|
|
if (hasTwoColumns)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
nextColumn();
|
|
|
|
nextColumn();
|
|
|
|
if (Config.titles_visibility)
|
|
|
|
if (Config.titles_visibility)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string item_type = lowercase(tagTypeToString(Config.media_lib_primary_tag));
|
|
|
|
std::string item_type = lowercase(tagTypeToString(Config.media_lib_primary_tag));
|
|
|
|
Albums->setTitle("Albums (sorted by " + item_type + ")");
|
|
|
|
Albums.setTitle("Albums (sorted by " + item_type + ")");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
Albums->setTitle("");
|
|
|
|
Albums.setTitle("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
Albums->setTitle(Config.titles_visibility ? "Albums" : "");
|
|
|
|
Albums.setTitle(Config.titles_visibility ? "Albums" : "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -248,10 +248,10 @@ std::wstring MediaLibrary::title()
|
|
|
|
|
|
|
|
|
|
|
|
void MediaLibrary::update()
|
|
|
|
void MediaLibrary::update()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!hasTwoColumns && Tags->reallyEmpty())
|
|
|
|
if (!hasTwoColumns && Tags.reallyEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Albums->clear();
|
|
|
|
Albums.clear();
|
|
|
|
Songs->clear();
|
|
|
|
Songs.clear();
|
|
|
|
auto list = Mpd.GetList(Config.media_lib_primary_tag);
|
|
|
|
auto list = Mpd.GetList(Config.media_lib_primary_tag);
|
|
|
|
std::sort(list.begin(), list.end(),
|
|
|
|
std::sort(list.begin(), list.end(),
|
|
|
|
LocaleBasedSorting(std::locale(), Config.ignore_leading_the));
|
|
|
|
LocaleBasedSorting(std::locale(), Config.ignore_leading_the));
|
|
|
|
@@ -259,50 +259,50 @@ void MediaLibrary::update()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (it->empty() && !Config.media_library_display_empty_tag)
|
|
|
|
if (it->empty() && !Config.media_library_display_empty_tag)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
Tags->addItem(*it);
|
|
|
|
Tags.addItem(*it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Tags->refresh();
|
|
|
|
Tags.refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasTwoColumns && !Tags->empty() && Albums->reallyEmpty() && Songs->reallyEmpty())
|
|
|
|
if (!hasTwoColumns && !Tags.empty() && Albums.reallyEmpty() && Songs.reallyEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// idle has to be blocked for now since it would be enabled and
|
|
|
|
// 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
|
|
|
|
// disabled a few times by each mpd command, which makes no sense
|
|
|
|
// and slows down the whole process.
|
|
|
|
// and slows down the whole process.
|
|
|
|
Mpd.BlockIdle(true);
|
|
|
|
Mpd.BlockIdle(true);
|
|
|
|
Albums->reset();
|
|
|
|
Albums.reset();
|
|
|
|
Mpd.StartFieldSearch(MPD_TAG_ALBUM);
|
|
|
|
Mpd.StartFieldSearch(MPD_TAG_ALBUM);
|
|
|
|
Mpd.AddSearch(Config.media_lib_primary_tag, Tags->current().value());
|
|
|
|
Mpd.AddSearch(Config.media_lib_primary_tag, Tags.current().value());
|
|
|
|
auto albums = Mpd.CommitSearchTags();
|
|
|
|
auto albums = Mpd.CommitSearchTags();
|
|
|
|
for (auto album = albums.begin(); album != albums.end(); ++album)
|
|
|
|
for (auto album = albums.begin(); album != albums.end(); ++album)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (Config.media_library_display_date)
|
|
|
|
if (Config.media_library_display_date)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Mpd.StartFieldSearch(MPD_TAG_DATE);
|
|
|
|
Mpd.StartFieldSearch(MPD_TAG_DATE);
|
|
|
|
Mpd.AddSearch(Config.media_lib_primary_tag, Tags->current().value());
|
|
|
|
Mpd.AddSearch(Config.media_lib_primary_tag, Tags.current().value());
|
|
|
|
Mpd.AddSearch(MPD_TAG_ALBUM, *album);
|
|
|
|
Mpd.AddSearch(MPD_TAG_ALBUM, *album);
|
|
|
|
auto dates = Mpd.CommitSearchTags();
|
|
|
|
auto dates = Mpd.CommitSearchTags();
|
|
|
|
for (auto date = dates.begin(); date != dates.end(); ++date)
|
|
|
|
for (auto date = dates.begin(); date != dates.end(); ++date)
|
|
|
|
Albums->addItem(SearchConstraints(*album, *date));
|
|
|
|
Albums.addItem(SearchConstraints(*album, *date));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
Albums->addItem(SearchConstraints(*album, ""));
|
|
|
|
Albums.addItem(SearchConstraints(*album, ""));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!Albums->empty())
|
|
|
|
if (!Albums.empty())
|
|
|
|
std::sort(Albums->beginV(), Albums->endV(), SortSearchConstraints());
|
|
|
|
std::sort(Albums.beginV(), Albums.endV(), SortSearchConstraints());
|
|
|
|
if (Albums->size() > 1)
|
|
|
|
if (Albums.size() > 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Albums->addSeparator();
|
|
|
|
Albums.addSeparator();
|
|
|
|
Albums->addItem(SearchConstraints("", AllTracksMarker));
|
|
|
|
Albums.addItem(SearchConstraints("", AllTracksMarker));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Albums->refresh();
|
|
|
|
Albums.refresh();
|
|
|
|
Mpd.BlockIdle(false);
|
|
|
|
Mpd.BlockIdle(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (hasTwoColumns && Albums->reallyEmpty())
|
|
|
|
else if (hasTwoColumns && Albums.reallyEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Songs->clear();
|
|
|
|
Songs.clear();
|
|
|
|
*Albums << NC::XY(0, 0) << "Fetching albums...";
|
|
|
|
Albums << NC::XY(0, 0) << "Fetching albums...";
|
|
|
|
Albums->Window::refresh();
|
|
|
|
Albums.Window::refresh();
|
|
|
|
Mpd.BlockIdle(true);
|
|
|
|
Mpd.BlockIdle(true);
|
|
|
|
auto artists = Mpd.GetList(Config.media_lib_primary_tag);
|
|
|
|
auto artists = Mpd.GetList(Config.media_lib_primary_tag);
|
|
|
|
for (auto artist = artists.begin(); artist != artists.end(); ++artist)
|
|
|
|
for (auto artist = artists.begin(); artist != artists.end(); ++artist)
|
|
|
|
@@ -321,50 +321,50 @@ void MediaLibrary::update()
|
|
|
|
Mpd.AddSearch(MPD_TAG_ALBUM, *album);
|
|
|
|
Mpd.AddSearch(MPD_TAG_ALBUM, *album);
|
|
|
|
auto dates = Mpd.CommitSearchTags();
|
|
|
|
auto dates = Mpd.CommitSearchTags();
|
|
|
|
for (auto date = dates.begin(); date != dates.end(); ++date)
|
|
|
|
for (auto date = dates.begin(); date != dates.end(); ++date)
|
|
|
|
Albums->addItem(SearchConstraints(*artist, *album, *date));
|
|
|
|
Albums.addItem(SearchConstraints(*artist, *album, *date));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
Albums->addItem(SearchConstraints(*artist, *album, *artist));
|
|
|
|
Albums.addItem(SearchConstraints(*artist, *album, *artist));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
Albums->addItem(SearchConstraints(*artist, *album, ""));
|
|
|
|
Albums.addItem(SearchConstraints(*artist, *album, ""));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Mpd.BlockIdle(0);
|
|
|
|
Mpd.BlockIdle(0);
|
|
|
|
if (!Albums->empty())
|
|
|
|
if (!Albums.empty())
|
|
|
|
std::sort(Albums->beginV(), Albums->endV(), SortSearchConstraints());
|
|
|
|
std::sort(Albums.beginV(), Albums.endV(), SortSearchConstraints());
|
|
|
|
Albums->refresh();
|
|
|
|
Albums.refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasTwoColumns && !Tags->empty() && w == Albums && Albums->reallyEmpty())
|
|
|
|
if (!hasTwoColumns && !Tags.empty() && isActiveWindow(Albums) && Albums.reallyEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Albums->setHighlightColor(Config.main_highlight_color);
|
|
|
|
Albums.setHighlightColor(Config.main_highlight_color);
|
|
|
|
Tags->setHighlightColor(Config.active_column_color);
|
|
|
|
Tags.setHighlightColor(Config.active_column_color);
|
|
|
|
w = Tags;
|
|
|
|
w = &Tags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!(hasTwoColumns ? Albums->empty() : Tags->empty()) && Songs->reallyEmpty())
|
|
|
|
if (!(hasTwoColumns ? Albums.empty() : Tags.empty()) && Songs.reallyEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Songs->reset();
|
|
|
|
Songs.reset();
|
|
|
|
|
|
|
|
|
|
|
|
Mpd.StartSearch(1);
|
|
|
|
Mpd.StartSearch(1);
|
|
|
|
Mpd.AddSearch(Config.media_lib_primary_tag, hasTwoColumns ? Albums->current().value().PrimaryTag : Tags->current().value());
|
|
|
|
Mpd.AddSearch(Config.media_lib_primary_tag, hasTwoColumns ? Albums.current().value().PrimaryTag : Tags.current().value());
|
|
|
|
if (Albums->current().value().Date != AllTracksMarker)
|
|
|
|
if (Albums.current().value().Date != AllTracksMarker)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Mpd.AddSearch(MPD_TAG_ALBUM, Albums->current().value().Album);
|
|
|
|
Mpd.AddSearch(MPD_TAG_ALBUM, Albums.current().value().Album);
|
|
|
|
if (Config.media_library_display_date)
|
|
|
|
if (Config.media_library_display_date)
|
|
|
|
Mpd.AddSearch(MPD_TAG_DATE, Albums->current().value().Date);
|
|
|
|
Mpd.AddSearch(MPD_TAG_DATE, Albums.current().value().Date);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
auto songs = Mpd.CommitSearchSongs();
|
|
|
|
auto songs = Mpd.CommitSearchSongs();
|
|
|
|
for (auto s = songs.begin(); s != songs.end(); ++s)
|
|
|
|
for (auto s = songs.begin(); s != songs.end(); ++s)
|
|
|
|
Songs->addItem(*s, myPlaylist->checkForSong(*s));
|
|
|
|
Songs.addItem(*s, myPlaylist->checkForSong(*s));
|
|
|
|
|
|
|
|
|
|
|
|
if (Albums->current().value().Date == AllTracksMarker)
|
|
|
|
if (Albums.current().value().Date == AllTracksMarker)
|
|
|
|
std::sort(Songs->beginV(), Songs->endV(), SortAllTracks());
|
|
|
|
std::sort(Songs.beginV(), Songs.endV(), SortAllTracks());
|
|
|
|
else
|
|
|
|
else
|
|
|
|
std::sort(Songs->beginV(), Songs->endV(), SortSongsByTrack);
|
|
|
|
std::sort(Songs.beginV(), Songs.endV(), SortSongsByTrack);
|
|
|
|
|
|
|
|
|
|
|
|
Songs->refresh();
|
|
|
|
Songs.refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -377,26 +377,26 @@ void MediaLibrary::spacePressed()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (Config.space_selects)
|
|
|
|
if (Config.space_selects)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t i = Tags->choice();
|
|
|
|
size_t i = Tags.choice();
|
|
|
|
Tags->at(i).setSelected(!Tags->at(i).isSelected());
|
|
|
|
Tags.at(i).setSelected(!Tags.at(i).isSelected());
|
|
|
|
Albums->clear();
|
|
|
|
Albums.clear();
|
|
|
|
Songs->clear();
|
|
|
|
Songs.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (Albums->current().value().Date != AllTracksMarker)
|
|
|
|
if (Albums.current().value().Date != AllTracksMarker)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t i = Albums->choice();
|
|
|
|
size_t i = Albums.choice();
|
|
|
|
Albums->at(i).setSelected(!Albums->at(i).isSelected());
|
|
|
|
Albums.at(i).setSelected(!Albums.at(i).isSelected());
|
|
|
|
Songs->clear();
|
|
|
|
Songs.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Songs)
|
|
|
|
else if (isActiveWindow(Songs))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t i = Songs->choice();
|
|
|
|
size_t i = Songs.choice();
|
|
|
|
Songs->at(i).setSelected(!Songs->at(i).isSelected());
|
|
|
|
Songs.at(i).setSelected(!Songs.at(i).isSelected());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
w->scroll(NC::wDown);
|
|
|
|
w->scroll(NC::wDown);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -408,7 +408,7 @@ void MediaLibrary::mouseButtonPressed(MEVENT me)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto tryNextColumn = [this]() -> bool {
|
|
|
|
auto tryNextColumn = [this]() -> bool {
|
|
|
|
bool result = true;
|
|
|
|
bool result = true;
|
|
|
|
if (w != Songs)
|
|
|
|
if (isActiveWindow(Songs))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (nextColumnAvailable())
|
|
|
|
if (nextColumnAvailable())
|
|
|
|
nextColumn();
|
|
|
|
nextColumn();
|
|
|
|
@@ -419,7 +419,7 @@ void MediaLibrary::mouseButtonPressed(MEVENT me)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
auto tryPreviousColumn = [this]() -> bool {
|
|
|
|
auto tryPreviousColumn = [this]() -> bool {
|
|
|
|
bool result = true;
|
|
|
|
bool result = true;
|
|
|
|
if (w != Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (previousColumnAvailable())
|
|
|
|
if (previousColumnAvailable())
|
|
|
|
previousColumn();
|
|
|
|
previousColumn();
|
|
|
|
@@ -428,66 +428,66 @@ void MediaLibrary::mouseButtonPressed(MEVENT me)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (!Tags->empty() && Tags->hasCoords(me.x, me.y))
|
|
|
|
if (!Tags.empty() && Tags.hasCoords(me.x, me.y))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!tryPreviousColumn() || !tryPreviousColumn())
|
|
|
|
if (!tryPreviousColumn() || !tryPreviousColumn())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
if (size_t(me.y) < Tags->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
|
|
|
|
if (size_t(me.y) < Tags.size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Tags->Goto(me.y);
|
|
|
|
Tags.Goto(me.y);
|
|
|
|
if (me.bstate & BUTTON3_PRESSED)
|
|
|
|
if (me.bstate & BUTTON3_PRESSED)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t pos = Tags->choice();
|
|
|
|
size_t pos = Tags.choice();
|
|
|
|
spacePressed();
|
|
|
|
spacePressed();
|
|
|
|
if (pos < Tags->size()-1)
|
|
|
|
if (pos < Tags.size()-1)
|
|
|
|
Tags->scroll(NC::wUp);
|
|
|
|
Tags.scroll(NC::wUp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
Screen<ScreenType>::mouseButtonPressed(me);
|
|
|
|
Screen<ScreenType>::mouseButtonPressed(me);
|
|
|
|
Albums->clear();
|
|
|
|
Albums.clear();
|
|
|
|
Songs->clear();
|
|
|
|
Songs.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!Albums->empty() && Albums->hasCoords(me.x, me.y))
|
|
|
|
else if (!Albums.empty() && Albums.hasCoords(me.x, me.y))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (w != Albums)
|
|
|
|
if (isActiveWindow(Albums))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool success;
|
|
|
|
bool success;
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
success = tryNextColumn();
|
|
|
|
success = tryNextColumn();
|
|
|
|
else
|
|
|
|
else
|
|
|
|
success = tryPreviousColumn();
|
|
|
|
success = tryPreviousColumn();
|
|
|
|
if (!success)
|
|
|
|
if (!success)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (size_t(me.y) < Albums->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
|
|
|
|
if (size_t(me.y) < Albums.size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Albums->Goto(me.y);
|
|
|
|
Albums.Goto(me.y);
|
|
|
|
if (me.bstate & BUTTON3_PRESSED)
|
|
|
|
if (me.bstate & BUTTON3_PRESSED)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t pos = Albums->choice();
|
|
|
|
size_t pos = Albums.choice();
|
|
|
|
spacePressed();
|
|
|
|
spacePressed();
|
|
|
|
if (pos < Albums->size()-1)
|
|
|
|
if (pos < Albums.size()-1)
|
|
|
|
Albums->scroll(NC::wUp);
|
|
|
|
Albums.scroll(NC::wUp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
Screen<ScreenType>::mouseButtonPressed(me);
|
|
|
|
Screen<ScreenType>::mouseButtonPressed(me);
|
|
|
|
Songs->clear();
|
|
|
|
Songs.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!Songs->empty() && Songs->hasCoords(me.x, me.y))
|
|
|
|
else if (!Songs.empty() && Songs.hasCoords(me.x, me.y))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!tryNextColumn() || !tryNextColumn())
|
|
|
|
if (!tryNextColumn() || !tryNextColumn())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
if (size_t(me.y) < Songs->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
|
|
|
|
if (size_t(me.y) < Songs.size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Songs->Goto(me.y);
|
|
|
|
Songs.Goto(me.y);
|
|
|
|
if (me.bstate & BUTTON1_PRESSED)
|
|
|
|
if (me.bstate & BUTTON1_PRESSED)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t pos = Songs->choice();
|
|
|
|
size_t pos = Songs.choice();
|
|
|
|
spacePressed();
|
|
|
|
spacePressed();
|
|
|
|
if (pos < Songs->size()-1)
|
|
|
|
if (pos < Songs.size()-1)
|
|
|
|
Songs->scroll(NC::wUp);
|
|
|
|
Songs.scroll(NC::wUp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
enterPressed();
|
|
|
|
enterPressed();
|
|
|
|
@@ -507,35 +507,35 @@ bool MediaLibrary::allowsFiltering()
|
|
|
|
std::string MediaLibrary::currentFilter()
|
|
|
|
std::string MediaLibrary::currentFilter()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string filter;
|
|
|
|
std::string filter;
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
filter = RegexFilter<std::string>::currentFilter(*Tags);
|
|
|
|
filter = RegexFilter<std::string>::currentFilter(Tags);
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
filter = RegexItemFilter<SearchConstraints>::currentFilter(*Albums);
|
|
|
|
filter = RegexItemFilter<SearchConstraints>::currentFilter(Albums);
|
|
|
|
else if (w == Songs)
|
|
|
|
else if (isActiveWindow(Songs))
|
|
|
|
filter = RegexFilter<MPD::Song>::currentFilter(*Songs);
|
|
|
|
filter = RegexFilter<MPD::Song>::currentFilter(Songs);
|
|
|
|
return filter;
|
|
|
|
return filter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MediaLibrary::applyFilter(const std::string &filter)
|
|
|
|
void MediaLibrary::applyFilter(const std::string &filter)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Tags->showAll();
|
|
|
|
Tags.showAll();
|
|
|
|
auto rx = RegexFilter<std::string>(filter, Config.regex_type, TagEntryMatcher);
|
|
|
|
auto rx = RegexFilter<std::string>(filter, Config.regex_type, TagEntryMatcher);
|
|
|
|
Tags->filter(Tags->begin(), Tags->end(), rx);
|
|
|
|
Tags.filter(Tags.begin(), Tags.end(), rx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Albums->showAll();
|
|
|
|
Albums.showAll();
|
|
|
|
auto fun = std::bind(AlbumEntryMatcher, _1, _2, true);
|
|
|
|
auto fun = std::bind(AlbumEntryMatcher, _1, _2, true);
|
|
|
|
auto rx = RegexItemFilter<SearchConstraints>(filter, Config.regex_type, fun);
|
|
|
|
auto rx = RegexItemFilter<SearchConstraints>(filter, Config.regex_type, fun);
|
|
|
|
Albums->filter(Albums->begin(), Albums->end(), rx);
|
|
|
|
Albums.filter(Albums.begin(), Albums.end(), rx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Songs)
|
|
|
|
else if (isActiveWindow(Songs))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Songs->showAll();
|
|
|
|
Songs.showAll();
|
|
|
|
auto rx = RegexFilter<MPD::Song>(filter, Config.regex_type, SongEntryMatcher);
|
|
|
|
auto rx = RegexFilter<MPD::Song>(filter, Config.regex_type, SongEntryMatcher);
|
|
|
|
Songs->filter(Songs->begin(), Songs->end(), rx);
|
|
|
|
Songs.filter(Songs.begin(), Songs.end(), rx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -549,43 +549,43 @@ bool MediaLibrary::allowsSearching()
|
|
|
|
bool MediaLibrary::search(const std::string &constraint)
|
|
|
|
bool MediaLibrary::search(const std::string &constraint)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool result = false;
|
|
|
|
bool result = false;
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto rx = RegexFilter<std::string>(constraint, Config.regex_type, TagEntryMatcher);
|
|
|
|
auto rx = RegexFilter<std::string>(constraint, Config.regex_type, TagEntryMatcher);
|
|
|
|
result = Tags->search(Tags->begin(), Tags->end(), rx);
|
|
|
|
result = Tags.search(Tags.begin(), Tags.end(), rx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto fun = std::bind(AlbumEntryMatcher, _1, _2, false);
|
|
|
|
auto fun = std::bind(AlbumEntryMatcher, _1, _2, false);
|
|
|
|
auto rx = RegexItemFilter<SearchConstraints>(constraint, Config.regex_type, fun);
|
|
|
|
auto rx = RegexItemFilter<SearchConstraints>(constraint, Config.regex_type, fun);
|
|
|
|
result = Albums->search(Albums->begin(), Albums->end(), rx);
|
|
|
|
result = Albums.search(Albums.begin(), Albums.end(), rx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Songs)
|
|
|
|
else if (isActiveWindow(Songs))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto rx = RegexFilter<MPD::Song>(constraint, Config.regex_type, SongEntryMatcher);
|
|
|
|
auto rx = RegexFilter<MPD::Song>(constraint, Config.regex_type, SongEntryMatcher);
|
|
|
|
result = Songs->search(Songs->begin(), Songs->end(), rx);
|
|
|
|
result = Songs.search(Songs.begin(), Songs.end(), rx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MediaLibrary::nextFound(bool wrap)
|
|
|
|
void MediaLibrary::nextFound(bool wrap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
Tags->nextFound(wrap);
|
|
|
|
Tags.nextFound(wrap);
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
Albums->nextFound(wrap);
|
|
|
|
Albums.nextFound(wrap);
|
|
|
|
else if (w == Songs)
|
|
|
|
else if (isActiveWindow(Songs))
|
|
|
|
Songs->nextFound(wrap);
|
|
|
|
Songs.nextFound(wrap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MediaLibrary::prevFound(bool wrap)
|
|
|
|
void MediaLibrary::prevFound(bool wrap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
Tags->prevFound(wrap);
|
|
|
|
Tags.prevFound(wrap);
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
Albums->prevFound(wrap);
|
|
|
|
Albums.prevFound(wrap);
|
|
|
|
else if (w == Songs)
|
|
|
|
else if (isActiveWindow(Songs))
|
|
|
|
Songs->prevFound(wrap);
|
|
|
|
Songs.prevFound(wrap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/***********************************************************************/
|
|
|
|
@@ -593,7 +593,7 @@ void MediaLibrary::prevFound(bool wrap)
|
|
|
|
std::shared_ptr<ProxySongList> MediaLibrary::getProxySongList()
|
|
|
|
std::shared_ptr<ProxySongList> MediaLibrary::getProxySongList()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto ptr = nullProxySongList();
|
|
|
|
auto ptr = nullProxySongList();
|
|
|
|
if (w == Songs)
|
|
|
|
if (isActiveWindow(Songs))
|
|
|
|
ptr = songsProxyList();
|
|
|
|
ptr = songsProxyList();
|
|
|
|
return ptr;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -605,24 +605,24 @@ bool MediaLibrary::allowsSelection()
|
|
|
|
|
|
|
|
|
|
|
|
void MediaLibrary::reverseSelection()
|
|
|
|
void MediaLibrary::reverseSelection()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
reverseSelectionHelper(Tags->begin(), Tags->end());
|
|
|
|
reverseSelectionHelper(Tags.begin(), Tags.end());
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// omit "All tracks"
|
|
|
|
// omit "All tracks"
|
|
|
|
if (Albums->size() > 1)
|
|
|
|
if (Albums.size() > 1)
|
|
|
|
reverseSelectionHelper(Albums->begin(), Albums->end()-2);
|
|
|
|
reverseSelectionHelper(Albums.begin(), Albums.end()-2);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
reverseSelectionHelper(Albums->begin(), Albums->end());
|
|
|
|
reverseSelectionHelper(Albums.begin(), Albums.end());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Songs)
|
|
|
|
else if (isActiveWindow(Songs))
|
|
|
|
reverseSelectionHelper(Songs->begin(), Songs->end());
|
|
|
|
reverseSelectionHelper(Songs.begin(), Songs.end());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MPD::SongList MediaLibrary::getSelectedSongs()
|
|
|
|
MPD::SongList MediaLibrary::getSelectedSongs()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MPD::SongList result;
|
|
|
|
MPD::SongList result;
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto tag_handler = [&result](const std::string &tag) {
|
|
|
|
auto tag_handler = [&result](const std::string &tag) {
|
|
|
|
Mpd.StartSearch(true);
|
|
|
|
Mpd.StartSearch(true);
|
|
|
|
@@ -631,16 +631,16 @@ MPD::SongList MediaLibrary::getSelectedSongs()
|
|
|
|
std::sort(songs.begin(), songs.end(), SortAllTracks());
|
|
|
|
std::sort(songs.begin(), songs.end(), SortAllTracks());
|
|
|
|
result.insert(result.end(), songs.begin(), songs.end());
|
|
|
|
result.insert(result.end(), songs.begin(), songs.end());
|
|
|
|
};
|
|
|
|
};
|
|
|
|
for (auto it = Tags->begin(); it != Tags->end(); ++it)
|
|
|
|
for (auto it = Tags.begin(); it != Tags.end(); ++it)
|
|
|
|
if (it->isSelected())
|
|
|
|
if (it->isSelected())
|
|
|
|
tag_handler(it->value());
|
|
|
|
tag_handler(it->value());
|
|
|
|
// if no item is selected, add current one
|
|
|
|
// if no item is selected, add current one
|
|
|
|
if (result.empty() && !Tags->empty())
|
|
|
|
if (result.empty() && !Tags.empty())
|
|
|
|
tag_handler(Tags->current().value());
|
|
|
|
tag_handler(Tags.current().value());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (auto it = Albums->begin(); it != Albums->end() && !it->isSeparator(); ++it)
|
|
|
|
for (auto it = Albums.begin(); it != Albums.end() && !it->isSeparator(); ++it)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (it->isSelected())
|
|
|
|
if (it->isSelected())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -649,7 +649,7 @@ MPD::SongList MediaLibrary::getSelectedSongs()
|
|
|
|
if (hasTwoColumns)
|
|
|
|
if (hasTwoColumns)
|
|
|
|
Mpd.AddSearch(Config.media_lib_primary_tag, sc.PrimaryTag);
|
|
|
|
Mpd.AddSearch(Config.media_lib_primary_tag, sc.PrimaryTag);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
Mpd.AddSearch(Config.media_lib_primary_tag, Tags->current().value());
|
|
|
|
Mpd.AddSearch(Config.media_lib_primary_tag, Tags.current().value());
|
|
|
|
Mpd.AddSearch(MPD_TAG_ALBUM, sc.Album);
|
|
|
|
Mpd.AddSearch(MPD_TAG_ALBUM, sc.Album);
|
|
|
|
Mpd.AddSearch(MPD_TAG_DATE, sc.Date);
|
|
|
|
Mpd.AddSearch(MPD_TAG_DATE, sc.Date);
|
|
|
|
auto songs = Mpd.CommitSearchSongs();
|
|
|
|
auto songs = Mpd.CommitSearchSongs();
|
|
|
|
@@ -658,21 +658,21 @@ MPD::SongList MediaLibrary::getSelectedSongs()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if no item is selected, add songs from right column
|
|
|
|
// if no item is selected, add songs from right column
|
|
|
|
if (result.empty() && !Albums->empty())
|
|
|
|
if (result.empty() && !Albums.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
withUnfilteredMenu(*Songs, [this, &result]() {
|
|
|
|
withUnfilteredMenu(Songs, [this, &result]() {
|
|
|
|
result.insert(result.end(), Songs->beginV(), Songs->endV());
|
|
|
|
result.insert(result.end(), Songs.beginV(), Songs.endV());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Songs)
|
|
|
|
else if (isActiveWindow(Songs))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (auto it = Songs->begin(); it != Songs->end(); ++it)
|
|
|
|
for (auto it = Songs.begin(); it != Songs.end(); ++it)
|
|
|
|
if (it->isSelected())
|
|
|
|
if (it->isSelected())
|
|
|
|
result.push_back(it->value());
|
|
|
|
result.push_back(it->value());
|
|
|
|
// if no item is selected, add current one
|
|
|
|
// if no item is selected, add current one
|
|
|
|
if (result.empty() && !Songs->empty())
|
|
|
|
if (result.empty() && !Songs.empty())
|
|
|
|
result.push_back(Songs->current().value());
|
|
|
|
result.push_back(Songs.current().value());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -681,15 +681,15 @@ MPD::SongList MediaLibrary::getSelectedSongs()
|
|
|
|
|
|
|
|
|
|
|
|
bool MediaLibrary::previousColumnAvailable()
|
|
|
|
bool MediaLibrary::previousColumnAvailable()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert(!hasTwoColumns || w != Tags);
|
|
|
|
assert(!hasTwoColumns || !isActiveWindow(Tags));
|
|
|
|
if (w == Songs)
|
|
|
|
if (isActiveWindow(Songs))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!Albums->reallyEmpty() && (hasTwoColumns || !Tags->reallyEmpty()))
|
|
|
|
if (!Albums.reallyEmpty() && (hasTwoColumns || !Tags.reallyEmpty()))
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!hasTwoColumns && !Tags->reallyEmpty())
|
|
|
|
if (!hasTwoColumns && !Tags.reallyEmpty())
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
@@ -697,33 +697,33 @@ bool MediaLibrary::previousColumnAvailable()
|
|
|
|
|
|
|
|
|
|
|
|
void MediaLibrary::previousColumn()
|
|
|
|
void MediaLibrary::previousColumn()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (w == Songs)
|
|
|
|
if (isActiveWindow(Songs))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Songs->setHighlightColor(Config.main_highlight_color);
|
|
|
|
Songs.setHighlightColor(Config.main_highlight_color);
|
|
|
|
w->refresh();
|
|
|
|
w->refresh();
|
|
|
|
w = Albums;
|
|
|
|
w = &Albums;
|
|
|
|
Albums->setHighlightColor(Config.active_column_color);
|
|
|
|
Albums.setHighlightColor(Config.active_column_color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Albums && !hasTwoColumns)
|
|
|
|
else if (isActiveWindow(Albums) && !hasTwoColumns)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Albums->setHighlightColor(Config.main_highlight_color);
|
|
|
|
Albums.setHighlightColor(Config.main_highlight_color);
|
|
|
|
w->refresh();
|
|
|
|
w->refresh();
|
|
|
|
w = Tags;
|
|
|
|
w = &Tags;
|
|
|
|
Tags->setHighlightColor(Config.active_column_color);
|
|
|
|
Tags.setHighlightColor(Config.active_column_color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MediaLibrary::nextColumnAvailable()
|
|
|
|
bool MediaLibrary::nextColumnAvailable()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert(!hasTwoColumns || w != Tags);
|
|
|
|
assert(!hasTwoColumns || !isActiveWindow(Tags));
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!Albums->reallyEmpty() && !Songs->reallyEmpty())
|
|
|
|
if (!Albums.reallyEmpty() && !Songs.reallyEmpty())
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!Songs->reallyEmpty())
|
|
|
|
if (!Songs.reallyEmpty())
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
@@ -731,19 +731,19 @@ bool MediaLibrary::nextColumnAvailable()
|
|
|
|
|
|
|
|
|
|
|
|
void MediaLibrary::nextColumn()
|
|
|
|
void MediaLibrary::nextColumn()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Tags->setHighlightColor(Config.main_highlight_color);
|
|
|
|
Tags.setHighlightColor(Config.main_highlight_color);
|
|
|
|
w->refresh();
|
|
|
|
w->refresh();
|
|
|
|
w = Albums;
|
|
|
|
w = &Albums;
|
|
|
|
Albums->setHighlightColor(Config.active_column_color);
|
|
|
|
Albums.setHighlightColor(Config.active_column_color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Albums->setHighlightColor(Config.main_highlight_color);
|
|
|
|
Albums.setHighlightColor(Config.main_highlight_color);
|
|
|
|
w->refresh();
|
|
|
|
w->refresh();
|
|
|
|
w = Songs;
|
|
|
|
w = &Songs;
|
|
|
|
Songs->setHighlightColor(Config.active_column_color);
|
|
|
|
Songs.setHighlightColor(Config.active_column_color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -759,7 +759,7 @@ int MediaLibrary::Columns()
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<ProxySongList> MediaLibrary::songsProxyList()
|
|
|
|
std::shared_ptr<ProxySongList> MediaLibrary::songsProxyList()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return mkProxySongList(*Songs, [](NC::Menu<MPD::Song>::Item &item) {
|
|
|
|
return mkProxySongList(Songs, [](NC::Menu<MPD::Song>::Item &item) {
|
|
|
|
return &item.value();
|
|
|
|
return &item.value();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -802,100 +802,100 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasTwoColumns)
|
|
|
|
if (!hasTwoColumns)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Tags->showAll();
|
|
|
|
Tags.showAll();
|
|
|
|
if (Tags->empty())
|
|
|
|
if (Tags.empty())
|
|
|
|
update();
|
|
|
|
update();
|
|
|
|
if (primary_tag != Tags->current().value())
|
|
|
|
if (primary_tag != Tags.current().value())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < Tags->size(); ++i)
|
|
|
|
for (size_t i = 0; i < Tags.size(); ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (primary_tag == (*Tags)[i].value())
|
|
|
|
if (primary_tag == Tags[i].value())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Tags->highlight(i);
|
|
|
|
Tags.highlight(i);
|
|
|
|
Albums->clear();
|
|
|
|
Albums.clear();
|
|
|
|
Songs->clear();
|
|
|
|
Songs.clear();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Albums->showAll();
|
|
|
|
Albums.showAll();
|
|
|
|
if (Albums->empty())
|
|
|
|
if (Albums.empty())
|
|
|
|
update();
|
|
|
|
update();
|
|
|
|
|
|
|
|
|
|
|
|
std::string album = s.getAlbum();
|
|
|
|
std::string album = s.getAlbum();
|
|
|
|
std::string date = s.getDate();
|
|
|
|
std::string date = s.getDate();
|
|
|
|
if ((hasTwoColumns && Albums->current().value().PrimaryTag != primary_tag)
|
|
|
|
if ((hasTwoColumns && Albums.current().value().PrimaryTag != primary_tag)
|
|
|
|
|| album != Albums->current().value().Album
|
|
|
|
|| album != Albums.current().value().Album
|
|
|
|
|| date != Albums->current().value().Date)
|
|
|
|
|| date != Albums.current().value().Date)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < Albums->size(); ++i)
|
|
|
|
for (size_t i = 0; i < Albums.size(); ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ((!hasTwoColumns || (*Albums)[i].value().PrimaryTag == primary_tag)
|
|
|
|
if ((!hasTwoColumns || Albums[i].value().PrimaryTag == primary_tag)
|
|
|
|
&& album == (*Albums)[i].value().Album
|
|
|
|
&& album == Albums[i].value().Album
|
|
|
|
&& date == (*Albums)[i].value().Date)
|
|
|
|
&& date == Albums[i].value().Date)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Albums->highlight(i);
|
|
|
|
Albums.highlight(i);
|
|
|
|
Songs->clear();
|
|
|
|
Songs.clear();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Songs->showAll();
|
|
|
|
Songs.showAll();
|
|
|
|
if (Songs->empty())
|
|
|
|
if (Songs.empty())
|
|
|
|
update();
|
|
|
|
update();
|
|
|
|
|
|
|
|
|
|
|
|
if (s.getHash() != Songs->current().value().getHash())
|
|
|
|
if (s.getHash() != Songs.current().value().getHash())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < Songs->size(); ++i)
|
|
|
|
for (size_t i = 0; i < Songs.size(); ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (s.getHash() == (*Songs)[i].value().getHash())
|
|
|
|
if (s.getHash() == Songs[i].value().getHash())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Songs->highlight(i);
|
|
|
|
Songs.highlight(i);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Tags->setHighlightColor(Config.main_highlight_color);
|
|
|
|
Tags.setHighlightColor(Config.main_highlight_color);
|
|
|
|
Albums->setHighlightColor(Config.main_highlight_color);
|
|
|
|
Albums.setHighlightColor(Config.main_highlight_color);
|
|
|
|
Songs->setHighlightColor(Config.active_column_color);
|
|
|
|
Songs.setHighlightColor(Config.active_column_color);
|
|
|
|
w = Songs;
|
|
|
|
w = &Songs;
|
|
|
|
refresh();
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MediaLibrary::AddToPlaylist(bool add_n_play)
|
|
|
|
void MediaLibrary::AddToPlaylist(bool add_n_play)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (w == Songs && !Songs->empty())
|
|
|
|
if (isActiveWindow(Songs) && !Songs.empty())
|
|
|
|
myPlaylist->Add(Songs->current().value(), add_n_play);
|
|
|
|
myPlaylist->Add(Songs.current().value(), add_n_play);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto list = getSelectedSongs();
|
|
|
|
auto list = getSelectedSongs();
|
|
|
|
if (myPlaylist->Add(list, add_n_play))
|
|
|
|
if (myPlaylist->Add(list, add_n_play))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ((!Tags->empty() && w == Tags)
|
|
|
|
if ((!Tags.empty() && isActiveWindow(Tags))
|
|
|
|
|| (w == Albums && Albums->current().value().Date == AllTracksMarker))
|
|
|
|
|| (isActiveWindow(Albums) && Albums.current().value().Date == AllTracksMarker))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string tag_type = lowercase(tagTypeToString(Config.media_lib_primary_tag));
|
|
|
|
std::string tag_type = lowercase(tagTypeToString(Config.media_lib_primary_tag));
|
|
|
|
Statusbar::msg("Songs with %s = \"%s\" added", tag_type.c_str(), Tags->current().value().c_str());
|
|
|
|
Statusbar::msg("Songs with %s = \"%s\" added", tag_type.c_str(), Tags.current().value().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
Statusbar::msg("Songs from album \"%s\" added", Albums->current().value().Album.c_str());
|
|
|
|
Statusbar::msg("Songs from album \"%s\" added", Albums.current().value().Album.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!add_n_play)
|
|
|
|
if (!add_n_play)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
w->scroll(NC::wDown);
|
|
|
|
w->scroll(NC::wDown);
|
|
|
|
if (w == Tags)
|
|
|
|
if (isActiveWindow(Tags))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Albums->clear();
|
|
|
|
Albums.clear();
|
|
|
|
Songs->clear();
|
|
|
|
Songs.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (w == Albums)
|
|
|
|
else if (isActiveWindow(Albums))
|
|
|
|
Songs->clear();
|
|
|
|
Songs.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|