[banshee/stable-1.6] [PlayQueue] Correct track reordering (bgo#613333)



commit 1644192c7c0a975080a55d7aacc93a61e7e7c06f
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date:   Sun Jun 6 19:10:48 2010 +1000

    [PlayQueue] Correct track reordering (bgo#613333)

 .../Banshee.PlayQueue/PlayQueueSource.cs           |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
index de9c88f..bb7a9c3 100644
--- a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
+++ b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
@@ -469,18 +469,23 @@ namespace Banshee.PlayQueue
 
         public override void ReorderSelectedTracks (int drop_row)
         {
-            // If the current_track is not playing, make the first pending unselected track the current one.
+            // If the current_track is not playing, dropping tracks may change it.
+            // If the selection is dropped above the current_track, the first pending
+            // of the dropped tracks (if any) will become the new current_track.
+            // If the tracks are dropped below the curren_track,
+            // the first pending track not in the selection will become current.
             if (current_track != null && !ServiceManager.PlayerEngine.IsPlaying (current_track)) {
                 int current_index = TrackModel.IndexOf (current_track);
+                bool above = drop_row <= current_index;
                 int new_index = -1;
                 for (int index = current_index; index < TrackModel.Count; index++) {
-                    if (!TrackModel.Selection.Contains (index)) {
+                    if (above == TrackModel.Selection.Contains (index)) {
                         new_index = index;
                         break;
                     }
                 }
-                if (new_index != current_index) {
-                    SetCurrentTrack (new_index == -1 ? null : TrackModel[new_index] as DatabaseTrackInfo);
+                if (new_index != current_index && new_index >= 0) {
+                    SetCurrentTrack (TrackModel[new_index] as DatabaseTrackInfo);
                 }
             }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]