minor fixes for moving and deleting items

This commit is contained in:
unK
2008-09-15 20:52:25 +02:00
parent 90b975f04d
commit e029c2cd09
2 changed files with 26 additions and 19 deletions

View File

@@ -1703,6 +1703,7 @@ int main(int argc, char *argv[])
{ {
if (!mPlaylist->Empty() && current_screen == csPlaylist) if (!mPlaylist->Empty() && current_screen == csPlaylist)
{ {
block_playlist_update = 1;
if (mPlaylist->IsAnySelected()) if (mPlaylist->IsAnySelected())
{ {
vector<int> list; vector<int> list;
@@ -1717,15 +1718,17 @@ int main(int argc, char *argv[])
} }
else else
{ {
block_playlist_update = 1;
dont_change_now_playing = 1; dont_change_now_playing = 1;
mPlaylist->SetTimeout(50); mPlaylist->SetTimeout(50);
while (!mPlaylist->Empty() && Keypressed(input, Key.Delete)) while (!mPlaylist->Empty() && Keypressed(input, Key.Delete))
{ {
int id = mPlaylist->GetChoice();
TraceMpdStatus(); TraceMpdStatus();
timer = time(NULL); timer = time(NULL);
Mpd->QueueDeleteSong(mPlaylist->GetChoice()); if (now_playing > id) // needed for keeping proper
mPlaylist->DeleteOption(mPlaylist->GetChoice()); now_playing--; // position of now playing song.
Mpd->QueueDeleteSong(id);
mPlaylist->DeleteOption(id);
mPlaylist->Refresh(); mPlaylist->Refresh();
mPlaylist->ReadKey(input); mPlaylist->ReadKey(input);
} }
@@ -1872,7 +1875,7 @@ int main(int argc, char *argv[])
if (*it == now_playing && list.front() > 0) if (*it == now_playing && list.front() > 0)
mPlaylist->BoldOption(now_playing, 0); mPlaylist->BoldOption(now_playing, 0);
vector<int>origs(list); vector<int> origs(list);
while (Keypressed(input, Key.MvSongUp) && list.front() > 0) while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
{ {
@@ -1892,6 +1895,9 @@ int main(int argc, char *argv[])
{ {
int from, to; int from, to;
from = to = mPlaylist->GetChoice(); from = to = mPlaylist->GetChoice();
// unbold now playing as if song changes during move, this won't be unbolded.
if (to == now_playing && to > 0)
mPlaylist->BoldOption(now_playing, 0);
while (Keypressed(input, Key.MvSongUp) && to > 0) while (Keypressed(input, Key.MvSongUp) && to > 0)
{ {
TraceMpdStatus(); TraceMpdStatus();
@@ -1913,7 +1919,7 @@ int main(int argc, char *argv[])
vector<int> list; vector<int> list;
mPlaylistEditor->GetSelectedList(list); mPlaylistEditor->GetSelectedList(list);
vector<int>origs(list); vector<int> origs(list);
while (Keypressed(input, Key.MvSongUp) && list.front() > 0) while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
{ {
@@ -1964,7 +1970,7 @@ int main(int argc, char *argv[])
if (*it == now_playing && list.back() < mPlaylist->Size()-1) if (*it == now_playing && list.back() < mPlaylist->Size()-1)
mPlaylist->BoldOption(now_playing, 0); mPlaylist->BoldOption(now_playing, 0);
vector<int>origs(list); vector<int> origs(list);
while (Keypressed(input, Key.MvSongDown) && list.back() < mPlaylist->Size()-1) while (Keypressed(input, Key.MvSongDown) && list.back() < mPlaylist->Size()-1)
{ {
@@ -1984,6 +1990,9 @@ int main(int argc, char *argv[])
{ {
int from, to; int from, to;
from = to = mPlaylist->GetChoice(); from = to = mPlaylist->GetChoice();
// unbold now playing as if song changes during move, this won't be unbolded.
if (to == now_playing && to < mPlaylist->Size()-1)
mPlaylist->BoldOption(now_playing, 0);
while (Keypressed(input, Key.MvSongDown) && to < mPlaylist->Size()-1) while (Keypressed(input, Key.MvSongDown) && to < mPlaylist->Size()-1)
{ {
TraceMpdStatus(); TraceMpdStatus();
@@ -2006,7 +2015,7 @@ int main(int argc, char *argv[])
vector<int> list; vector<int> list;
mPlaylistEditor->GetSelectedList(list); mPlaylistEditor->GetSelectedList(list);
vector<int>origs(list); vector<int> origs(list);
while (Keypressed(input, Key.MvSongDown) && list.back() < mPlaylistEditor->Size()-1) while (Keypressed(input, Key.MvSongDown) && list.back() < mPlaylistEditor->Size()-1)
{ {

View File

@@ -285,20 +285,18 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
{ {
if (!mPlaylist->Empty() && now_playing >= 0) if (!mPlaylist->Empty() && now_playing >= 0)
{ {
if (!mPlaylist->Empty()) if (Config.repeat_one_mode && repeat_one_allowed)
{ {
if (Config.repeat_one_mode && repeat_one_allowed) std::swap(now_playing, old_playing);
{ Mpd->Play(now_playing);
std::swap(now_playing, old_playing);
Mpd->Play(now_playing);
}
if (old_playing >= 0)
mPlaylist->BoldOption(old_playing, 0);
mPlaylist->BoldOption(now_playing, 1);
if (Config.autocenter_mode)
mPlaylist->Highlight(now_playing);
repeat_one_allowed = 0;
} }
if (old_playing >= 0)
mPlaylist->BoldOption(old_playing, 0);
mPlaylist->BoldOption(now_playing, 1);
if (Config.autocenter_mode)
mPlaylist->Highlight(now_playing);
repeat_one_allowed = 0;
if (!Mpd->GetElapsedTime()) if (!Mpd->GetElapsedTime())
mvwhline(wFooter->RawWin(), 0, 0, 0, wFooter->GetWidth()); mvwhline(wFooter->RawWin(), 0, 0, 0, wFooter->GetWidth());
} }