if there is no selected items, treat the current one as selected
This commit is contained in:
@@ -246,6 +246,8 @@ void Browser::GetSelectedSongs(MPD::SongList &v)
|
|||||||
{
|
{
|
||||||
std::vector<size_t> selected;
|
std::vector<size_t> selected;
|
||||||
w->GetSelected(selected);
|
w->GetSelected(selected);
|
||||||
|
if (selected.empty())
|
||||||
|
selected.push_back(w->Choice());
|
||||||
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
|
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
|
||||||
{
|
{
|
||||||
const Item &item = w->at(*it);
|
const Item &item = w->at(*it);
|
||||||
|
|||||||
@@ -419,10 +419,10 @@ void MediaLibrary::GetSelectedSongs(MPD::SongList &v)
|
|||||||
{
|
{
|
||||||
std::vector<size_t> selected;
|
std::vector<size_t> selected;
|
||||||
Songs->GetSelected(selected);
|
Songs->GetSelected(selected);
|
||||||
|
if (selected.empty())
|
||||||
|
selected.push_back(Songs->Choice());
|
||||||
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
|
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
|
||||||
{
|
|
||||||
v.push_back(new MPD::Song(Songs->at(*it)));
|
v.push_back(new MPD::Song(Songs->at(*it)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaLibrary::ApplyFilter(const std::string &s)
|
void MediaLibrary::ApplyFilter(const std::string &s)
|
||||||
|
|||||||
14
src/misc.cpp
14
src/misc.cpp
@@ -37,7 +37,7 @@ SelectedItemsAdder *mySelectedItemsAdder = new SelectedItemsAdder;
|
|||||||
void SelectedItemsAdder::Init()
|
void SelectedItemsAdder::Init()
|
||||||
{
|
{
|
||||||
SetDimensions();
|
SetDimensions();
|
||||||
itsPlaylistSelector = new Menu<std::string>((COLS-itsWidth)/2, (MainHeight-itsHeight)/2+MainStartY, itsWidth, itsHeight, "Add selected items to...", Config.main_color, Config.window_border);
|
itsPlaylistSelector = new Menu<std::string>((COLS-itsWidth)/2, (MainHeight-itsHeight)/2+MainStartY, itsWidth, itsHeight, "Add selected item(s) to...", Config.main_color, Config.window_border);
|
||||||
itsPlaylistSelector->CyclicScrolling(Config.use_cyclic_scrolling);
|
itsPlaylistSelector->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||||
itsPlaylistSelector->HighlightColor(Config.main_highlight_color);
|
itsPlaylistSelector->HighlightColor(Config.main_highlight_color);
|
||||||
itsPlaylistSelector->SetItemDisplayer(Display::Generic);
|
itsPlaylistSelector->SetItemDisplayer(Display::Generic);
|
||||||
@@ -66,11 +66,7 @@ void SelectedItemsAdder::SwitchTo()
|
|||||||
}
|
}
|
||||||
if (!myScreen->allowsSelection())
|
if (!myScreen->allowsSelection())
|
||||||
return;
|
return;
|
||||||
if (!myScreen->GetList()->hasSelected())
|
|
||||||
{
|
|
||||||
ShowMessage("No selected items!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MainHeight < 5)
|
if (MainHeight < 5)
|
||||||
{
|
{
|
||||||
ShowMessage("Screen is too small to display this window!");
|
ShowMessage("Screen is too small to display this window!");
|
||||||
@@ -177,7 +173,7 @@ void SelectedItemsAdder::EnterPressed()
|
|||||||
for (MPD::SongList::const_iterator it = list.begin(); it != list.end(); ++it)
|
for (MPD::SongList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||||
Mpd.AddToPlaylist(utf_playlist, **it);
|
Mpd.AddToPlaylist(utf_playlist, **it);
|
||||||
if (Mpd.CommitCommandsList())
|
if (Mpd.CommitCommandsList())
|
||||||
ShowMessage("Selected items added to playlist \"%s\"!", playlist.c_str());
|
ShowMessage("Selected item(s) added to playlist \"%s\"!", playlist.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (pos > 1 && pos < w->Size()-1) // add items to existing playlist
|
else if (pos > 1 && pos < w->Size()-1) // add items to existing playlist
|
||||||
@@ -187,7 +183,7 @@ void SelectedItemsAdder::EnterPressed()
|
|||||||
for (MPD::SongList::const_iterator it = list.begin(); it != list.end(); ++it)
|
for (MPD::SongList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||||
Mpd.AddToPlaylist(playlist, **it);
|
Mpd.AddToPlaylist(playlist, **it);
|
||||||
if (Mpd.CommitCommandsList())
|
if (Mpd.CommitCommandsList())
|
||||||
ShowMessage("Selected items added to playlist \"%s\"!", w->Current().c_str());
|
ShowMessage("Selected item(s) added to playlist \"%s\"!", w->Current().c_str());
|
||||||
}
|
}
|
||||||
if (pos != w->Size()-1)
|
if (pos != w->Size()-1)
|
||||||
{
|
{
|
||||||
@@ -235,7 +231,7 @@ void SelectedItemsAdder::EnterPressed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (successful_operation)
|
if (successful_operation)
|
||||||
ShowMessage("Selected items added!");
|
ShowMessage("Selected item(s) added!");
|
||||||
}
|
}
|
||||||
MPD::FreeSongList(list);
|
MPD::FreeSongList(list);
|
||||||
SwitchTo();
|
SwitchTo();
|
||||||
|
|||||||
@@ -269,6 +269,8 @@ void Playlist::GetSelectedSongs(MPD::SongList &v)
|
|||||||
{
|
{
|
||||||
std::vector<size_t> selected;
|
std::vector<size_t> selected;
|
||||||
Items->GetSelected(selected);
|
Items->GetSelected(selected);
|
||||||
|
if (selected.empty())
|
||||||
|
selected.push_back(Items->Choice());
|
||||||
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
|
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
|
||||||
v.push_back(new MPD::Song(Items->at(*it)));
|
v.push_back(new MPD::Song(Items->at(*it)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,6 +270,8 @@ void PlaylistEditor::GetSelectedSongs(MPD::SongList &v)
|
|||||||
{
|
{
|
||||||
std::vector<size_t> selected;
|
std::vector<size_t> selected;
|
||||||
Content->GetSelected(selected);
|
Content->GetSelected(selected);
|
||||||
|
if (selected.empty())
|
||||||
|
selected.push_back(Content->Choice());
|
||||||
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
|
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
|
||||||
{
|
{
|
||||||
v.push_back(new MPD::Song(Content->at(*it)));
|
v.push_back(new MPD::Song(Content->at(*it)));
|
||||||
|
|||||||
@@ -231,6 +231,8 @@ void SearchEngine::GetSelectedSongs(MPD::SongList &v)
|
|||||||
{
|
{
|
||||||
std::vector<size_t> selected;
|
std::vector<size_t> selected;
|
||||||
w->GetSelected(selected);
|
w->GetSelected(selected);
|
||||||
|
if (selected.empty() && w->Choice() >= StaticOptions)
|
||||||
|
selected.push_back(w->Choice());
|
||||||
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
|
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
|
||||||
v.push_back(new MPD::Song(*w->at(*it).second));
|
v.push_back(new MPD::Song(*w->at(*it).second));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -803,6 +803,8 @@ void TagEditor::GetSelectedSongs(MPD::SongList &v)
|
|||||||
{
|
{
|
||||||
std::vector<size_t> selected;
|
std::vector<size_t> selected;
|
||||||
Tags->GetSelected(selected);
|
Tags->GetSelected(selected);
|
||||||
|
if (selected.empty())
|
||||||
|
selected.push_back(Tags->Choice());
|
||||||
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
|
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
|
||||||
v.push_back(new MPD::Song(Tags->at(*it)));
|
v.push_back(new MPD::Song(Tags->at(*it)));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user