[vlmc-devel] Track.qml: Simplify a function a bit

Yikai Lu git at videolan.org
Sat Jul 1 14:55:03 CEST 2017


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Sat Jul  1 21:15:41 2017 +0900| [2dc58b4926ce2e8a648e6e8906ed9f04ce8f2a9b] | committer: Yikai Lu

Track.qml: Simplify a function a bit

> https://code.videolan.org/videolan/vlmc/commit/2dc58b4926ce2e8a648e6e8906ed9f04ce8f2a9b
---

 src/Gui/timeline/Track.qml | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
index 64ee9c46..dcbe16cf 100644
--- a/src/Gui/timeline/Track.qml
+++ b/src/Gui/timeline/Track.qml
@@ -212,11 +212,16 @@ Item {
                     dMode = dropMode.Move;
 
                 if ( dMode === dropMode.Move ) {
-                    // Put drag.source top
-                    for ( var i = 1; i < selectedClips.length; ++i ) {
-                        if ( selectedClips[i] === drag.source ) {
-                            selectedClips.splice( i, 1 );
-                            selectedClips.unshift( drag.source );
+                    // Prepare newTrackId for all the selected clips
+                    for ( var i = 0; i < selectedClips.length; ++i ) {
+                        var target = selectedClips[i];
+                        if ( drag.source === target ) {
+                            var oldTrackId = target.newTrackId;
+                            target.newTrackId = trackId;
+                            for ( var j = 0; j < selectedClips.length; ++j ) {
+                                if ( drag.source !== selectedClips[j] )
+                                    selectedClips[j].newTrackId = Math.max( 0, trackId - oldTrackId + selectedClips[j].trackId );
+                            }
                         }
                     }
 
@@ -239,15 +244,7 @@ Item {
 
                 var alreadyCalculated = []; // Uuids of clips being already set new x position.
                 for ( i = 0; i < selectedClips.length; ++i ) {
-                    var target = selectedClips[i];
-                    if ( drag.source === target ) {
-                        var oldTrackId = target.newTrackId;
-                        target.newTrackId = trackId;
-                        for ( var j = 0; j < selectedClips.length; ++j ) {
-                            if ( drag.source !== selectedClips[j] )
-                                selectedClips[j].newTrackId = Math.max( 0, trackId - oldTrackId + selectedClips[j].trackId );
-                        }
-                    }
+                    target = selectedClips[i];
 
                     var uuid = target.uuid;
 



More information about the Vlmc-devel mailing list