Commit a582d5db authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix timeline clip selection broken after a move undo operation

parent b6731517
......@@ -949,7 +949,7 @@ bool TimelineFunctions::changeClipState(const std::shared_ptr<TimelineItemModel>
}
result = timeline->m_allClips[clipId]->setClipState(status, local_undo, local_redo);
if (result && track > -1) {
result = timeline->getTrackById(track)->requestClipInsertion(clipId, start, true, true, local_undo, local_redo);
result = timeline->getTrackById(track)->requestClipInsertion(clipId, start, true, true, local_undo, local_redo, false, false);
}
UPDATE_UNDO_REDO_NOLOCK(local_redo, local_undo, undo, redo);
return result;
......
......@@ -841,7 +841,7 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
} else {
}
}
ok = ok && getTrackById(trackId)->requestClipInsertion(clipId, position, updateView, finalMove, local_undo, local_redo, groupMove, allowedClipMixes);
ok = ok && getTrackById(trackId)->requestClipInsertion(clipId, position, updateView, finalMove, local_undo, local_redo, groupMove, false, allowedClipMixes);
if (!ok) {
qWarning() << "clip insertion failed";
......@@ -2924,11 +2924,11 @@ int TimelineModel::requestClipResizeAndTimeWarp(int itemId, int size, bool right
if (!right) {
pos += getItemPlaytime(id) - size;
}
result = getTrackById(tid)->requestClipDeletion(id, true, true, undo, redo, false, true);
result = getTrackById(tid)->requestClipDeletion(id, true, true, undo, redo, false, false);
bool pitchCompensate = m_allClips[id]->getIntProperty(QStringLiteral("warp_pitch"));
result = result && requestClipTimeWarp(id, speed, pitchCompensate, true, undo, redo);
result = result && requestItemResize(id, size, true, true, undo, redo);
result = result && getTrackById(tid)->requestClipInsertion(id, pos, true, true, undo, redo);
result = result && getTrackById(tid)->requestClipInsertion(id, pos, true, true, undo, redo, false, false);
if (!result) {
break;
}
......@@ -5422,7 +5422,7 @@ void TimelineModel::requestClipReload(int clipId, int forceDuration)
if (forceDuration > -1) {
m_allClips[clipId]->requestResize(forceDuration, true, local_undo, local_redo);
}
getTrackById(old_trackId)->requestClipInsertion(clipId, oldPos, refreshView, true, local_undo, local_redo);
getTrackById(old_trackId)->requestClipInsertion(clipId, oldPos, refreshView, true, local_undo, local_redo, false, false);
if (maxDuration != m_allClips[clipId]->getMaxDuration()) {
QModelIndex ix = makeClipIndexFromID(clipId);
emit dataChanged(ix, ix, {TimelineModel::MaxDurationRole});
......@@ -5467,7 +5467,7 @@ bool TimelineModel::requestClipTimeWarp(int clipId, double speed, bool pitchComp
success = m_allClips[clipId]->useTimewarpProducer(speed, pitchCompensate, changeDuration, local_undo, local_redo);
}
if (trackId != -1) {
success = success && getTrackById(trackId)->requestClipInsertion(clipId, oldPos, true, true, local_undo, local_redo);
success = success && getTrackById(trackId)->requestClipInsertion(clipId, oldPos, true, true, local_undo, local_redo, false, false);
}
if (!success) {
local_undo();
......@@ -5525,7 +5525,7 @@ bool TimelineModel::requestClipTimeRemap(int clipId, bool enable, Fun &undo, Fun
success = m_allClips[clipId]->useTimeRemapProducer(enable, local_undo, local_redo);
}
if (trackId != -1) {
success = success && getTrackById(trackId)->requestClipInsertion(clipId, oldPos, true, true, local_undo, local_redo);
success = success && getTrackById(trackId)->requestClipInsertion(clipId, oldPos, true, true, local_undo, local_redo, false, false);
if (success && !enable && previousDuration > 0) {
// Restore input duration
requestItemResize(clipId, previousDuration, true, true, local_undo, local_redo);
......
......@@ -265,7 +265,7 @@ Fun TrackModel::requestClipInsertion_lambda(int clipId, int position, bool updat
return []() { return false; };
}
bool TrackModel::requestClipInsertion(int clipId, int position, bool updateView, bool finalMove, Fun &undo, Fun &redo, bool groupMove, const QList<int> &allowedClipMixes)
bool TrackModel::requestClipInsertion(int clipId, int position, bool updateView, bool finalMove, Fun &undo, Fun &redo, bool groupMove, bool newInsertion, const QList<int> &allowedClipMixes)
{
QWriteLocker locker(&m_lock);
if (isLocked()) {
......@@ -300,7 +300,7 @@ bool TrackModel::requestClipInsertion(int clipId, int position, bool updateView,
// A clip move changed the track duration, update track effects
m_effectStack->adjustStackLength(true, 0, duration, 0, trackDuration(), 0, undo, redo, true);
}
auto reverse = requestClipDeletion_lambda(clipId, updateView, finalMove, groupMove, finalMove);
auto reverse = requestClipDeletion_lambda(clipId, updateView, finalMove, groupMove, newInsertion);
UPDATE_UNDO_REDO(operation, reverse, local_undo, local_redo);
UPDATE_UNDO_REDO(local_redo, local_undo, undo, redo);
return true;
......
......@@ -174,7 +174,7 @@ protected:
@param undo Lambda function containing the current undo stack. Will be updated with current operation
@param redo Lambda function containing the current redo queue. Will be updated with current operation
*/
bool requestClipInsertion(int clipId, int position, bool updateView, bool finalMove, Fun &undo, Fun &redo, bool groupMove = false, const QList<int> &allowedClipMixes = {});
bool requestClipInsertion(int clipId, int position, bool updateView, bool finalMove, Fun &undo, Fun &redo, bool groupMove = false, bool newInsertion = true, const QList<int> &allowedClipMixes = {});
/** @brief This function returns a lambda that performs the requested operation */
Fun requestClipInsertion_lambda(int clipId, int position, bool updateView, bool finalMove, bool groupMove = false, const QList<int> &allowedClipMixes = {});
......
......@@ -391,7 +391,7 @@ Rectangle {
color: 'transparent'
id: itemBorder
anchors.fill: parent
border.color: (clipStatus === ClipStatus.StatusMissing || ClipStatus === ClipStatus.StatusWaiting || clipStatus === ClipStatus.StatusDeleting) ? "#ff0000" : selected ? root.selectionColor : grouped ? root.groupColor : borderColor
border.color: (clipStatus === ClipStatus.StatusMissing || ClipStatus === ClipStatus.StatusWaiting || clipStatus === ClipStatus.StatusDeleting) ? "#ff0000" : clipRoot.selected ? root.selectionColor : grouped ? root.groupColor : borderColor
border.width: isGrabbed ? 8 : 2
}
......@@ -1153,7 +1153,7 @@ Rectangle {
}
},
State {
name: 'selected'
name: 'selectedClip'
when: clipRoot.selected === true
PropertyChanges {
target: clipRoot
......@@ -1446,7 +1446,7 @@ Rectangle {
height: container.height
width: clipRoot.maxDuration * clipRoot.timeScale
x: - (clipRoot.inPoint - slipOffset) * clipRoot.timeScale
visible: root.activeTool === ProjectTool.SlipTool && selected && clipRoot.maxDuration > 0 // don't show for endless clips
visible: root.activeTool === ProjectTool.SlipTool && clipRoot.selected && clipRoot.maxDuration > 0 // don't show for endless clips
property int inPoint: clipRoot.inPoint
property int outPoint: clipRoot.outPoint
Rectangle {
......
......@@ -106,7 +106,7 @@ Item{
target: loader.item
property: "selected"
value: model.selected
when: loader.status == Loader.Ready && model.clipType != ProducerType.Track
when: loader.status == Loader.Ready && loader.item
}
Binding {
target: loader.item
......
......@@ -3976,7 +3976,7 @@ bool TimelineController::endFakeMove(int clipId, int position, bool updateView,
}
res = res && TimelineFunctions::requestInsertSpace(m_model, QPoint(position, position + duration), undo, redo, {trackId});
}
res = res && m_model->getTrackById(trackId)->requestClipInsertion(clipId, position, updateView, invalidateTimeline, undo, redo);
res = res && m_model->getTrackById(trackId)->requestClipInsertion(clipId, position, updateView, invalidateTimeline, undo, redo, false, false);
if (res) {
// Terminate fake move
if (m_model->isClip(clipId)) {
......
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