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

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,
// Perform resize only
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()) {
// 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<int> 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;
......
......@@ -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;
......
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