diff --git a/src/timeline2/model/compositionmodel.cpp b/src/timeline2/model/compositionmodel.cpp index 5e1325ed071e9b533d57669900f6e7d8d2dbe9c9..fa81c0050a989d57f48fa15ada7414723e50d731 100644 --- a/src/timeline2/model/compositionmodel.cpp +++ b/src/timeline2/model/compositionmodel.cpp @@ -116,28 +116,34 @@ bool CompositionModel::requestResize(int size, bool right, Fun &undo, Fun &redo, // Perform resize only setInOut(in, out); } - Fun operation = [track_operation]() { + QVector roles{TimelineModel::DurationRole}; + if (!right) { + roles.push_back(TimelineModel::StartRole); + } + Fun operation = [this, track_operation, roles]() { if (track_operation()) { + // we send a list of roles to be updated + if (auto ptr = m_parent.lock()) { + QModelIndex ix = ptr->makeCompositionIndexFromID(m_id); + ptr->dataChanged(ix, ix, roles); + } return true; } return false; }; if (operation()) { // Now, we are in the state in which the timeline should be when we try to revert current action. So we can build the reverse action from here - auto ptr = m_parent.lock(); - // we send a list of roles to be updated - QVector roles{TimelineModel::DurationRole}; - if (!right) { - roles.push_back(TimelineModel::StartRole); - } - if (m_currentTrackId != -1 && ptr) { - QModelIndex ix = ptr->makeCompositionIndexFromID(m_id); - // TODO: integrate in undo - ptr->dataChanged(ix, ix, roles); - track_reverse = ptr->getTrackById(m_currentTrackId)->requestCompositionResize_lambda(m_id, old_in, old_out, logUndo); + if (m_currentTrackId != -1) { + if (auto ptr = m_parent.lock()) { + track_reverse = ptr->getTrackById(m_currentTrackId)->requestCompositionResize_lambda(m_id, old_in, old_out, logUndo); + } } - Fun reverse = [track_reverse]() { + Fun reverse = [this, track_reverse, roles]() { if (track_reverse()) { + if (auto ptr = m_parent.lock()) { + QModelIndex ix = ptr->makeCompositionIndexFromID(m_id); + ptr->dataChanged(ix, ix, roles); + } return true; } return false; diff --git a/src/timeline2/model/timelinemodel.cpp b/src/timeline2/model/timelinemodel.cpp index 845d6aacfebafa483e88efe9578958a0ca8677f9..6bcf82d271ee1d9e3a14db33f02154f2108aa9a0 100644 --- a/src/timeline2/model/timelinemodel.cpp +++ b/src/timeline2/model/timelinemodel.cpp @@ -1781,15 +1781,6 @@ bool TimelineModel::requestItemResize(int itemId, int size, bool right, bool log { Fun local_undo = []() { return true; }; Fun local_redo = []() { return true; }; - Fun update_model = [itemId, right, logUndo, this]() { - Q_ASSERT(isItem(itemId)); - if (getItemTrackId(itemId) != -1) { - qDebug() << "++++++++++\nRESIZING ITEM: " << itemId << "\n+++++++"; - QModelIndex modelIndex = isClip(itemId) ? makeClipIndexFromID(itemId) : makeCompositionIndexFromID(itemId); - notifyChange(modelIndex, modelIndex, !right, true, logUndo); - } - return true; - }; bool result = false; if (isClip(itemId)) { result = m_allClips[itemId]->requestResize(size, right, local_undo, local_redo, logUndo); @@ -1798,11 +1789,6 @@ bool TimelineModel::requestItemResize(int itemId, int size, bool right, bool log result = m_allCompositions[itemId]->requestResize(size, right, local_undo, local_redo, logUndo); } if (result) { - if (!blockUndo) { - PUSH_LAMBDA(update_model, local_undo); - } - PUSH_LAMBDA(update_model, local_redo); - update_model(); UPDATE_UNDO_REDO(local_redo, local_undo, undo, redo); } return result;