if (event->buttons() != Qt::NoButton && event->modifiers() == Qt::NoModifier) {
QGraphicsView::mouseMoveEvent(event);
m_moveOpMode = SEEK;
- seekCursorPos(mappedXPos);
- slotCheckPositionScrolling();
+ if (mappedXPos != m_document->renderer()->getCurrentSeekPosition() && mappedXPos != cursorPos()) {
+ seekCursorPos(mappedXPos);
+ slotCheckPositionScrolling();
+ }
return;
} else m_moveOpMode = NONE;
}
AbstractGroupItem *dragGroup = NULL;
AbstractClipItem *collisionClip = NULL;
bool found = false;
+ QStringList lockedTracks;
+ double yOffset = 0;
while (!m_dragGuide && ct < collisionList.count()) {
if (collisionList.at(ct)->type() == AVWIDGET || collisionList.at(ct)->type() == TRANSITIONWIDGET) {
collisionClip = static_cast <AbstractClipItem *>(collisionList.at(ct));
m_dragItem = collisionClip;
}
found = true;
-
- m_dragItem->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
+ for (int i = 0; i < m_document->tracksCount(); i++) {
+ if (m_document->trackInfoAt(i).isLocked) lockedTracks << QString::number(m_document->tracksCount() - i - 1);
+ }
+ yOffset = mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y();
+ m_dragItem->setProperty("y_absolute", yOffset);
+ m_dragItem->setProperty("locked_tracks", lockedTracks);
m_dragItemInfo = m_dragItem->info();
- if (m_selectionGroup) m_selectionGroup->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
- if (m_dragItem->parentItem() && m_dragItem->parentItem()->type() == GROUPWIDGET && m_dragItem->parentItem() != m_selectionGroup) {
+ if (m_selectionGroup) {
+ m_selectionGroup->setProperty("y_absolute", yOffset);
+ m_selectionGroup->setProperty("locked_tracks", lockedTracks);
+ }
+ if (dragGroup) {
dragGroup = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
- dragGroup->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
+ dragGroup->setProperty("y_absolute", yOffset);
+ dragGroup->setProperty("locked_tracks", lockedTracks);
}
break;
}
}
m_operationMode = NONE;
+ if (dragGroup == NULL) {
+ if (m_dragItem && m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup)
+ dragGroup = static_cast<AbstractGroupItem*> (m_dragItem->parentItem());
+ }
displayContextMenu(event->globalPos(), m_dragItem, dragGroup);
m_menuPosition = m_clickEvent;
}
bool selected = !m_dragItem->isSelected();
QGraphicsView::mousePressEvent(event);
-
if (dragGroup) {
dragGroup->setSelected(selected);
- if (dragGroup->parentItem())
+ QList<QGraphicsItem *> children = dragGroup->childItems();
+ for (int i = 0; i < children.count(); i++) {
+ children.at(i)->setSelected(selected);
+ }
+ if (dragGroup->parentItem()) {
dragGroup->parentItem()->setSelected(selected);
+ }
}
else
m_dragItem->setSelected(selected);
m_dragItem = NULL;
}
groupSelectedItems(QList <QGraphicsItem*>(), false, true);
+ if (m_selectionGroup) {
+ m_selectionGroup->setProperty("y_absolute", yOffset);
+ m_selectionGroup->setProperty("locked_tracks", lockedTracks);
+ }
+
if (m_dragItem) {
ClipItem *clip = static_cast <ClipItem *>(m_dragItem);
updateClipTypeActions(dragGroup == NULL ? clip : NULL);
for (int i = 0; i < selection.count(); i++) {
if (selectNewGroup) selection.at(i)->setSelected(true);
if (selection.at(i)->type() == GROUPWIDGET) {
- groupsList.insert(static_cast<AbstractGroupItem*> (selection.at(i)));
+ AbstractGroupItem *it = static_cast <AbstractGroupItem *> (selection.at(i));
+ if (!it || it->isItemLocked()) continue;
+ groupsList.insert(it);
}
}
for (int i = 0; i < selection.count(); i++) {
if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET) {
if (selection.at(i)->parentItem() && selection.at(i)->parentItem()->type() == GROUPWIDGET) {
- groupsList.insert(static_cast <QGraphicsItemGroup *> (selection.at(i)->parentItem()));
+ AbstractGroupItem *it = static_cast <AbstractGroupItem *> (selection.at(i)->parentItem());
+ if (!it || it->isItemLocked()) continue;
+ groupsList.insert(it);
}
else {
+ AbstractClipItem *it = static_cast<AbstractClipItem *> (selection.at(i));
+ if (!it || it->isItemLocked()) continue;
itemsList.insert(selection.at(i));
}
}
bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint &pos)
{
- if (data->hasFormat("kdenlive/clip")) {
- m_clipDrag = true;
- m_scene->clearSelection();
- resetSelectionGroup(false);
+ QPointF framePos = mapToScene(pos);
+ int track = framePos.y() / KdenliveSettings::trackheight();
+ m_scene->clearSelection();
+ m_dragItem = NULL;
+ resetSelectionGroup(false);
+ m_clipDrag = data->hasFormat("kdenlive/clip") || data->hasFormat("kdenlive/producerslist");
+ // This is not a clip drag, maybe effect or other...
+ if (!m_clipDrag) return false;
+ if (track < 0 || track > m_document->tracksCount() - 1 || m_document->trackInfoAt(m_document->tracksCount() - track - 1).isLocked) return true;
+ if (data->hasFormat("kdenlive/clip")) {
QStringList list = QString(data->data("kdenlive/clip")).split(';');
DocClipBase *clip = m_document->getBaseClip(list.at(0));
if (clip == NULL) {
emit displayMessage(i18n("Clip not ready"), ErrorMessage);
return false;
}
- QPointF framePos = mapToScene(pos);
ItemInfo info;
info.startPos = GenTime();
info.cropStart = GenTime(list.at(1).toInt(), m_document->fps());
QList <GenTime> offsetList;
offsetList.append(info.endPos);
updateSnapPoints(NULL, offsetList);
+ QStringList lockedTracks;
+ for (int i = 0; i < m_document->tracksCount(); i++) {
+ if (m_document->trackInfoAt(i).isLocked) lockedTracks << QString::number(m_document->tracksCount() - i - 1);
+ }
+ m_selectionGroup->setProperty("locked_tracks", lockedTracks);
m_selectionGroup->setPos(framePos);
scene()->addItem(m_selectionGroup);
m_selectionGroup->setSelected(true);
- return true;
} else if (data->hasFormat("kdenlive/producerslist")) {
- m_clipDrag = true;
QStringList ids = QString(data->data("kdenlive/producerslist")).split(';');
- m_scene->clearSelection();
- resetSelectionGroup(false);
QList <GenTime> offsetList;
QList <ItemInfo> infoList;
- QPointF framePos = mapToScene(pos);
GenTime start = GenTime((int)(framePos.x() + 0.5), m_document->fps());
int track = (int)(framePos.y() / m_tracksHeight);
framePos.setX((int)(framePos.x() + 0.5));
if (!canBePastedTo(infoList, AVWIDGET)) {
return true;
}
- m_selectionGroup = new AbstractGroupItem(m_document->fps());
+ if (ids.size() > 1) m_selectionGroup = new AbstractGroupItem(m_document->fps());
start = GenTime();
for (int i = 0; i < ids.size(); ++i) {
QString clipData = ids.at(i);
start += info.cropDuration;
offsetList.append(start);
ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1, getFrameWidth(), false);
- m_selectionGroup->addItem(item);
+ if (ids.size() > 1) m_selectionGroup->addItem(item);
+ else m_dragItem = item;
+ item->setSelected(true);
if (!clip->isPlaceHolder()) m_waitingThumbs.append(item);
}
updateSnapPoints(NULL, offsetList);
- m_selectionGroup->setPos(framePos);
- scene()->addItem(m_selectionGroup);
+ QStringList lockedTracks;
+ for (int i = 0; i < m_document->tracksCount(); i++) {
+ if (m_document->trackInfoAt(i).isLocked) lockedTracks << QString::number(m_document->tracksCount() - i - 1);
+ }
+
+ if (m_selectionGroup) {
+ m_selectionGroup->setProperty("locked_tracks", lockedTracks);
+ m_selectionGroup->setPos(framePos);
+ scene()->addItem(m_selectionGroup);
+ }
+ else if (m_dragItem) {
+ m_dragItem->setProperty("locked_tracks", lockedTracks);
+ m_dragItem->setPos(framePos);
+ scene()->addItem(m_dragItem);
+ }
//m_selectionGroup->setZValue(10);
m_thumbsTimer.start();
- return true;
-
- } else {
- // the drag is not a clip (may be effect, ...)
- m_clipDrag = false;
- return false;
}
+ return true;
}
m_selectionGroup->setPos(pos);
emit mousePosition((int)(m_selectionGroup->scenePos().x() + 0.5));
event->acceptProposedAction();
- } else {
+ } else if (m_dragItem) {
+ m_dragItem->setPos(pos);
+ emit mousePosition((int)(m_dragItem->scenePos().x() + 0.5));
+ event->acceptProposedAction();
+ } else {
// Drag enter was not possible, try again at mouse position
insertDropClips(event->mimeData(), event->pos());
event->accept();
void CustomTrackView::dragLeaveEvent(QDragLeaveEvent * event)
{
- if (m_selectionGroup && m_clipDrag) {
+ if ((m_selectionGroup || m_dragItem) && m_clipDrag) {
m_thumbsTimer.stop();
m_waitingThumbs.clear();
- QList<QGraphicsItem *> items = m_selectionGroup->childItems();
+ QList<QGraphicsItem *> items;
+ if (m_selectionGroup) items = m_selectionGroup->childItems();
+ else if (m_dragItem) items.append(m_dragItem);
qDeleteAll(items);
- scene()->destroyItemGroup(m_selectionGroup);
+ if (m_selectionGroup) scene()->destroyItemGroup(m_selectionGroup);
m_selectionGroup = NULL;
+ m_dragItem = NULL;
+ event->accept();
} else QGraphicsView::dragLeaveEvent(event);
}
void CustomTrackView::dropEvent(QDropEvent * event)
{
- if (m_selectionGroup && m_clipDrag) {
- QList<QGraphicsItem *> items = m_selectionGroup->childItems();
+ if ((m_selectionGroup || m_dragItem) && m_clipDrag) {
+ QList<QGraphicsItem *> items;
+ if (m_selectionGroup) items = m_selectionGroup->childItems();
+ else if (m_dragItem) items.append(m_dragItem);
resetSelectionGroup();
m_dragItem = NULL;
m_scene->clearSelection();
if (effectPos != -1) {
QDomElement effect = item->getEffectAtIndex(effectPos);
int max = item->cropDuration().frames(m_document->fps());
- int end = max + item->cropStart().frames(m_document->fps());
+ int end = max + item->cropStart().frames(m_document->fps()) - 1;
if (start > max) {
// Make sure the fade effect is not longer than the clip
item->setFadeOut(max);
if (effectPos != -1) {
QDomElement effect = item->getEffectAtIndex(effectPos);
int max = item->cropDuration().frames(m_document->fps());
- int end = max + item->cropStart().frames(m_document->fps());
+ int end = max + item->cropStart().frames(m_document->fps()) - 1;
if (start > max) {
// Make sure the fade effect is not longer than the clip
item->setFadeOut(max);
void CustomTrackView::editGuide(const GenTime &oldPos, const GenTime &pos, const QString &comment)
{
- if (oldPos > GenTime() && pos > GenTime()) {
- // move guide
+ if (comment.isEmpty() && pos < GenTime()) {
+ // Delete guide
+ bool found = false;
for (int i = 0; i < m_guides.count(); i++) {
if (m_guides.at(i)->position() == oldPos) {
- Guide *item = m_guides.at(i);
- item->updateGuide(pos, comment);
+ delete m_guides.takeAt(i);
+ found = true;
break;
}
}
- } else if (pos > GenTime()) addGuide(pos, comment);
- else {
- // remove guide
- bool found = false;
+ if (!found) emit displayMessage(i18n("No guide at cursor time"), ErrorMessage);
+ }
+
+ else if (oldPos >= GenTime()) {
+ // move guide
for (int i = 0; i < m_guides.count(); i++) {
if (m_guides.at(i)->position() == oldPos) {
- delete m_guides.takeAt(i);
- found = true;
+ Guide *item = m_guides.at(i);
+ item->updateGuide(pos, comment);
break;
}
}
- if (!found) emit displayMessage(i18n("No guide at cursor time"), ErrorMessage);
- }
+ } else addGuide(pos, comment);
qSort(m_guides.begin(), m_guides.end(), sortGuidesList);
m_document->syncGuides(m_guides);
}
bool found = false;
for (int i = 0; i < m_guides.count(); i++) {
if (m_guides.at(i)->position() == pos) {
- EditGuideCommand *command = new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(), QString(), true);
+ EditGuideCommand *command = new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(-1), QString(), true);
m_commandStack->push(command);
found = true;
break;
void CustomTrackView::slotDeleteTimeLineGuide()
{
if (m_dragGuide == NULL) return;
- EditGuideCommand *command = new EditGuideCommand(this, m_dragGuide->position(), m_dragGuide->label(), GenTime(), QString(), true);
+ EditGuideCommand *command = new EditGuideCommand(this, m_dragGuide->position(), m_dragGuide->label(), GenTime(-1), QString(), true);
m_commandStack->push(command);
}
QUndoCommand *deleteAll = new QUndoCommand();
deleteAll->setText("Delete all guides");
for (int i = 0; i < m_guides.count(); i++) {
- new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(), QString(), true, deleteAll);
+ new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(-1), QString(), true, deleteAll);
}
m_commandStack->push(deleteAll);
}