Fix copy/paste when we have more audio tracks than video tracks

parent ac43ebc2
......@@ -628,11 +628,15 @@ QDomElement ClipModel::toXml(QDomDocument &document)
container.setAttribute(QStringLiteral("position"), getPosition());
container.setAttribute(QStringLiteral("state"), (int)m_currentState);
if (auto ptr = m_parent.lock()) {
int trackId = ptr->getTrackPosition(getCurrentTrackId());
int trackId = ptr->getTrackPosition(m_currentTrackId);
container.setAttribute(QStringLiteral("track"), trackId);
if (ptr->isAudioTrack(getCurrentTrackId())) {
container.setAttribute(QStringLiteral("audioTrack"), 1);
container.setAttribute(QStringLiteral("mirrorTrack"), ptr->getTrackPosition(ptr->getMirrorVideoTrackId(getCurrentTrackId())));
int mirrorId = ptr->getMirrorVideoTrackId(m_currentTrackId);
if (mirrorId > -1) {
mirrorId = ptr->getTrackPosition(mirrorId);
}
container.setAttribute(QStringLiteral("mirrorTrack"), mirrorId);
}
}
container.setAttribute(QStringLiteral("speed"), m_speed);
......
......@@ -610,7 +610,10 @@ void TimelineController::copyItem()
if (audioCopy) {
int masterMirror = m_model->getMirrorVideoTrackId(masterTid);
if (masterMirror == -1) {
container.setAttribute(QStringLiteral("audioCopy"), 1);
QPair<QList <int>, QList <int> > projectTracks = TimelineFunctions::getAVTracksIds(m_model);
if (!projectTracks.second.isEmpty()) {
masterTrack = m_model->getTrackPosition(projectTracks.second.first());
}
} else {
masterTrack = m_model->getTrackPosition(masterMirror);
}
......@@ -657,7 +660,6 @@ bool TimelineController::pasteItem()
QMap<QString, QString> mappedIds;
// Check available tracks
QPair<QList <int>, QList <int> > projectTracks = TimelineFunctions::getAVTracksIds(m_model);
bool masterIsAudio = copiedItems.documentElement().hasAttribute(QStringLiteral("audioCopy"));
int masterSourceTrack = copiedItems.documentElement().attribute(QStringLiteral("masterTrack")).toInt();
QDomNodeList clips = copiedItems.documentElement().elementsByTagName(QStringLiteral("clip"));
QDomNodeList compositions = copiedItems.documentElement().elementsByTagName(QStringLiteral("composition"));
......@@ -723,6 +725,7 @@ bool TimelineController::pasteItem()
// Check we have enough tracks above/below
if (requestedVideoTracks > 0) {
qDebug()<<"MASTERSTK: "<<masterSourceTrack<<", VTKS: "<<videoTracks;
int tracksBelow = masterSourceTrack - videoTracks.first();
int tracksAbove = videoTracks.last() - masterSourceTrack;
qDebug()<<"// RQST TKS BELOW: "<<tracksBelow<<" / ABOVE: "<<tracksAbove;
......@@ -747,17 +750,17 @@ bool TimelineController::pasteItem()
tracksMap.insert(tk, projectTracks.second.at(masterIx + tk - masterSourceTrack));
qDebug()<<"// TK MAP: "<<tk<<" => "<<projectTracks.second.at(masterIx + tk - masterSourceTrack);
}
QMapIterator<int, int> i(audioMirrors);
while (i.hasNext()) {
i.next();
int videoIx = tracksMap.value(i.value());
qDebug()<<"// TK AUDIO MAP: "<<i.key()<<" => "<<videoIx<<" ; AUDIO MIRROR: "<<m_model->getMirrorAudioTrackId(videoIx);
tracksMap.insert(i.key(), m_model->getMirrorAudioTrackId(videoIx));
QMapIterator<int, int> it(audioMirrors);
while (it.hasNext()) {
it.next();
int videoIx = tracksMap.value(it.value());
//qDebug()<<"// TK AUDIO MAP: "<<it.key()<<" => "<<videoIx<<" ; AUDIO MIRROR: "<<m_model->getMirrorAudioTrackId(videoIx);
tracksMap.insert(it.key(), m_model->getMirrorAudioTrackId(videoIx));
}
qDebug()<<"++++++++++++++++++++++++++\n\n\n// AUDIO MIRRORS: "<<audioMirrors<<", RESULT: "<<tracksMap;
for (int tk : singleAudioTracks) {
//TODO
for (int i = 0; i < singleAudioTracks.size(); i++) {
tracksMap.insert(singleAudioTracks.at(i), projectTracks.first.at(i));
}
qDebug()<<"++++++++++++++++++++++++++\n\n\n// AUDIO MIRRORS: "<<audioMirrors<<", RESULT: "<<tracksMap;
if (!docId.isEmpty() && docId != pCore->currentDoc()->getDocumentProperty(QStringLiteral("documentid"))) {
// paste from another document, import bin clips
QString folderId = pCore->projectItemModel()->getFolderIdByName(i18n("Pasted clips"));
......
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