Fix dragging multistream clip using target tracks

parent efad2514
Pipeline #20216 passed with stage
in 9 minutes and 32 seconds
......@@ -1072,7 +1072,7 @@ bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId,
QMap<int, int> dropTargets;
if (res && (canMirrorDrop || !target_track.isEmpty()) && master->hasAudioAndVideo()) {
if (!useTargets) {
int streamsCount = m_audioTarget.keys().count();
int streamsCount = m_binAudioTargets.keys().count();
target_track = {mirror};
QList <int> audioTids = getLowerTracksId(mirror, TrackType::AudioTrack);
if (streamsCount > audioTids.count() + 1) {
......@@ -1085,7 +1085,7 @@ bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId,
streamsCount--;
}
}
QList <int> aTargets = m_audioTarget.values();
QList <int> aTargets = m_binAudioTargets.keys();
std::sort(aTargets.begin(), aTargets.end());
for (int i = 0; i < target_track.count(); ++i) {
dropTargets.insert(target_track.at(i), aTargets.at(i));
......
......@@ -822,6 +822,8 @@ protected:
// The preferred audio target for clip insertion in the form {timeline track id, bin clip stream index}
QMap <int, int> m_audioTarget;
/** @brief The list of audio streams available from the selected bin clip, in the form: {stream index, stream description} */
QMap <int, QString> m_binAudioTargets;
// The preferred video target for clip insertion or -1 if not defined
int m_videoTarget;
// Timeline editing mode
......
......@@ -120,7 +120,7 @@ void TimelineController::setModel(std::shared_ptr<TimelineItemModel> model)
void TimelineController::setTargetTracks(bool hasVideo, QMap <int, QString> audioTargets)
{
int videoTrack = -1;
m_binAudioTargets = audioTargets;
m_model->m_binAudioTargets = audioTargets;
QMap<int, int> audioTracks;
m_hasVideoTarget = hasVideo;
m_hasAudioTarget = audioTargets.size();
......@@ -1161,7 +1161,7 @@ void TimelineController::assignAudioTarget(int trackId, int stream)
int TimelineController::getFirstUnassignedStream() const
{
QList <int> keys = m_binAudioTargets.keys();
QList <int> keys = m_model->m_binAudioTargets.keys();
QList <int> assigned = m_model->m_audioTarget.values();
for (int k : keys) {
if (!assigned.contains(k)) {
......@@ -2431,13 +2431,13 @@ QVariantList TimelineController::lastAudioTarget() const
const QString TimelineController::audioTargetName(int tid) const
{
if (m_model->m_audioTarget.contains(tid) && m_binAudioTargets.size() > 1) {
if (m_model->m_audioTarget.contains(tid) && m_model->m_binAudioTargets.size() > 1) {
int streamIndex = m_model->m_audioTarget.value(tid);
if (m_binAudioTargets.contains(streamIndex)) {
QString targetName = m_binAudioTargets.value(streamIndex);
if (m_model->m_binAudioTargets.contains(streamIndex)) {
QString targetName = m_model->m_binAudioTargets.value(streamIndex);
return targetName.isEmpty() ? QChar('x') : targetName.at(0);
} else {
qDebug()<<"STREAM INDEX NOT IN TARGET : "<<streamIndex<<" = "<<m_binAudioTargets;
qDebug()<<"STREAM INDEX NOT IN TARGET : "<<streamIndex<<" = "<<m_model->m_binAudioTargets;
}
} else {
qDebug()<<"TRACK NOT IN TARGET : "<<tid<<" = "<<m_model->m_audioTarget.keys();
......@@ -3381,7 +3381,7 @@ void TimelineController::expandActiveClip()
QMap <int, QString> TimelineController::getCurrentTargets(int trackId, int &activeTargetStream)
{
if (m_binAudioTargets.size() < 2) {
if (m_model->m_binAudioTargets.size() < 2) {
activeTargetStream = -1;
return QMap <int, QString>();
}
......@@ -3390,7 +3390,7 @@ QMap <int, QString> TimelineController::getCurrentTargets(int trackId, int &acti
} else {
activeTargetStream = -1;
}
return m_binAudioTargets;
return m_model->m_binAudioTargets;
}
void TimelineController::addTracks(int videoTracks, int audioTracks)
......
......@@ -589,8 +589,6 @@ private:
int m_hasAudioTarget {0};
bool m_hasVideoTarget {false};
int m_lastVideoTarget {-1};
/** @brief The list of audio streams available from the selected bin clip, in the form: {stream index, stream description} */
QMap <int, QString> m_binAudioTargets;
/** @brief The last combination of audio targets in the form: {timeline track id, bin stream index} */
QMap <int, int> m_lastAudioTarget;
bool m_videoTargetActive {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