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