Cleanup in clip/composition resize UI update

parent c4153484
Pipeline #4487 passed with stage
in 14 minutes and 2 seconds
...@@ -116,28 +116,34 @@ bool CompositionModel::requestResize(int size, bool right, Fun &undo, Fun &redo, ...@@ -116,28 +116,34 @@ bool CompositionModel::requestResize(int size, bool right, Fun &undo, Fun &redo,
// Perform resize only // Perform resize only
setInOut(in, out); setInOut(in, out);
} }
Fun operation = [track_operation]() { QVector<int> roles{TimelineModel::DurationRole};
if (!right) {
roles.push_back(TimelineModel::StartRole);
}
Fun operation = [this, track_operation, roles]() {
if (track_operation()) { 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 true;
} }
return false; return false;
}; };
if (operation()) { 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 // 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(); if (m_currentTrackId != -1) {
// we send a list of roles to be updated if (auto ptr = m_parent.lock()) {
QVector<int> roles{TimelineModel::DurationRole}; track_reverse = ptr->getTrackById(m_currentTrackId)->requestCompositionResize_lambda(m_id, old_in, old_out, logUndo);
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);
} }
Fun reverse = [track_reverse]() { Fun reverse = [this, track_reverse, roles]() {
if (track_reverse()) { if (track_reverse()) {
if (auto ptr = m_parent.lock()) {
QModelIndex ix = ptr->makeCompositionIndexFromID(m_id);
ptr->dataChanged(ix, ix, roles);
}
return true; return true;
} }
return false; return false;
......
...@@ -1781,15 +1781,6 @@ bool TimelineModel::requestItemResize(int itemId, int size, bool right, bool log ...@@ -1781,15 +1781,6 @@ bool TimelineModel::requestItemResize(int itemId, int size, bool right, bool log
{ {
Fun local_undo = []() { return true; }; Fun local_undo = []() { return true; };
Fun local_redo = []() { 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; bool result = false;
if (isClip(itemId)) { if (isClip(itemId)) {
result = m_allClips[itemId]->requestResize(size, right, local_undo, local_redo, logUndo); 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 ...@@ -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); result = m_allCompositions[itemId]->requestResize(size, right, local_undo, local_redo, logUndo);
} }
if (result) { 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); UPDATE_UNDO_REDO(local_redo, local_undo, undo, redo);
} }
return result; return result;
......
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