Fix a bug where dragging songs to the bottom of the playlist would actually move them back to the top.

This commit is contained in:
David Sansome 2012-07-15 12:51:19 +01:00
parent de782c980d
commit 2035c3e7f5
1 changed files with 6 additions and 6 deletions

View File

@ -707,9 +707,9 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action, int ro
stream.readRawData(reinterpret_cast<char*>(&source_playlist), sizeof(source_playlist)); stream.readRawData(reinterpret_cast<char*>(&source_playlist), sizeof(source_playlist));
stream >> source_rows; stream >> source_rows;
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream.readRawData((char*)&pid, sizeof(pid)); stream.readRawData((char*)&pid, sizeof(pid));
} else { } else {
pid = ! own_pid; pid = ! own_pid;
} }
qStableSort(source_rows); // Make sure we take them in order qStableSort(source_rows); // Make sure we take them in order
@ -791,6 +791,10 @@ void Playlist::MoveItemsWithoutUndo(const QList<int>& source_rows, int pos) {
layoutAboutToBeChanged(); layoutAboutToBeChanged();
PlaylistItemList moved_items; PlaylistItemList moved_items;
if (pos < 0) {
pos = items_.count();
}
// Take the items out of the list first, keeping track of whether the // Take the items out of the list first, keeping track of whether the
// insertion point changes // insertion point changes
int offset = 0; int offset = 0;
@ -802,10 +806,6 @@ void Playlist::MoveItemsWithoutUndo(const QList<int>& source_rows, int pos) {
} }
offset++; offset++;
} }
if (pos < 0) {
pos = items_.count();
}
// Put the items back in // Put the items back in
for (int i=start ; i<start+moved_items.count() ; ++i) { for (int i=start ; i<start+moved_items.count() ; ++i) {