Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Kdenlive
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
258
Issues
258
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Multimedia
Kdenlive
Commits
09b73be0
Commit
09b73be0
authored
Jul 05, 2019
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pressing Shift while moving an AV clip allows to move video part track independently of audio part
parent
8c91e110
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
52 deletions
+66
-52
src/timeline2/model/builders/meltBuilder.cpp
src/timeline2/model/builders/meltBuilder.cpp
+1
-1
src/timeline2/model/timelinefunctions.cpp
src/timeline2/model/timelinefunctions.cpp
+8
-8
src/timeline2/model/timelinemodel.cpp
src/timeline2/model/timelinemodel.cpp
+36
-27
src/timeline2/model/timelinemodel.hpp
src/timeline2/model/timelinemodel.hpp
+5
-5
src/timeline2/view/qml/timeline.qml
src/timeline2/view/qml/timeline.qml
+8
-3
src/timeline2/view/timelinecontroller.cpp
src/timeline2/view/timelinecontroller.cpp
+7
-7
tests/modeltest.cpp
tests/modeltest.cpp
+1
-1
No files found.
src/timeline2/model/builders/meltBuilder.cpp
View file @
09b73be0
...
...
@@ -315,7 +315,7 @@ bool constructTrackFromMelt(const std::shared_ptr<TimelineItemModel> &timeline,
if
(
pCore
->
bin
()
->
getBinClip
(
binId
))
{
PlaylistState
::
ClipState
st
=
inferState
(
clip
,
audioTrack
);
cid
=
ClipModel
::
construct
(
timeline
,
binId
,
clip
,
st
);
ok
=
timeline
->
requestClipMove
(
cid
,
tid
,
position
,
true
,
false
,
true
,
undo
,
redo
);
ok
=
timeline
->
requestClipMove
(
cid
,
tid
,
position
,
true
,
true
,
false
,
true
,
undo
,
redo
);
}
else
{
qDebug
()
<<
"// Cannot find bin clip: "
<<
binId
<<
" - "
<<
clip
->
get
(
"id"
);
}
...
...
src/timeline2/model/timelinefunctions.cpp
View file @
09b73be0
...
...
@@ -131,7 +131,7 @@ bool TimelineFunctions::processClipCut(const std::shared_ptr<TimelineItemModel>
res
=
res
&&
timeline
->
requestItemResize
(
newId
,
duration
-
newDuration
,
false
,
true
,
undo
,
redo
);
// The next requestclipmove does not check for duration change since we don't invalidate timeline, so check duration change now
bool
durationChanged
=
trackDuration
!=
timeline
->
getTrackById_const
(
trackId
)
->
trackDuration
();
res
=
res
&&
timeline
->
requestClipMove
(
newId
,
trackId
,
position
,
true
,
false
,
true
,
undo
,
redo
);
res
=
res
&&
timeline
->
requestClipMove
(
newId
,
trackId
,
position
,
true
,
true
,
false
,
true
,
undo
,
redo
);
if
(
durationChanged
)
{
// Track length changed, check project duration
Fun
updateDuration
=
[
timeline
]()
{
...
...
@@ -245,7 +245,7 @@ bool TimelineFunctions::requestSpacerEndOperation(const std::shared_ptr<Timeline
int
track
=
timeline
->
getItemTrackId
(
itemId
);
bool
isClip
=
timeline
->
isClip
(
itemId
);
if
(
isClip
)
{
timeline
->
requestClipMove
(
itemId
,
track
,
startPosition
,
false
,
false
);
timeline
->
requestClipMove
(
itemId
,
track
,
startPosition
,
true
,
false
,
false
);
}
else
{
timeline
->
requestCompositionMove
(
itemId
,
track
,
startPosition
,
false
,
false
);
}
...
...
@@ -262,7 +262,7 @@ bool TimelineFunctions::requestSpacerEndOperation(const std::shared_ptr<Timeline
}
else
{
// only 1 clip to be moved
if
(
isClip
)
{
final
=
timeline
->
requestClipMove
(
itemId
,
track
,
endPosition
,
true
,
true
,
true
,
undo
,
redo
);
final
=
timeline
->
requestClipMove
(
itemId
,
track
,
endPosition
,
true
,
true
,
true
,
true
,
undo
,
redo
);
}
else
{
final
=
timeline
->
requestCompositionMove
(
itemId
,
track
,
-
1
,
endPosition
,
true
,
true
,
undo
,
redo
);
}
...
...
@@ -448,7 +448,7 @@ bool TimelineFunctions::removeSpace(const std::shared_ptr<TimelineItemModel> &ti
}
else
{
// only 1 clip to be moved
int
clipStart
=
timeline
->
getItemPosition
(
clipId
);
result
=
timeline
->
requestClipMove
(
clipId
,
timeline
->
getItemTrackId
(
clipId
),
clipStart
-
(
zone
.
y
()
-
zone
.
x
()),
true
,
true
,
true
,
undo
,
redo
);
result
=
timeline
->
requestClipMove
(
clipId
,
timeline
->
getItemTrackId
(
clipId
),
clipStart
-
(
zone
.
y
()
-
zone
.
x
()),
true
,
true
,
true
,
true
,
undo
,
redo
);
}
}
return
result
;
...
...
@@ -490,7 +490,7 @@ bool TimelineFunctions::requestInsertSpace(const std::shared_ptr<TimelineItemMod
result
=
result
&&
timeline
->
requestGroupMove
(
itemId
,
timeline
->
m_groups
->
getRootId
(
itemId
),
0
,
zone
.
y
()
-
zone
.
x
(),
true
,
true
,
local_undo
,
local_redo
);
}
else
if
(
timeline
->
isClip
(
itemId
))
{
result
=
result
&&
timeline
->
requestClipMove
(
itemId
,
targetTrackId
,
targetPos
,
true
,
true
,
true
,
local_undo
,
local_redo
);
result
=
result
&&
timeline
->
requestClipMove
(
itemId
,
targetTrackId
,
targetPos
,
true
,
true
,
true
,
true
,
local_undo
,
local_redo
);
}
else
{
result
=
result
&&
timeline
->
requestCompositionMove
(
itemId
,
targetTrackId
,
timeline
->
m_allCompositions
[
itemId
]
->
getForcedTrack
(),
targetPos
,
true
,
true
,
local_undo
,
local_redo
);
...
...
@@ -529,7 +529,7 @@ bool TimelineFunctions::requestItemCopy(const std::shared_ptr<TimelineItemModel>
std
::
advance
(
it
,
target_track_position
);
int
target_track
=
(
*
it
)
->
getId
();
if
(
timeline
->
isClip
(
id
))
{
res
=
res
&&
timeline
->
requestClipMove
(
newId
,
target_track
,
target_position
,
true
,
true
,
true
,
undo
,
redo
);
res
=
res
&&
timeline
->
requestClipMove
(
newId
,
target_track
,
target_position
,
true
,
true
,
true
,
true
,
undo
,
redo
);
}
else
{
const
QString
&
transitionId
=
timeline
->
m_allCompositions
[
id
]
->
getAssetId
();
std
::
unique_ptr
<
Mlt
::
Properties
>
transProps
(
timeline
->
m_allCompositions
[
id
]
->
properties
());
...
...
@@ -650,7 +650,7 @@ bool TimelineFunctions::requestSplitAudio(const std::shared_ptr<TimelineItemMode
bool
success
=
false
;
while
(
!
success
&&
!
possibleTracks
.
isEmpty
())
{
int
newTrack
=
possibleTracks
.
takeFirst
();
success
=
timeline
->
requestClipMove
(
newId
,
newTrack
,
position
,
true
,
false
,
true
,
undo
,
redo
);
success
=
timeline
->
requestClipMove
(
newId
,
newTrack
,
position
,
true
,
true
,
false
,
true
,
undo
,
redo
);
}
TimelineFunctions
::
changeClipState
(
timeline
,
cid
,
PlaylistState
::
VideoOnly
,
undo
,
redo
);
success
=
success
&&
timeline
->
m_groups
->
createGroupAtSameLevel
(
cid
,
std
::
unordered_set
<
int
>
{
newId
},
GroupType
::
AVSplit
,
undo
,
redo
);
...
...
@@ -701,7 +701,7 @@ bool TimelineFunctions::requestSplitVideo(const std::shared_ptr<TimelineItemMode
bool
success
=
false
;
while
(
!
success
&&
!
possibleTracks
.
isEmpty
())
{
int
newTrack
=
possibleTracks
.
takeFirst
();
success
=
timeline
->
requestClipMove
(
newId
,
newTrack
,
position
,
true
,
true
,
true
,
undo
,
redo
);
success
=
timeline
->
requestClipMove
(
newId
,
newTrack
,
position
,
true
,
true
,
true
,
true
,
undo
,
redo
);
}
TimelineFunctions
::
changeClipState
(
timeline
,
cid
,
PlaylistState
::
AudioOnly
,
undo
,
redo
);
success
=
success
&&
timeline
->
m_groups
->
createGroupAtSameLevel
(
cid
,
std
::
unordered_set
<
int
>
{
newId
},
GroupType
::
AVSplit
,
undo
,
redo
);
...
...
src/timeline2/model/timelinemodel.cpp
View file @
09b73be0
...
...
@@ -62,15 +62,15 @@ RTTR_REGISTRATION
using
namespace
rttr
;
registration
::
class_
<
TimelineModel
>
(
"TimelineModel"
)
.
method
(
"setTrackLockedState"
,
&
TimelineModel
::
setTrackLockedState
)(
parameter_names
(
"trackId"
,
"lock"
))
.
method
(
"requestClipMove"
,
select_overload
<
bool
(
int
,
int
,
int
,
bool
,
bool
,
bool
)
>
(
&
TimelineModel
::
requestClipMove
))(
parameter_names
(
"clipId"
,
"trackId"
,
"position"
,
"updateView"
,
"logUndo"
,
"invalidateTimeline"
))
.
method
(
"requestClipMove"
,
select_overload
<
bool
(
int
,
int
,
int
,
bool
,
bool
,
bool
,
bool
)
>
(
&
TimelineModel
::
requestClipMove
))(
parameter_names
(
"clipId"
,
"trackId"
,
"position"
,
"
moveMirrorTracks"
,
"
updateView"
,
"logUndo"
,
"invalidateTimeline"
))
.
method
(
"requestCompositionMove"
,
select_overload
<
bool
(
int
,
int
,
int
,
bool
,
bool
)
>
(
&
TimelineModel
::
requestCompositionMove
))(
parameter_names
(
"compoId"
,
"trackId"
,
"position"
,
"updateView"
,
"logUndo"
))
.
method
(
"requestClipInsertion"
,
select_overload
<
bool
(
const
QString
&
,
int
,
int
,
int
&
,
bool
,
bool
,
bool
)
>
(
&
TimelineModel
::
requestClipInsertion
))(
parameter_names
(
"binClipId"
,
"trackId"
,
"position"
,
"id"
,
"logUndo"
,
"refreshView"
,
"useTargets"
))
.
method
(
"requestItemDeletion"
,
select_overload
<
bool
(
int
,
bool
)
>
(
&
TimelineModel
::
requestItemDeletion
))(
parameter_names
(
"clipId"
,
"logUndo"
))
.
method
(
"requestGroupMove"
,
select_overload
<
bool
(
int
,
int
,
int
,
int
,
bool
,
bool
)
>
(
&
TimelineModel
::
requestGroupMove
))(
parameter_names
(
"itemId"
,
"groupId"
,
"delta_track"
,
"delta_pos"
,
"updateView"
,
"logUndo"
))
.
method
(
"requestGroupMove"
,
select_overload
<
bool
(
int
,
int
,
int
,
int
,
bool
,
bool
,
bool
)
>
(
&
TimelineModel
::
requestGroupMove
))(
parameter_names
(
"itemId"
,
"groupId"
,
"delta_track"
,
"delta_pos"
,
"
moveMirrorTracks"
,
"
updateView"
,
"logUndo"
))
.
method
(
"requestGroupDeletion"
,
select_overload
<
bool
(
int
,
bool
)
>
(
&
TimelineModel
::
requestGroupDeletion
))(
parameter_names
(
"clipId"
,
"logUndo"
))
.
method
(
"requestItemResize"
,
select_overload
<
int
(
int
,
int
,
bool
,
bool
,
int
,
bool
)
>
(
&
TimelineModel
::
requestItemResize
))(
parameter_names
(
"itemId"
,
"size"
,
"right"
,
"logUndo"
,
"snapDistance"
,
"allowSingleResize"
))
...
...
@@ -89,7 +89,7 @@ RTTR_REGISTRATION
parameter_names
(
"clipId"
,
"trackId"
,
"position"
,
"updateView"
,
"logUndo"
,
"invalidateTimeline"
))
.
method
(
"requestFakeGroupMove"
,
select_overload
<
bool
(
int
,
int
,
int
,
int
,
bool
,
bool
)
>
(
&
TimelineModel
::
requestFakeGroupMove
))(
parameter_names
(
"clipId"
,
"groupId"
,
"delta_track"
,
"delta_pos"
,
"updateView"
,
"logUndo"
))
.
method
(
"suggestClipMove"
,
&
TimelineModel
::
suggestClipMove
)(
parameter_names
(
"clipId"
,
"trackId"
,
"position"
,
"cursorPosition"
,
"snapDistance"
))
.
method
(
"suggestClipMove"
,
&
TimelineModel
::
suggestClipMove
)(
parameter_names
(
"clipId"
,
"trackId"
,
"position"
,
"cursorPosition"
,
"snapDistance"
,
"moveMirrorTracks"
))
.
method
(
"suggestCompositionMove"
,
&
TimelineModel
::
suggestCompositionMove
)(
parameter_names
(
"compoId"
,
"trackId"
,
"position"
,
"cursorPosition"
,
"snapDistance"
))
// .method("addSnap", &TimelineModel::addSnap)(parameter_names("pos"))
...
...
@@ -535,7 +535,7 @@ bool TimelineModel::requestFakeClipMove(int clipId, int trackId, int position, b
return
false
;
}
bool
TimelineModel
::
requestClipMove
(
int
clipId
,
int
trackId
,
int
position
,
bool
updateView
,
bool
invalidateTimeline
,
bool
finalMove
,
Fun
&
undo
,
Fun
&
redo
,
bool
groupMove
)
bool
TimelineModel
::
requestClipMove
(
int
clipId
,
int
trackId
,
int
position
,
bool
moveMirrorTracks
,
bool
updateView
,
bool
invalidateTimeline
,
bool
finalMove
,
Fun
&
undo
,
Fun
&
redo
,
bool
groupMove
)
{
// qDebug() << "// FINAL MOVE: " << invalidateTimeline << ", UPDATE VIEW: " << updateView<<", FINAL: "<<finalMove;
if
(
trackId
==
-
1
)
{
...
...
@@ -632,7 +632,7 @@ bool TimelineModel::requestFakeClipMove(int clipId, int trackId, int position, b
return
res
;
}
bool
TimelineModel
::
requestClipMove
(
int
clipId
,
int
trackId
,
int
position
,
bool
updateView
,
bool
logUndo
,
bool
invalidateTimeline
)
bool
TimelineModel
::
requestClipMove
(
int
clipId
,
int
trackId
,
int
position
,
bool
moveMirrorTracks
,
bool
updateView
,
bool
logUndo
,
bool
invalidateTimeline
)
{
QWriteLocker
locker
(
&
m_lock
);
TRACE
(
clipId
,
trackId
,
position
,
updateView
,
logUndo
,
invalidateTimeline
);
...
...
@@ -649,11 +649,11 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
int
track_pos2
=
getTrackPosition
(
current_trackId
);
int
delta_track
=
track_pos1
-
track_pos2
;
int
delta_pos
=
position
-
m_allClips
[
clipId
]
->
getPosition
();
return
requestGroupMove
(
clipId
,
groupId
,
delta_track
,
delta_pos
,
updateView
,
logUndo
);
return
requestGroupMove
(
clipId
,
groupId
,
delta_track
,
delta_pos
,
moveMirrorTracks
,
updateView
,
logUndo
);
}
std
::
function
<
bool
(
void
)
>
undo
=
[]()
{
return
true
;
};
std
::
function
<
bool
(
void
)
>
redo
=
[]()
{
return
true
;
};
bool
res
=
requestClipMove
(
clipId
,
trackId
,
position
,
updateView
,
invalidateTimeline
,
logUndo
,
undo
,
redo
);
bool
res
=
requestClipMove
(
clipId
,
trackId
,
position
,
moveMirrorTracks
,
updateView
,
invalidateTimeline
,
logUndo
,
undo
,
redo
);
if
(
res
&&
logUndo
)
{
PUSH_UNDO
(
undo
,
redo
,
i18n
(
"Move clip"
));
}
...
...
@@ -681,7 +681,7 @@ bool TimelineModel::requestClipMoveAttempt(int clipId, int trackId, int position
int
delta_pos
=
position
-
m_allClips
[
clipId
]
->
getPosition
();
res
=
requestGroupMove
(
clipId
,
groupId
,
delta_track
,
delta_pos
,
false
,
false
,
undo
,
redo
,
false
);
}
else
{
res
=
requestClipMove
(
clipId
,
trackId
,
position
,
false
,
false
,
false
,
undo
,
redo
);
res
=
requestClipMove
(
clipId
,
trackId
,
position
,
true
,
false
,
false
,
false
,
undo
,
redo
);
}
if
(
res
)
{
undo
();
...
...
@@ -697,7 +697,7 @@ int TimelineModel::suggestItemMove(int itemId, int trackId, int position, int cu
return
suggestCompositionMove
(
itemId
,
trackId
,
position
,
cursorPosition
,
snapDistance
);
}
int
TimelineModel
::
suggestClipMove
(
int
clipId
,
int
trackId
,
int
position
,
int
cursorPosition
,
int
snapDistance
)
int
TimelineModel
::
suggestClipMove
(
int
clipId
,
int
trackId
,
int
position
,
int
cursorPosition
,
int
snapDistance
,
bool
moveMirrorTracks
)
{
QWriteLocker
locker
(
&
m_lock
);
TRACE
(
clipId
,
trackId
,
position
,
cursorPosition
,
snapDistance
);
...
...
@@ -739,7 +739,7 @@ int TimelineModel::suggestClipMove(int clipId, int trackId, int position, int cu
}
}
// we check if move is possible
bool
possible
=
m_editMode
==
TimelineMode
::
NormalEdit
?
requestClipMove
(
clipId
,
trackId
,
position
,
true
,
false
,
false
)
bool
possible
=
m_editMode
==
TimelineMode
::
NormalEdit
?
requestClipMove
(
clipId
,
trackId
,
position
,
moveMirrorTracks
,
true
,
false
,
false
)
:
requestFakeClipMove
(
clipId
,
trackId
,
position
,
true
,
false
,
false
);
/*} else {
possible = requestClipMoveAttempt(clipId, trackId, position);
...
...
@@ -759,7 +759,7 @@ int TimelineModel::suggestClipMove(int clipId, int trackId, int position, int cu
if
(
trackId
!=
sourceTrackId
&&
sourceTrackId
!=
-
1
)
{
qDebug
()
<<
"// TESTING SAME TRACVK MOVE: "
<<
trackId
<<
" = "
<<
sourceTrackId
;
trackId
=
sourceTrackId
;
possible
=
requestClipMove
(
clipId
,
trackId
,
position
,
true
,
false
,
false
);
possible
=
requestClipMove
(
clipId
,
trackId
,
position
,
moveMirrorTracks
,
true
,
false
,
false
);
if
(
!
possible
)
{
qDebug
()
<<
"CANNOT MOVE CLIP : "
<<
clipId
<<
" ON TK: "
<<
trackId
<<
", AT POS: "
<<
position
;
}
else
{
...
...
@@ -780,7 +780,7 @@ int TimelineModel::suggestClipMove(int clipId, int trackId, int position, int cu
TRACE_RES
(
currentPos
);
return
currentPos
;
}
possible
=
requestClipMove
(
clipId
,
trackId
,
position
,
true
,
false
,
false
);
possible
=
requestClipMove
(
clipId
,
trackId
,
position
,
moveMirrorTracks
,
true
,
false
,
false
);
TRACE_RES
(
possible
?
position
:
currentPos
);
return
possible
?
position
:
currentPos
;
}
...
...
@@ -835,7 +835,7 @@ int TimelineModel::suggestClipMove(int clipId, int trackId, int position, int cu
}
if
(
blank_length
!=
0
)
{
int
updatedPos
=
currentPos
+
(
after
?
blank_length
:
-
blank_length
);
possible
=
requestClipMove
(
clipId
,
trackId
,
updatedPos
,
true
,
false
,
false
);
possible
=
requestClipMove
(
clipId
,
trackId
,
updatedPos
,
moveMirrorTracks
,
true
,
false
,
false
);
if
(
possible
)
{
TRACE_RES
(
updatedPos
);
return
updatedPos
;
...
...
@@ -1019,7 +1019,7 @@ bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId,
}
bool
audioDrop
=
getTrackById_const
(
trackId
)
->
isAudioTrack
();
res
=
requestClipCreation
(
binClipId
,
id
,
getTrackById_const
(
trackId
)
->
trackType
(),
1.0
,
local_undo
,
local_redo
);
res
=
res
&&
requestClipMove
(
id
,
trackId
,
position
,
refreshView
,
logUndo
,
logUndo
,
local_undo
,
local_redo
);
res
=
res
&&
requestClipMove
(
id
,
trackId
,
position
,
true
,
refreshView
,
logUndo
,
logUndo
,
local_undo
,
local_redo
);
int
target_track
;
if
(
audioDrop
)
{
target_track
=
m_videoTarget
==
-
1
?
-
1
:
getTrackById_const
(
m_videoTarget
)
->
isLocked
()
?
-
1
:
m_videoTarget
;
...
...
@@ -1055,7 +1055,7 @@ bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId,
bool
move
=
false
;
while
(
!
move
&&
!
possibleTracks
.
isEmpty
())
{
int
newTrack
=
possibleTracks
.
takeFirst
();
move
=
requestClipMove
(
newId
,
newTrack
,
position
,
true
,
true
,
true
,
audio_undo
,
audio_redo
);
move
=
requestClipMove
(
newId
,
newTrack
,
position
,
true
,
true
,
true
,
true
,
audio_undo
,
audio_redo
);
}
// use lazy evaluation to group only if move was successful
res
=
res
&&
move
&&
requestClipsGroup
({
id
,
newId
},
audio_undo
,
audio_redo
,
GroupType
::
AVSplit
);
...
...
@@ -1086,7 +1086,7 @@ bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId,
normalisedBinId
.
remove
(
0
,
1
);
}
res
=
requestClipCreation
(
normalisedBinId
,
id
,
dropType
,
1.0
,
local_undo
,
local_redo
);
res
=
res
&&
requestClipMove
(
id
,
trackId
,
position
,
refreshView
,
logUndo
,
logUndo
,
local_undo
,
local_redo
);
res
=
res
&&
requestClipMove
(
id
,
trackId
,
position
,
true
,
refreshView
,
logUndo
,
logUndo
,
local_undo
,
local_redo
);
}
if
(
!
res
)
{
bool
undone
=
local_undo
();
...
...
@@ -1341,13 +1341,13 @@ bool TimelineModel::requestFakeGroupMove(int clipId, int groupId, int delta_trac
return
true
;
}
bool
TimelineModel
::
requestGroupMove
(
int
itemId
,
int
groupId
,
int
delta_track
,
int
delta_pos
,
bool
updateView
,
bool
logUndo
)
bool
TimelineModel
::
requestGroupMove
(
int
itemId
,
int
groupId
,
int
delta_track
,
int
delta_pos
,
bool
moveMirrorTracks
,
bool
updateView
,
bool
logUndo
)
{
QWriteLocker
locker
(
&
m_lock
);
TRACE
(
itemId
,
groupId
,
delta_track
,
delta_pos
,
updateView
,
logUndo
);
std
::
function
<
bool
(
void
)
>
undo
=
[]()
{
return
true
;
};
std
::
function
<
bool
(
void
)
>
redo
=
[]()
{
return
true
;
};
bool
res
=
requestGroupMove
(
itemId
,
groupId
,
delta_track
,
delta_pos
,
updateView
,
logUndo
,
undo
,
redo
);
bool
res
=
requestGroupMove
(
itemId
,
groupId
,
delta_track
,
delta_pos
,
updateView
,
logUndo
,
undo
,
redo
,
moveMirrorTracks
);
if
(
res
&&
logUndo
)
{
PUSH_UNDO
(
undo
,
redo
,
i18n
(
"Move group"
));
}
...
...
@@ -1355,7 +1355,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
return
res
;
}
bool
TimelineModel
::
requestGroupMove
(
int
itemId
,
int
groupId
,
int
delta_track
,
int
delta_pos
,
bool
updateView
,
bool
finalMove
,
Fun
&
undo
,
Fun
&
redo
,
bool
TimelineModel
::
requestGroupMove
(
int
itemId
,
int
groupId
,
int
delta_track
,
int
delta_pos
,
bool
updateView
,
bool
finalMove
,
Fun
&
undo
,
Fun
&
redo
,
bool
moveMirrorTracks
,
bool
allowViewRefresh
)
{
QWriteLocker
locker
(
&
m_lock
);
...
...
@@ -1463,11 +1463,20 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
}
}
}
if
(
getTrackById
(
old_track_ids
[
itemId
])
->
isAudioTrack
())
{
// Master clip is audio, so reverse delta for video clips
video_delta
=
-
delta_track
;
if
(
!
moveMirrorTracks
)
{
if
(
getTrackById
(
old_track_ids
[
itemId
])
->
isAudioTrack
())
{
// Master clip is audio, so reverse delta for video clips
video_delta
=
0
;
}
else
{
audio_delta
=
0
;
}
}
else
{
audio_delta
=
-
delta_track
;
if
(
getTrackById
(
old_track_ids
[
itemId
])
->
isAudioTrack
())
{
// Master clip is audio, so reverse delta for video clips
video_delta
=
-
delta_track
;
}
else
{
audio_delta
=
-
delta_track
;
}
}
}
...
...
@@ -1480,7 +1489,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
int
current_track_id
=
getItemTrackId
(
item
);
int
target_position
=
getItemPosition
(
item
)
+
delta_pos
;
if
(
isClip
(
item
))
{
ok
=
ok
&&
requestClipMove
(
item
,
current_track_id
,
target_position
,
updateThisView
,
finalMove
,
finalMove
,
local_undo
,
local_redo
,
true
);
ok
=
ok
&&
requestClipMove
(
item
,
current_track_id
,
target_position
,
moveMirrorTracks
,
updateThisView
,
finalMove
,
finalMove
,
local_undo
,
local_redo
,
true
);
}
else
{
ok
=
ok
&&
requestCompositionMove
(
item
,
current_track_id
,
m_allCompositions
[
item
]
->
getForcedTrack
(),
target_position
,
updateThisView
,
finalMove
,
local_undo
,
local_redo
);
...
...
@@ -1505,7 +1514,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
int
target_track
=
(
*
it
)
->
getId
();
int
target_position
=
old_position
[
item
]
+
delta_pos
;
if
(
isClip
(
item
))
{
ok
=
ok
&&
requestClipMove
(
item
,
target_track
,
target_position
,
updateThisView
,
finalMove
,
finalMove
,
local_undo
,
local_redo
,
true
);
ok
=
ok
&&
requestClipMove
(
item
,
target_track
,
target_position
,
moveMirrorTracks
,
updateThisView
,
finalMove
,
finalMove
,
local_undo
,
local_redo
,
true
);
}
else
{
ok
=
ok
&&
requestCompositionMove
(
item
,
target_track
,
old_forced_track
[
item
],
target_position
,
updateThisView
,
finalMove
,
local_undo
,
local_redo
);
...
...
src/timeline2/model/timelinemodel.hpp
View file @
09b73be0
...
...
@@ -345,7 +345,7 @@ public:
@param updateView if set to false, no signal is sent to qml
@param logUndo if set to false, no undo object is stored
*/
Q_INVOKABLE
bool
requestClipMove
(
int
clipId
,
int
trackId
,
int
position
,
bool
updateView
=
true
,
bool
logUndo
=
true
,
bool
invalidateTimeline
=
false
);
Q_INVOKABLE
bool
requestClipMove
(
int
clipId
,
int
trackId
,
int
position
,
bool
moveMirrorTracks
=
true
,
bool
updateView
=
true
,
bool
logUndo
=
true
,
bool
invalidateTimeline
=
false
);
/* @brief Move a composition to a specific position This action is undoable
Returns true on success. If it fails, nothing is modified. If the clip is
...
...
@@ -357,7 +357,7 @@ public:
/* Same function, but accumulates undo and redo, and doesn't check
for group*/
bool
requestClipMove
(
int
clipId
,
int
trackId
,
int
position
,
bool
updateView
,
bool
invalidateTimeline
,
bool
finalMove
,
Fun
&
undo
,
Fun
&
redo
,
bool
groupMove
=
false
);
bool
requestClipMove
(
int
clipId
,
int
trackId
,
int
position
,
bool
moveMirrorTracks
,
bool
updateView
,
bool
invalidateTimeline
,
bool
finalMove
,
Fun
&
undo
,
Fun
&
redo
,
bool
groupMove
=
false
);
bool
requestCompositionMove
(
int
transid
,
int
trackId
,
int
compositionTrack
,
int
position
,
bool
updateView
,
bool
finalMove
,
Fun
&
undo
,
Fun
&
redo
);
/* When timeline edit mode is insert or overwrite, we fake the move (as it will overlap existing clips, and only process the real move on drop */
...
...
@@ -378,7 +378,7 @@ public:
@param dontRefreshMasterClip when false, no view refresh is attempted
*/
Q_INVOKABLE
int
suggestItemMove
(
int
itemId
,
int
trackId
,
int
position
,
int
cursorPosition
,
int
snapDistance
=
-
1
);
Q_INVOKABLE
int
suggestClipMove
(
int
clipId
,
int
trackId
,
int
position
,
int
cursorPosition
,
int
snapDistance
=
-
1
);
Q_INVOKABLE
int
suggestClipMove
(
int
clipId
,
int
trackId
,
int
position
,
int
cursorPosition
,
int
snapDistance
=
-
1
,
bool
moveMirrorTracks
=
true
);
Q_INVOKABLE
int
suggestCompositionMove
(
int
compoId
,
int
trackId
,
int
position
,
int
cursorPosition
,
int
snapDistance
=
-
1
);
/* @brief Request clip insertion at given position. This action is undoable
...
...
@@ -432,8 +432,8 @@ public:
@param logUndo if set to true, an undo object is created
@param allowViewRefresh if false, the view will never get updated (useful for suggestMove)
*/
bool
requestGroupMove
(
int
itemId
,
int
groupId
,
int
delta_track
,
int
delta_pos
,
bool
updateView
=
true
,
bool
logUndo
=
true
);
bool
requestGroupMove
(
int
itemId
,
int
groupId
,
int
delta_track
,
int
delta_pos
,
bool
updateView
,
bool
finalMove
,
Fun
&
undo
,
Fun
&
redo
,
bool
requestGroupMove
(
int
itemId
,
int
groupId
,
int
delta_track
,
int
delta_pos
,
bool
moveMirrorTracks
=
true
,
bool
updateView
=
true
,
bool
logUndo
=
true
);
bool
requestGroupMove
(
int
itemId
,
int
groupId
,
int
delta_track
,
int
delta_pos
,
bool
updateView
,
bool
finalMove
,
Fun
&
undo
,
Fun
&
redo
,
bool
moveMirrorTracks
=
true
,
bool
allowViewRefresh
=
true
);
/* @brief Deletes all clips inside the group that contains the given clip.
...
...
src/timeline2/view/qml/timeline.qml
View file @
09b73be0
...
...
@@ -1102,6 +1102,7 @@ Rectangle {
drag.minimumX
:
0
property
int
dragFrame
property
bool
shiftClick
:
false
property
bool
moveMirrorTracks
:
true
enabled
:
root
.
activeTool
==
0
onPressed
:
{
console
.
log
(
'
+++++++++++++++++++ DRAG CLICKED +++++++++++++
'
)
...
...
@@ -1115,6 +1116,7 @@ Rectangle {
return
}
dragFrame
=
-
1
moveMirrorTracks
=
true
timeline
.
activeTrack
=
dragProxy
.
sourceTrack
if
(
mouse
.
modifiers
&
Qt
.
ShiftModifier
)
{
if
(
timeline
.
selection
.
indexOf
(
dragProxy
.
draggedItem
)
==
-
1
)
{
...
...
@@ -1189,6 +1191,9 @@ Rectangle {
endDrag
()
return
}
if
(
moveMirrorTracks
&&
mouse
.
modifiers
&
Qt
.
ShiftModifier
)
{
moveMirrorTracks
=
false
}
if
(
!
shiftClick
&&
dragProxy
.
draggedItem
>
-
1
&&
mouse
.
buttons
===
Qt
.
LeftButton
&&
(
controller
.
isClip
(
dragProxy
.
draggedItem
)
||
controller
.
isComposition
(
dragProxy
.
draggedItem
)))
{
continuousScrolling
(
mouse
.
x
+
parent
.
x
)
var
mapped
=
tracksContainerArea
.
mapFromItem
(
dragProxy
,
mouse
.
x
,
mouse
.
y
).
x
...
...
@@ -1213,7 +1218,7 @@ Rectangle {
dragProxy
.
masterObject
.
y
=
pos
.
y
//console.log('bringing item to front')
}
dragFrame
=
controller
.
suggestClipMove
(
dragProxy
.
draggedItem
,
tId
,
posx
,
timeline
.
position
,
Math
.
floor
(
root
.
snapping
))
dragFrame
=
controller
.
suggestClipMove
(
dragProxy
.
draggedItem
,
tId
,
posx
,
timeline
.
position
,
Math
.
floor
(
root
.
snapping
)
,
moveMirrorTracks
)
timeline
.
activeTrack
=
timeline
.
getItemMovingTrack
(
dragProxy
.
draggedItem
)
}
var
delta
=
dragFrame
-
dragProxy
.
sourceFrame
...
...
@@ -1237,8 +1242,8 @@ Rectangle {
controller
.
requestCompositionMove
(
dragProxy
.
draggedItem
,
tId
,
dragFrame
,
true
,
true
,
true
)
}
else
{
if
(
controller
.
normalEdit
())
{
controller
.
requestClipMove
(
dragProxy
.
draggedItem
,
dragProxy
.
sourceTrack
,
dragProxy
.
sourceFrame
,
true
,
false
,
false
)
controller
.
requestClipMove
(
dragProxy
.
draggedItem
,
tId
,
dragFrame
,
true
,
true
,
true
)
controller
.
requestClipMove
(
dragProxy
.
draggedItem
,
dragProxy
.
sourceTrack
,
dragProxy
.
sourceFrame
,
moveMirrorTracks
,
true
,
false
,
false
)
controller
.
requestClipMove
(
dragProxy
.
draggedItem
,
tId
,
dragFrame
,
moveMirrorTracks
,
true
,
true
,
true
)
}
else
{
// Fake move, only process final move
timeline
.
endFakeMove
(
dragProxy
.
draggedItem
,
dragFrame
,
true
,
true
,
true
)
...
...
src/timeline2/view/timelinecontroller.cpp
View file @
09b73be0
...
...
@@ -1765,7 +1765,7 @@ void TimelineController::setAudioRef(int clipId)
m_audioCorrelator
.
reset
(
new
AudioCorrelation
(
std
::
move
(
envelope
)));
connect
(
m_audioCorrelator
.
get
(),
&
AudioCorrelation
::
gotAudioAlignData
,
[
&
](
int
cid
,
int
shift
)
{
int
pos
=
m_model
->
getClipPosition
(
m_audioRef
)
+
shift
-
m_model
->
getClipIn
(
m_audioRef
);
bool
result
=
m_model
->
requestClipMove
(
cid
,
m_model
->
getClipTrackId
(
cid
),
pos
,
true
,
true
);
bool
result
=
m_model
->
requestClipMove
(
cid
,
m_model
->
getClipTrackId
(
cid
),
pos
,
true
,
true
,
true
);
if
(
!
result
)
{
pCore
->
displayMessage
(
i18n
(
"Cannot move clip to frame %1."
,
(
pos
+
shift
)),
InformationMessage
,
500
);
}
...
...
@@ -1792,7 +1792,7 @@ void TimelineController::alignAudio(int clipId)
// easy, same clip.
int
newPos
=
m_model
->
getClipPosition
(
m_audioRef
)
-
m_model
->
getClipIn
(
m_audioRef
)
+
m_model
->
getClipIn
(
clipId
);
if
(
newPos
)
{
bool
result
=
m_model
->
requestClipMove
(
clipId
,
m_model
->
getClipTrackId
(
clipId
),
newPos
,
true
,
true
);
bool
result
=
m_model
->
requestClipMove
(
clipId
,
m_model
->
getClipTrackId
(
clipId
),
newPos
,
true
,
true
,
true
);
if
(
!
result
)
{
pCore
->
displayMessage
(
i18n
(
"Cannot move clip to frame %1."
,
newPos
),
InformationMessage
,
500
);
}
...
...
@@ -2028,9 +2028,9 @@ void TimelineController::editItemDuration(int id)
bool
result
=
true
;
if
(
newPos
<
start
)
{
if
(
!
isComposition
)
{
result
=
m_model
->
requestClipMove
(
id
,
trackId
,
newPos
,
true
,
true
,
true
,
undo
,
redo
);
result
=
m_model
->
requestClipMove
(
id
,
trackId
,
newPos
,
true
,
true
,
true
,
true
,
undo
,
redo
);
if
(
result
&&
partner
>
-
1
)
{
result
=
m_model
->
requestClipMove
(
partner
,
m_model
->
getItemTrackId
(
partner
),
newPos
,
true
,
true
,
true
,
undo
,
redo
);
result
=
m_model
->
requestClipMove
(
partner
,
m_model
->
getItemTrackId
(
partner
),
newPos
,
true
,
true
,
true
,
true
,
undo
,
redo
);
}
}
else
{
result
=
m_model
->
requestCompositionMove
(
id
,
trackId
,
newPos
,
m_model
->
m_allCompositions
[
id
]
->
getForcedTrack
(),
true
,
true
,
undo
,
redo
);
...
...
@@ -2063,9 +2063,9 @@ void TimelineController::editItemDuration(int id)
}
if
(
start
!=
newPos
||
newIn
!=
in
)
{
if
(
!
isComposition
)
{
result
=
result
&&
m_model
->
requestClipMove
(
id
,
trackId
,
newPos
,
true
,
true
,
true
,
undo
,
redo
);
result
=
result
&&
m_model
->
requestClipMove
(
id
,
trackId
,
newPos
,
true
,
true
,
true
,
true
,
undo
,
redo
);
if
(
result
&&
partner
>
-
1
)
{
result
=
m_model
->
requestClipMove
(
partner
,
m_model
->
getItemTrackId
(
partner
),
newPos
,
true
,
true
,
true
,
undo
,
redo
);
result
=
m_model
->
requestClipMove
(
partner
,
m_model
->
getItemTrackId
(
partner
),
newPos
,
true
,
true
,
true
,
true
,
undo
,
redo
);
}
}
else
{
result
=
result
&&
...
...
@@ -2316,7 +2316,7 @@ bool TimelineController::endFakeGroupMove(int clipId, int groupId, int delta_tra
if
(
m_model
->
isClip
(
item
))
{
int
target_track
=
new_track_ids
[
item
];
int
target_position
=
old_position
[
item
]
+
delta_pos
;
ok
=
ok
&&
m_model
->
requestClipMove
(
item
,
target_track
,
target_position
,
updateView
,
finalMove
,
finalMove
,
undo
,
redo
);
ok
=
ok
&&
m_model
->
requestClipMove
(
item
,
target_track
,
target_position
,
true
,
updateView
,
finalMove
,
finalMove
,
undo
,
redo
);
}
else
{
// ok = ok && requestCompositionMove(item, target_track, old_forced_track[item], target_position, updateThisView, local_undo, local_redo);
}
...
...
tests/modeltest.cpp
View file @
09b73be0
...
...
@@ -1675,7 +1675,7 @@ TEST_CASE("Undo and Redo", "[ClipModel]")
{
std
::
function
<
bool
(
void
)
>
undo
=
[]()
{
return
true
;
};
std
::
function
<
bool
(
void
)
>
redo
=
[]()
{
return
true
;
};
REQUIRE
(
timeline
->
requestClipMove
(
cid6
,
tid1
,
7
,
true
,
true
,
true
,
undo
,
redo
));
REQUIRE
(
timeline
->
requestClipMove
(
cid6
,
tid1
,
7
,
true
,
true
,
true
,
true
,
undo
,
redo
));
pCore
->
pushUndo
(
undo
,
redo
,
QString
());
}
auto
state3
=
[
&
]()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment