From: Jean-Baptiste M. <jb...@kd...> - 2012-10-05 13:27:52
|
Git commit 6c21c88fa32bd16d78e6645f8ec1fe6ad7e5e2b4 by Jean-Baptiste Mardelle. Committed on 05/10/2012 at 15:01. Pushed by mardelle into branch 'master'. Fix insertion of several clip zones in timeline M +27 -7 src/customtrackview.cpp M +31 -47 src/projectlistview.cpp http://commits.kde.org/kdenlive/6c21c88fa32bd16d78e6645f8ec1fe6ad7e5e2b4 diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 3d4ac7e..2d55c1d 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -1566,7 +1566,8 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint &pos) // Check if clips can be inserted at that position for (int i = 0; i < ids.size(); ++i) { - DocClipBase *clip = m_document->getBaseClip(ids.at(i)); + QString clipData = ids.at(i); + DocClipBase *clip = m_document->getBaseClip(clipData.section('/', 0, 0)); if (clip == NULL) { kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << ids.at(i); return false; @@ -1577,11 +1578,20 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint &pos) } ItemInfo info; info.startPos = start; - info.cropDuration = clip->duration(); - info.endPos = info.startPos + info.cropDuration; + if (clipData.contains('/')) { + // this is a clip zone, set in / out + int in = clipData.section('/', 1, 1).toInt(); + int out = clipData.section('/', 2, 2).toInt(); + info.cropStart = GenTime(in, m_document->fps()); + info.cropDuration = GenTime(out - in, m_document->fps()); + } + else { + info.cropDuration = clip->duration(); + } + info.endPos = info.startPos + info.cropDuration; info.track = track; infoList.append(info); - start += clip->duration(); + start += info.cropDuration; } if (!canBePastedTo(infoList, AVWIDGET)) { return true; @@ -1589,11 +1599,21 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint &pos) m_selectionGroup = new AbstractGroupItem(m_document->fps()); start = GenTime(); for (int i = 0; i < ids.size(); ++i) { - DocClipBase *clip = m_document->getBaseClip(ids.at(i)); + QString clipData = ids.at(i); + DocClipBase *clip = m_document->getBaseClip(clipData.section('/', 0, 0)); ItemInfo info; info.startPos = start; - info.cropDuration = clip->duration(); - info.endPos = info.startPos + info.cropDuration; + if (clipData.contains('/')) { + // this is a clip zone, set in / out + int in = clipData.section('/', 1, 1).toInt(); + int out = clipData.section('/', 2, 2).toInt(); + info.cropStart = GenTime(in, m_document->fps()); + info.cropDuration = GenTime(out - in, m_document->fps()); + } + else { + info.cropDuration = clip->duration(); + } + info.endPos = info.startPos + info.cropDuration; info.track = 0; start += info.cropDuration; offsetList.append(start); diff --git a/src/projectlistview.cpp b/src/projectlistview.cpp index e4a2641..cda2480 100644 --- a/src/projectlistview.cpp +++ b/src/projectlistview.cpp @@ -347,56 +347,40 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event) QTreeWidgetItem *it = itemAt(m_DragStartPosition); if (!it) return; - if (it->type() == PROJECTSUBCLIPTYPE) { - // subitem - SubProjectItem *clickItem = static_cast <SubProjectItem *>(it); - if (clickItem && (clickItem->flags() & Qt::ItemIsDragEnabled)) { - ProjectItem *clip = static_cast <ProjectItem *>(it->parent()); - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - - QStringList list; - list.append(clip->clipId()); - QPoint p = clickItem->zone(); - list.append(QString::number(p.x())); - list.append(QString::number(p.y())); - QByteArray data; - data.append(list.join(";").toUtf8()); - mimeData->setData("kdenlive/clip", data); - drag->setMimeData(mimeData); - drag->setPixmap(clickItem->data(0, Qt::DecorationRole).value<QPixmap>()); - drag->setHotSpot(QPoint(0, 50)); - drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction); - } - } else { - if (it && (it->flags() & Qt::ItemIsDragEnabled)) { - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - const QList <QTreeWidgetItem *> list = selectedItems(); - QStringList ids; - foreach(const QTreeWidgetItem *item, list) { - if (item->type() == PROJECTFOLDERTYPE) { - const int children = item->childCount(); - for (int i = 0; i < children; i++) { - ids.append(static_cast <ProjectItem *>(item->child(i))->clipId()); - } - } else { - const ProjectItem *clip = static_cast <const ProjectItem *>(item); - ids.append(clip->clipId()); + if (it && (it->flags() & Qt::ItemIsDragEnabled)) { + QDrag *drag = new QDrag(this); + QMimeData *mimeData = new QMimeData; + const QList <QTreeWidgetItem *> list = selectedItems(); + QStringList ids; + foreach(const QTreeWidgetItem *item, list) { + if (item->type() == PROJECTFOLDERTYPE) { + const int children = item->childCount(); + for (int i = 0; i < children; i++) { + ids.append(static_cast <ProjectItem *>(item->child(i))->clipId()); } + } else if (item->type() == PROJECTSUBCLIPTYPE) { + const ProjectItem *parentclip = static_cast <const ProjectItem *>(item->parent()); + const SubProjectItem *clickItem = static_cast <const SubProjectItem *>(item); + QPoint p = clickItem->zone(); + QString data = parentclip->clipId(); + data.append("/" + QString::number(p.x())); + data.append("/" + QString::number(p.y())); + ids.append(data); + } else { + const ProjectItem *clip = static_cast <const ProjectItem *>(item); + ids.append(clip->clipId()); } - if (ids.isEmpty()) return; - QByteArray data; - data.append(ids.join(";").toUtf8()); //doc.toString().toUtf8()); - mimeData->setData("kdenlive/producerslist", data); - //mimeData->setText(ids.join(";")); //doc.toString()); - //mimeData->setImageData(image); - drag->setMimeData(mimeData); - drag->setPixmap(it->data(0, Qt::DecorationRole).value<QPixmap>()); - drag->setHotSpot(QPoint(0, 50)); - drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction); } - //event->accept(); + if (ids.isEmpty()) return; + QByteArray data; + data.append(ids.join(";").toUtf8()); //doc.toString().toUtf8()); + mimeData->setData("kdenlive/producerslist", data); + //mimeData->setText(ids.join(";")); //doc.toString()); + //mimeData->setImageData(image); + drag->setMimeData(mimeData); + drag->setPixmap(it->data(0, Qt::DecorationRole).value<QPixmap>()); + drag->setHotSpot(QPoint(0, 40)); + drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction); } } |