if selected items are separated, group them while moving

This commit is contained in:
Andrzej Rybczak
2009-03-12 13:32:24 +01:00
parent c0d227a0c8
commit 2bb0aaef18

View File

@@ -852,23 +852,25 @@ int main(int argc, char *argv[])
int diff = pos-list.front(); int diff = pos-list.front();
if (diff > 0) if (diff > 0)
{ {
diff -= list.size(); pos -= list.size();
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++) size_t i = list.size()-1;
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++, i--)
{ {
Mpd->QueueMove(*it, *it+diff); Mpd->QueueMove(*it, pos+i);
myPlaylist->Main()->Move(*it, *it+diff); myPlaylist->Main()->Move(*it, pos+i);
} }
} }
else if (diff < 0) else if (diff < 0)
{ {
for (vector<size_t>::const_iterator it = list.begin(); it != list.end(); it++) size_t i = 0;
for (vector<size_t>::const_iterator it = list.begin(); it != list.end(); it++, i++)
{ {
Mpd->QueueMove(*it, *it+diff); Mpd->QueueMove(*it, pos+i);
myPlaylist->Main()->Move(*it, *it+diff); myPlaylist->Main()->Move(*it, pos+i);
} }
} }
myPlaylist->Main()->Highlight(list.front()+diff);
Mpd->CommitQueue(); Mpd->CommitQueue();
myPlaylist->Main()->Highlight(pos);
myPlaylist->FixPositions(); myPlaylist->FixPositions();
} }
else if (Keypressed(input, Key.Add)) else if (Keypressed(input, Key.Add))