From 2bb0aaef180c06cd9d61aba1f558ef5de96b27d4 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Thu, 12 Mar 2009 13:32:24 +0100 Subject: [PATCH] if selected items are separated, group them while moving --- src/ncmpcpp.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index bcc2cef2..01997dd4 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -852,23 +852,25 @@ int main(int argc, char *argv[]) int diff = pos-list.front(); if (diff > 0) { - diff -= list.size(); - for (vector::reverse_iterator it = list.rbegin(); it != list.rend(); it++) + pos -= list.size(); + size_t i = list.size()-1; + for (vector::reverse_iterator it = list.rbegin(); it != list.rend(); it++, i--) { - Mpd->QueueMove(*it, *it+diff); - myPlaylist->Main()->Move(*it, *it+diff); + Mpd->QueueMove(*it, pos+i); + myPlaylist->Main()->Move(*it, pos+i); } } else if (diff < 0) { - for (vector::const_iterator it = list.begin(); it != list.end(); it++) + size_t i = 0; + for (vector::const_iterator it = list.begin(); it != list.end(); it++, i++) { - Mpd->QueueMove(*it, *it+diff); - myPlaylist->Main()->Move(*it, *it+diff); + Mpd->QueueMove(*it, pos+i); + myPlaylist->Main()->Move(*it, pos+i); } } - myPlaylist->Main()->Highlight(list.front()+diff); Mpd->CommitQueue(); + myPlaylist->Main()->Highlight(pos); myPlaylist->FixPositions(); } else if (Keypressed(input, Key.Add))