Commit 20c03ca8 authored by luyikei's avatar luyikei

Timeline: Save selected clips as uuids

parent 1cd4fb1f
......@@ -72,7 +72,7 @@ Rectangle {
return false;
for ( var i = 0; i < selectedClips.length; ++i ) {
for ( var j = i + 1; j < selectedClips.length; ++j ) {
if ( selectedClips[i].linkedClips.indexOf( selectedClips[j].uuid ) === -1 )
if ( findClipItem( selectedClips[i] ).linkedClips.indexOf( selectedClips[j] ) === -1 )
return false;
}
}
......@@ -169,23 +169,24 @@ Rectangle {
}
onSelectedChanged: {
for ( var i = 0; i < selectedClips.length; ++i )
if ( !selectedClips[i] || selectedClips[i] === clip ) {
selectedClips.splice( i, 1 );
--i;
}
if ( selected === true ) {
selectedClips.push( clip );
selectedClips.push( uuid );
var group = findGroup( uuid );
for ( i = 0; i < ( group ? group.length : 0 ); ++i ) {
for ( var i = 0; i < ( group ? group.length : 0 ); ++i ) {
var clipItem = findClipItem( group[i] );
if ( clipItem )
clipItem.selected = true;
}
selectLinkedClip();
}
else
for ( i = 0; i < selectedClips.length; ++i )
if ( selectedClips[i] === uuid ) {
selectedClips.splice( i, 1 );
--i;
break;
}
}
Component.onCompleted: {
......
......@@ -23,7 +23,7 @@ Menu {
else {
var l = [];
for ( var i = 0; i < selectedClips.length; ++i ) {
l.push( "" + selectedClips[i].uuid );
l.push( "" + selectedClips[i] );
}
addGroup( l );
}
......@@ -38,16 +38,16 @@ Menu {
if ( linked === true ) {
for ( var i = 0; i < selectedClips.length; ++i ) {
for ( var j = i + 1; j < selectedClips.length; ++j ) {
if ( selectedClips[i].linkedClips.indexOf( selectedClips[j].uuid ) !== -1 )
workflow.unlinkClips( selectedClips[i].uuid, selectedClips[j].uuid );
if ( findClipItem( selectedClips[i] ).linkedClips.indexOf( selectedClips[j] ) !== -1 )
workflow.unlinkClips( selectedClips[i], selectedClips[j] );
}
}
}
else {
for ( i = 0; i < selectedClips.length; ++i ) {
for ( j = i + 1; j < selectedClips.length; ++j ) {
if ( selectedClips[i].linkedClips.indexOf( selectedClips[j].uuid ) === -1 )
workflow.linkClips( selectedClips[i].uuid, selectedClips[j].uuid );
if (findClipItem( selectedClips[i] ).linkedClips.indexOf( selectedClips[j] ) === -1 )
workflow.linkClips( selectedClips[i], selectedClips[j] );
}
}
}
......
......@@ -196,21 +196,22 @@ Item {
else
dMode = dropMode.Move;
var toMove = [];
for ( var i = 0; i < selectedClips.length; ++i )
toMove.push( selectedClips[i].uuid );
var toMove = selectedClips.concat();
if ( dMode === dropMode.Move ) {
// Prepare newTrackId for all the selected clips
for ( i = 0; i < toMove.length; ++i ) {
for ( var i = 0; i < toMove.length; ++i ) {
var target = findClipItem( toMove[i] );
if ( drag.source === target ) {
drag.source.parent.parent.z = ++maxZ;
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 );
if ( drag.source.uuid !== selectedClips[j] )
{
var clip = findClipItem( selectedClips[j] );
clip.newTrackId = Math.max( 0, trackId - oldTrackId + clip.trackId );
}
}
}
// Let's move to the new tracks
......
......@@ -19,7 +19,7 @@ Rectangle {
property int scale: 4
property var allClips: [] // Actual clip item objects
property var allClipsDict: ({}) // Actual clip item objects
property var selectedClips: [] // Actual clip item objects
property var selectedClips: [] // Selected clip uuids
property var groups: [] // list of lists of clip uuids
property var linkedClipsDict: ({}) // Uuid
property alias isMagneticMode: magneticModeButton.selected
......@@ -29,7 +29,7 @@ Rectangle {
function clearSelectedClips() {
while ( selectedClips.length ) {
var clip = selectedClips.pop();
var clip = findClipItem( selectedClips.pop() );
if ( clip )
clip.selected = false;
}
......@@ -299,8 +299,10 @@ Rectangle {
// Workaround: We cannot sort selectedClips directly maybe because of a Qt bug
var sorted = selectedClips.slice();
sorted.sort(
function( clipA, clipB )
function( clipAUuid, clipBUuid )
{
var clipA = findClipItem( clipAUuid );
var clipB = findClipItem( clipBUuid );
if ( clipA.newTrackId > clipA.trackId )
{
return - ( clipA.newTrackId - clipB.newTrackId );
......@@ -320,7 +322,6 @@ Rectangle {
return 0;
}
);
selectedClips = sorted;
}
function dragFinished() {
......@@ -330,7 +331,10 @@ Rectangle {
// I'm aware that it's not the best solution but it's the safest solution for sure
var toMove = [];
for ( var i = 0; i < selectedClips.length; ++i )
toMove.push( [selectedClips[i].uuid, selectedClips[i].newTrackId, selectedClips[i].position] );
{
var clip = findClipItem( selectedClips[i] );
toMove.push( [clip.uuid, clip.newTrackId, clip.position] );
}
for ( i = 0; i < toMove.length; ++i )
workflow.moveClip( toMove[i][0], toMove[i][1], toMove[i][2] );
......@@ -581,7 +585,8 @@ Rectangle {
icon: StandardIcon.Question
standardButtons: StandardButton.Yes | StandardButton.No
onYes: {
workflow.removeClip( selectedClips[0].uuid );
while ( selectedClips.length > 0 )
workflow.removeClip( selectedClips[0] );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment