m_document->setModified(true);
}
-void CustomTrackView::setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition, QActionGroup *clipTypeGroup)
+void CustomTrackView::setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition, QActionGroup *clipTypeGroup, QMenu *markermenu)
{
m_timelineContextMenu = timeline;
m_timelineContextClipMenu = clip;
m_clipTypeGroup = clipTypeGroup;
+
+ m_markerMenu = new QMenu(i18n("Go to marker..."), this);
+ m_markerMenu->setEnabled(false);
+ markermenu->addMenu(m_markerMenu);
+ connect(m_markerMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotGoToMarker(QAction *)));
QList <QAction *> list = m_timelineContextClipMenu->actions();
for (int i = 0; i < list.count(); i++) {
if (list.at(i)->data().toString() == "paste_effects") m_pasteEffectsAction = list.at(i);
// spacer tool
snappedPos = getSnapPointForPos(mappedXPos + m_spacerOffset);
if (snappedPos < 0) snappedPos = 0;
+
// Make sure there is no collision
QList<QGraphicsItem *> children = m_selectionGroup->childItems();
QPainterPath shape = m_selectionGroup->clipGroupShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0));
QList<QGraphicsItem*> collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
collidingItems.removeAll(m_selectionGroup);
for (int i = 0; i < children.count(); i++) {
+ if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ collidingItems.removeAll(subchildren.at(j));
+ }
+ }
collidingItems.removeAll(children.at(i));
}
bool collision = false;
+ int offset = 0;
+ for (int i = 0; i < collidingItems.count(); i++) {
+ if (!collidingItems.at(i)->isEnabled()) continue;
+ if (collidingItems.at(i)->type() == AVWIDGET && snappedPos < m_selectionGroup->sceneBoundingRect().left()) {
+ AbstractClipItem *item = static_cast <AbstractClipItem *>(collidingItems.at(i));
+ // Moving backward, determine best pos
+ QPainterPath clipPath;
+ clipPath.addRect(item->sceneBoundingRect());
+ QPainterPath res = shape.intersected(clipPath);
+ offset = qMax(offset, (int)(res.boundingRect().width() + 0.5));
+ }
+ }
+ snappedPos += offset;
+ // make sure we have no collision
+ shape = m_selectionGroup->clipGroupShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0));
+ collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
+ collidingItems.removeAll(m_selectionGroup);
+ for (int i = 0; i < children.count(); i++) {
+ if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ collidingItems.removeAll(subchildren.at(j));
+ }
+ }
+ collidingItems.removeAll(children.at(i));
+ }
+
for (int i = 0; i < collidingItems.count(); i++) {
if (!collidingItems.at(i)->isEnabled()) continue;
if (collidingItems.at(i)->type() == AVWIDGET) {
break;
}
}
+
+
if (!collision) {
// Check transitions
shape = m_selectionGroup->transitionGroupShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0));
collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
collidingItems.removeAll(m_selectionGroup);
for (int i = 0; i < children.count(); i++) {
+ if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ collidingItems.removeAll(subchildren.at(j));
+ }
+ }
+ collidingItems.removeAll(children.at(i));
+ }
+ offset = 0;
+
+ for (int i = 0; i < collidingItems.count(); i++) {
+ if (collidingItems.at(i)->type() == TRANSITIONWIDGET && snappedPos < m_selectionGroup->sceneBoundingRect().left()) {
+ AbstractClipItem *item = static_cast <AbstractClipItem *>(collidingItems.at(i));
+ // Moving backward, determine best pos
+ QPainterPath clipPath;
+ clipPath.addRect(item->sceneBoundingRect());
+ QPainterPath res = shape.intersected(clipPath);
+ offset = qMax(offset, (int)(res.boundingRect().width() + 0.5));
+ }
+ }
+
+ snappedPos += offset;
+ // make sure we have no collision
+ shape = m_selectionGroup->transitionGroupShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0));
+ collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
+ collidingItems.removeAll(m_selectionGroup);
+ for (int i = 0; i < children.count(); i++) {
+ if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ collidingItems.removeAll(subchildren.at(j));
+ }
+ }
collidingItems.removeAll(children.at(i));
}
for (int i = 0; i < collidingItems.count(); i++) {
kDebug() << "SELELCTING ELEMENTS WITHIN =" << event->pos().x() << "/" << 1 << ", " << mapFromScene(sceneRect().width(), 0).x() - event->pos().x() << "/" << sceneRect().height();
}
+ QList <GenTime> offsetList;
// create group to hold selected items
m_selectionGroup = new AbstractGroupItem(m_document->fps());
scene()->addItem(m_selectionGroup);
- QList <GenTime> offsetList;
+
for (int i = 0; i < selection.count(); i++) {
if (selection.at(i)->parentItem() == 0 && (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET)) {
AbstractClipItem *item = static_cast<AbstractClipItem *>(selection.at(i));
offsetList.append(item->endPos());
m_selectionGroup->addToGroup(selection.at(i));
selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
- } else if (selection.at(i)->parentItem() == 0 && selection.at(i)->type() == GROUPWIDGET) {
+ } else if (/*selection.at(i)->parentItem() == 0 && */selection.at(i)->type() == GROUPWIDGET) {
if (static_cast<AbstractGroupItem *>(selection.at(i))->isItemLocked()) continue;
QList<QGraphicsItem *> children = selection.at(i)->childItems();
for (int j = 0; j < children.count(); j++) {
}
m_selectionGroup->addToGroup(selection.at(i));
selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
- } else if (selection.at(i)->parentItem()) {
+ } else if (selection.at(i)->parentItem() && !selection.contains(selection.at(i)->parentItem())) {
if (static_cast<AbstractGroupItem *>(selection.at(i)->parentItem())->isItemLocked()) continue;
+ //AbstractGroupItem *grp = static_cast<AbstractGroupItem *>(selection.at(i)->parentItem());
m_selectionGroup->addToGroup(selection.at(i)->parentItem());
selection.at(i)->parentItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
}
{
m_deleteGuide->setEnabled(m_dragGuide != NULL);
m_editGuide->setEnabled(m_dragGuide != NULL);
- if (clip == NULL) m_timelineContextMenu->popup(pos);
- else if (group != NULL) {
+ m_markerMenu->clear();
+ m_markerMenu->setEnabled(false);
+ if (clip == NULL) {
+ m_timelineContextMenu->popup(pos);
+ } else if (group != NULL) {
m_pasteEffectsAction->setEnabled(m_copiedItems.count() == 1);
m_ungroupAction->setEnabled(true);
updateClipTypeActions(NULL);
m_ungroupAction->setEnabled(false);
if (clip->type() == AVWIDGET) {
ClipItem *item = static_cast <ClipItem*>(clip);
+ //build go to marker menu
+ if (item->baseClip()) {
+ QList <CommentedTime> markers = item->baseClip()->commentedSnapMarkers();
+ int offset = item->startPos().frames(m_document->fps());
+ if (!markers.isEmpty()) {
+ for (int i = 0; i < markers.count(); i++) {
+ int pos = (int) markers.at(i).time().frames(m_document->timecode().fps());
+ QString position = m_document->timecode().getTimecode(markers.at(i).time()) + ' ' + markers.at(i).comment();
+ QAction *go = m_markerMenu->addAction(position);
+ go->setData(pos + offset);
+ }
+ }
+ m_markerMenu->setEnabled(!m_markerMenu->isEmpty());
+ }
updateClipTypeActions(item);
m_pasteEffectsAction->setEnabled(m_copiedItems.count() == 1);
m_timelineContextClipMenu->popup(pos);
- } else if (clip->type() == TRANSITIONWIDGET) m_timelineContextTransitionMenu->popup(pos);
+ } else if (clip->type() == TRANSITIONWIDGET) {
+ m_timelineContextTransitionMenu->popup(pos);
+ }
}
}
if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
else effectName = i18n("effect");
effectCommand->setText(i18n("Add %1", effectName));
- int count = 0;
+
if (track == -1) itemList = scene()->selectedItems();
if (itemList.isEmpty()) {
ClipItem *clip = getClipItemAt((int) pos.frames(m_document->fps()), track);
if (clip) itemList.append(clip);
else emit displayMessage(i18n("Select a clip if you want to apply an effect"), ErrorMessage);
}
- kDebug() << "// REQUESTING EFFECT ON CLIP: " << pos.frames(25) << ", TRK: " << track << "SELECTED ITEMS: " << itemList.count();
+
+ //expand groups
+ for (int i = 0; i < itemList.count(); i++) {
+ if (itemList.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subitems = itemList.at(i)->childItems();
+ for (int j = 0; j < subitems.count(); j++) {
+ if (!itemList.contains(subitems.at(j))) itemList.append(subitems.at(j));
+ }
+ }
+ }
+
for (int i = 0; i < itemList.count(); i++) {
if (itemList.at(i)->type() == AVWIDGET) {
ClipItem *item = static_cast <ClipItem *>(itemList.at(i));
effect.setAttribute("src", ladpsaFile);
}
new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), effect, true, effectCommand);
- count++;
}
}
- if (count > 0) {
+ if (effectCommand->childCount() > 0) {
m_commandStack->push(effectCommand);
setDocumentModified();
} else delete effectCommand;
}
-void CustomTrackView::slotDeleteEffect(ClipItem *clip, QDomElement effect)
+void CustomTrackView::slotDeleteEffect(ClipItem *clip, QDomElement effect, bool affectGroup)
{
+ if (affectGroup && clip->parentItem() && clip->parentItem() == m_selectionGroup) {
+ //clip is in a group, also remove the effect in other clips of the group
+ QList<QGraphicsItem *> items = m_selectionGroup->childItems();
+ QUndoCommand *delCommand = new QUndoCommand();
+ QString effectName;
+ QDomNode namenode = effect.elementsByTagName("name").item(0);
+ if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
+ else effectName = i18n("effect");
+ delCommand->setText(i18n("Delete %1", effectName));
+
+ //expand groups
+ for (int i = 0; i < items.count(); i++) {
+ if (items.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subitems = items.at(i)->childItems();
+ for (int j = 0; j < subitems.count(); j++) {
+ if (!items.contains(subitems.at(j))) items.append(subitems.at(j));
+ }
+ }
+ }
+
+ for (int i = 0; i < items.count(); i++) {
+ if (items.at(i)->type() == AVWIDGET) {
+ ClipItem *item = static_cast <ClipItem *>(items.at(i));
+ int ix = item->hasEffect(effect.attribute("tag"), effect.attribute("id"));
+ if (ix != -1) {
+ QDomElement eff = item->effectAt(ix);
+ new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), eff, false, delCommand);
+ }
+ }
+ }
+ if (delCommand->childCount() > 0) m_commandStack->push(delCommand);
+ else delete delCommand;
+ return;
+ }
AddEffectCommand *command = new AddEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effect, false);
m_commandStack->push(command);
setDocumentModified();
int start = item->cropStart().frames(m_document->fps());
int end = item->fadeIn();
if (end == 0) {
- slotDeleteEffect(item, oldeffect);
+ slotDeleteEffect(item, oldeffect, false);
} else {
end += start;
QDomElement effect = oldeffect.cloneNode().toElement();
int start = item->cropStart().frames(m_document->fps());
int end = item->fadeIn();
if (end == 0) {
- slotDeleteEffect(item, oldeffect);
+ slotDeleteEffect(item, oldeffect, false);
} else {
end += start;
QDomElement effect = oldeffect.cloneNode().toElement();
int end = (item->cropDuration() + item->cropStart()).frames(m_document->fps());
int start = item->fadeOut();
if (start == 0) {
- slotDeleteEffect(item, oldeffect);
+ slotDeleteEffect(item, oldeffect, false);
} else {
start = end - start;
QDomElement effect = oldeffect.cloneNode().toElement();
int end = (item->cropDuration() + item->cropStart()).frames(m_document->fps());
int start = item->fadeOut();
if (start == 0) {
- slotDeleteEffect(item, oldeffect);
+ slotDeleteEffect(item, oldeffect, false);
} else {
start = end - start;
QDomElement effect = oldeffect.cloneNode().toElement();
paste->setText("Paste effects");
QList<QGraphicsItem *> clips = scene()->selectedItems();
+
+ // expand groups
+ for (int i = 0; i < clips.count(); ++i) {
+ if (clips.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> children = clips.at(i)->childItems();
+ for (int j = 0; j < children.count(); j++) {
+ if (children.at(j)->type() == AVWIDGET && !clips.contains(children.at(j))) {
+ clips.append(children.at(j));
+ }
+ }
+ }
+ }
+
+
for (int i = 0; i < clips.count(); ++i) {
if (clips.at(i)->type() == AVWIDGET) {
ClipItem *item = static_cast < ClipItem *>(clips.at(i));
}
}
}
- m_commandStack->push(paste);
+ if (paste->childCount() > 0) m_commandStack->push(paste);
+ else delete paste;
- // adjust effects (fades, ...)
+ //adjust effects (fades, ...)
for (int i = 0; i < clips.count(); ++i) {
- ClipItem *item = static_cast < ClipItem *>(clips.at(i));
- updatePositionEffects(item, item->info());
+ if (clips.at(i)->type() == AVWIDGET) {
+ ClipItem *item = static_cast < ClipItem *>(clips.at(i));
+ updatePositionEffects(item, item->info());
+ }
}
}
}
}
+void CustomTrackView::slotGoToMarker(QAction *action)
+{
+ int pos = action->data().toInt();
+ setCursorPos(pos, true);
+}
+
void CustomTrackView::reloadTransitionLumas()
{
QString lumaNames;
new AddTimelineClipCommand(this, clip->toXML(), clip->getId(), info, EffectsList(), true, false, true, false, addCommand);
m_commandStack->push(addCommand);
}
+
+void CustomTrackView::clearSelection()
+{
+ resetSelectionGroup();
+ scene()->clearSelection();
+ m_dragItem = NULL;
+ emit clipItemSelected(NULL);
+}
+