Fix timeline broken behavior on clip deletion.

Related to #524
parent b20a7307
Pipeline #13294 passed with stage
in 13 minutes and 56 seconds
......@@ -1161,7 +1161,6 @@ bool TimelineModel::requestItemDeletion(int itemId, bool logUndo)
PUSH_UNDO(undo, redo, actionLabel);
}
TRACE_RES(res);
requestClearSelection(true);
return res;
}
......@@ -2442,7 +2441,7 @@ Fun TimelineModel::deregisterClip_lambda(int clipId)
{
return [this, clipId]() {
// qDebug() << " // /REQUEST TL CLP DELETION: " << clipId << "\n--------\nCLIPS COUNT: " << m_allClips.size();
requestClearSelection(true);
// Clear effect stack
clearAssetView(clipId);
Q_ASSERT(m_allClips.count(clipId) > 0);
Q_ASSERT(getClipTrackId(clipId) == -1); // clip must be deleted from its track at this point
......
......@@ -250,7 +250,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);
auto reverse = requestClipDeletion_lambda(clipId, updateView, finalMove, groupMove, true);
UPDATE_UNDO_REDO(operation, reverse, local_undo, local_redo);
UPDATE_UNDO_REDO(local_redo, local_undo, undo, redo);
return true;
......@@ -289,7 +289,7 @@ void TrackModel::replugClip(int clipId)
m_playlists[target_track].unlock();
}
Fun TrackModel::requestClipDeletion_lambda(int clipId, bool updateView, bool finalMove, bool groupMove)
Fun TrackModel::requestClipDeletion_lambda(int clipId, bool updateView, bool finalMove, bool groupMove, bool finalDeletion)
{
QWriteLocker locker(&m_lock);
// Find index of clip
......@@ -297,8 +297,15 @@ Fun TrackModel::requestClipDeletion_lambda(int clipId, bool updateView, bool fin
bool audioOnly = m_allClips[clipId]->isAudioOnly();
int old_in = clip_position;
int old_out = old_in + m_allClips[clipId]->getPlaytime();
return [clip_position, clipId, old_in, old_out, updateView, audioOnly, finalMove, groupMove, this]() {
return [clip_position, clipId, old_in, old_out, updateView, audioOnly, finalMove, groupMove, finalDeletion, this]() {
if (isLocked()) return false;
if (finalDeletion && m_allClips[clipId]->selected) {
m_allClips[clipId]->selected = false;
if (auto ptr = m_parent.lock()) {
// item was selected, unselect
ptr->requestClearSelection(true);
}
}
auto clip_loc = getClipIndexAt(clip_position);
if (updateView) {
int old_clip_index = getRowfromClip(clipId);
......@@ -354,11 +361,8 @@ bool TrackModel::requestClipDeletion(int clipId, bool updateView, bool finalMove
auto old_clip = m_allClips[clipId];
int old_position = old_clip->getPosition();
// qDebug() << "/// REQUESTOING CLIP DELETION_: " << updateView;
if (finalDeletion) {
m_allClips[clipId]->selected = false;
}
int duration = trackDuration();
auto operation = requestClipDeletion_lambda(clipId, updateView, finalMove, groupMove);
auto operation = requestClipDeletion_lambda(clipId, updateView, finalMove, groupMove, finalDeletion);
if (operation()) {
if (finalMove && duration != trackDuration()) {
// A clip move changed the track duration, update track effects
......
......@@ -155,7 +155,7 @@ protected:
*/
bool requestClipDeletion(int clipId, bool updateView, bool finalMove, Fun &undo, Fun &redo, bool groupMove, bool finalDeletion);
/* @brief This function returns a lambda that performs the requested operation */
Fun requestClipDeletion_lambda(int clipId, bool updateView, bool finalMove, bool groupMove);
Fun requestClipDeletion_lambda(int clipId, bool updateView, bool finalMove, bool groupMove, bool finalDeletion);
/* @brief Performs an insertion of the given composition.
Returns true if the operation succeeded, and otherwise, the track is not modified.
......
......@@ -50,6 +50,12 @@ Rectangle {
scrollView.flickableItem.contentX = pos
}
function checkDeletion(itemId) {
if (dragProxy.draggedItem == itemId) {
endDrag()
}
}
function updatePalette() {
root.color = activePalette.window
root.textColor = activePalette.text
......
......@@ -90,6 +90,8 @@ void TimelineController::prepareClose()
// Delete timeline preview before resetting model so that removing clips from timeline doesn't invalidate
delete m_timelinePreview;
m_timelinePreview = nullptr;
// Clear roor so we don't call its methods anymore
m_root = nullptr;
}
void TimelineController::setModel(std::shared_ptr<TimelineItemModel> model)
......@@ -98,7 +100,12 @@ void TimelineController::setModel(std::shared_ptr<TimelineItemModel> model)
m_zone = QPoint(-1, -1);
m_timelinePreview = nullptr;
m_model = std::move(model);
connect(m_model.get(), &TimelineItemModel::requestClearAssetView, [&](int id) { pCore->clearAssetPanel(id); });
connect(m_model.get(), &TimelineItemModel::requestClearAssetView, [&](int id) {
pCore->clearAssetPanel(id);
if (m_root) {
QMetaObject::invokeMethod(m_root, "checkDeletion", Qt::QueuedConnection, Q_ARG(QVariant, id));
}
});
connect(m_model.get(), &TimelineItemModel::requestMonitorRefresh, [&]() { pCore->requestMonitorRefresh(); });
connect(m_model.get(), &TimelineModel::invalidateZone, this, &TimelineController::invalidateZone, Qt::DirectConnection);
connect(m_model.get(), &TimelineModel::durationUpdated, this, &TimelineController::checkDuration);
......
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