Commit 02e8c3ed authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix moving clip groups with a mix

parent d7c68402
...@@ -2005,6 +2005,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i ...@@ -2005,6 +2005,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
QVector <int> tracksWithMix; QVector <int> tracksWithMix;
// Separate clips from compositions to sort and check source tracks // Separate clips from compositions to sort and check source tracks
QMap<std::pair<int, int>, int> mixesToDelete;
for (int affectedItemId : all_items) { for (int affectedItemId : all_items) {
if (delta_track != 0) { if (delta_track != 0) {
// Check if an upper / lower move is possible // Check if an upper / lower move is possible
...@@ -2020,9 +2021,22 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i ...@@ -2020,9 +2021,22 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
sorted_clips.push_back({affectedItemId, m_allClips[affectedItemId]->getPosition()}); sorted_clips.push_back({affectedItemId, m_allClips[affectedItemId]->getPosition()});
sorted_clips_ids.push_back(affectedItemId); sorted_clips_ids.push_back(affectedItemId);
int current_track_id = getClipTrackId(affectedItemId); int current_track_id = getClipTrackId(affectedItemId);
if (!tracksWithMix.contains(current_track_id) && getTrackById_const(current_track_id)->hasMix(affectedItemId)) { // Check if we have a mix in the group
// There is a mix, prepare for update if (getTrackById_const(current_track_id)->hasMix(affectedItemId)) {
tracksWithMix << current_track_id; if (delta_track != 0) {
std::pair<MixInfo, MixInfo> mixData = getTrackById_const(current_track_id)->getMixInfo(affectedItemId);
if (mixData.first.firstClipId > -1 && all_items.find(mixData.first.firstClipId) == all_items.end()) {
// First part of the mix is not moving, delete start mix
mixesToDelete.insert({mixData.first.firstClipId,affectedItemId}, current_track_id);
}
if (mixData.second.firstClipId > -1 && all_items.find(mixData.second.secondClipId) == all_items.end()) {
// First part of the mix is not moving, delete start mix
mixesToDelete.insert({affectedItemId, mixData.second.secondClipId}, current_track_id);
}
} else if (!tracksWithMix.contains(current_track_id)) {
// There is a mix, prepare for update
tracksWithMix << current_track_id;
}
} }
} else { } else {
sorted_compositions.push_back({affectedItemId, {m_allCompositions[affectedItemId]->getPosition(), getTrackMltIndex(m_allCompositions[affectedItemId]->getCurrentTrackId())}}); sorted_compositions.push_back({affectedItemId, {m_allCompositions[affectedItemId]->getPosition(), getTrackMltIndex(m_allCompositions[affectedItemId]->getCurrentTrackId())}});
...@@ -2133,6 +2147,16 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i ...@@ -2133,6 +2147,16 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
// Keep track of old track for mixes // Keep track of old track for mixes
oldTrackIds.insert(item.first, getClipTrackId(item.first)); oldTrackIds.insert(item.first, getClipTrackId(item.first));
} }
// First delete mixes that have to
if (finalMove && !mixesToDelete.isEmpty()) {
QMapIterator<std::pair<int, int>, int> i(mixesToDelete);
while (i.hasNext()) {
i.next();
// Delete mix
bool res = getTrackById(i.value())->requestRemoveMix(i.key(), local_undo, local_redo);
}
}
// First, remove clips // First, remove clips
if (delta_track != 0) { if (delta_track != 0) {
// We delete our clips only if changing track // We delete our clips only if changing track
...@@ -2167,6 +2191,9 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i ...@@ -2167,6 +2191,9 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
} }
Fun sync_mix = [this, tracksWithMix, finalMove]() { Fun sync_mix = [this, tracksWithMix, finalMove]() {
if (!finalMove) {
return true;
}
for (int tid : tracksWithMix) { for (int tid : tracksWithMix) {
getTrackById_const(tid)->syncronizeMixes(finalMove); getTrackById_const(tid)->syncronizeMixes(finalMove);
} }
......
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