Commit 0f2968db authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix track order in mixed track view

parent 25e5eb29
...@@ -409,14 +409,16 @@ int TimelineModel::getTrackSortValue(int trackId, int separated) const ...@@ -409,14 +409,16 @@ int TimelineModel::getTrackSortValue(int trackId, int separated) const
trackPos = audioTrack ? aCount : vCount; trackPos = audioTrack ? aCount : vCount;
} }
} }
int trackDiff = qMax(0, aCount - vCount); if (isAudio) {
if (trackDiff > 0) { if (aCount > vCount && (trackPos - 1 > aCount - vCount)) {
// more audio tracks, keep them below return (aCount - vCount + 1) + 2 * (trackPos - (aCount - vCount +1));
if (isAudio && trackPos > vCount) {
return -trackPos;
} }
if (aCount == vCount) {
return 2 * trackPos;
}
return trackPos;
} }
return isAudio ? 2 * trackPos : 2 * (vCount + 1 - trackPos) + 1; return 2 * (vCount + 1 - trackPos) + 1;
} }
QList<int> TimelineModel::getLowerTracksId(int trackId, TrackType type) const QList<int> TimelineModel::getLowerTracksId(int trackId, TrackType type) const
...@@ -2479,15 +2481,19 @@ bool TimelineModel::requestTrackInsertion(int position, int &id, const QString & ...@@ -2479,15 +2481,19 @@ bool TimelineModel::requestTrackInsertion(int position, int &id, const QString &
}; };
Fun local_name_update = [position, audioTrack, this]() { Fun local_name_update = [position, audioTrack, this]() {
if (audioTrack) { if (KdenliveSettings::audiotracksbelow() == 0) {
for (int i = 0; i <= position; i++) { _resetView();
QModelIndex ix = makeTrackIndexFromID(getTrackIndexFromPosition(i));
emit dataChanged(ix, ix, {TimelineModel::TrackTagRole});
}
} else { } else {
for (int i = position; i < (int)m_allTracks.size(); i++) { if (audioTrack) {
QModelIndex ix = makeTrackIndexFromID(getTrackIndexFromPosition(i)); for (int i = 0; i <= position; i++) {
emit dataChanged(ix, ix, {TimelineModel::TrackTagRole}); QModelIndex ix = makeTrackIndexFromID(getTrackIndexFromPosition(i));
emit dataChanged(ix, ix, {TimelineModel::TrackTagRole});
}
} else {
for (int i = position; i < (int)m_allTracks.size(); i++) {
QModelIndex ix = makeTrackIndexFromID(getTrackIndexFromPosition(i));
emit dataChanged(ix, ix, {TimelineModel::TrackTagRole});
}
} }
} }
return true; return true;
......
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