if (event->buttons() != Qt::NoButton) {
bool move = (event->pos() - m_clickEvent).manhattanLength() >= QApplication::startDragDistance();
+ if (m_dragItem && move) m_clipDrag = true;
if (m_dragItem && m_tool == SELECTTOOL) {
- if (m_operationMode == MOVE && move) {
- //m_dragItem->setProperty("y_absolute", event->pos().y());
+ if (m_operationMode == MOVE && m_clipDrag) {
QGraphicsView::mouseMoveEvent(event);
// If mouse is at a border of the view, scroll
if (pos < 5) {
{
setFocus(Qt::MouseFocusReason);
m_menuPosition = QPoint();
+ m_clipDrag = false;
// special cases (middle click button or ctrl / shift click
if (event->button() == Qt::MidButton) {
collisionClip = static_cast <AbstractClipItem *>(collisionList.at(ct));
if (collisionClip->isItemLocked())
break;
- if (collisionClip == m_dragItem)
+ if (collisionClip == m_dragItem) {
collisionClip = NULL;
- else
+ }
+ else {
m_dragItem = collisionClip;
+ }
found = true;
m_dragItem->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
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) {
- // kDebug()<<"// KLIK FOUND GRP: "<<m_dragItem->sceneBoundingRect();
dragGroup = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
+ dragGroup->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
}
break;
}
if (m_dragItem) emit clipItemSelected(NULL);
m_dragItem = NULL;
}
-#if QT_VERSION >= 0x040600
+#if QT_VERSION >= 0x040800
// Add shadow to dragged item, currently disabled because of painting artifacts
- //TODO: re-enable when fixed
- /*QGraphicsDropShadowEffect *eff = new QGraphicsDropShadowEffect();
- eff->setBlurRadius(5);
- eff->setOffset(3, 3);
- m_dragItem->setGraphicsEffect(eff);*/
+ /*if (m_dragItem) {
+ QGraphicsDropShadowEffect *eff = new QGraphicsDropShadowEffect();
+ eff->setBlurRadius(5);
+ eff->setOffset(3, 3);
+ m_dragItem->setGraphicsEffect(eff);
+ }*/
#endif
if (m_dragItem && m_dragItem->type() == TRANSITIONWIDGET) {
// update transition menu action
if (item->isItemLocked()) continue;
offsetList.append(item->startPos());
offsetList.append(item->endPos());
- m_selectionGroup->addToGroup(selection.at(i));
- selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(selection.at(i));
} 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();
offsetList.append(item->startPos());
offsetList.append(item->endPos());
}
- m_selectionGroup->addToGroup(selection.at(i));
- selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(selection.at(i));
} 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_selectionGroup->addItem(selection.at(i)->parentItem());
}
}
m_spacerOffset = m_selectionGroup->sceneBoundingRect().left() - (int)(mapToScene(m_clickEvent).x());
} else {
seekCursorPos((int)(mapToScene(event->x(), 0).x()));
}
- //QGraphicsView::mousePressEvent(event);
+ QGraphicsView::mousePressEvent(event);
event->ignore();
return;
}
}
bool itemSelected = false;
- if (m_dragItem->isSelected())
+ if (m_dragItem->isSelected()) {
itemSelected = true;
- else if (m_dragItem->parentItem() && m_dragItem->parentItem()->isSelected())
+ }
+ else if (m_dragItem->parentItem() && m_dragItem->parentItem()->isSelected()) {
itemSelected = true;
- else if (dragGroup && dragGroup->isSelected())
+ }
+ else if (dragGroup && dragGroup->isSelected()) {
itemSelected = true;
+ }
if ((event->modifiers() == Qt::ControlModifier) || itemSelected == false) {
if (event->modifiers() != Qt::ControlModifier) {
if (m_dragItem->parentItem() && m_dragItem->parentItem()->type() == GROUPWIDGET) {
dragGroup = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
}
+
bool selected = !m_dragItem->isSelected();
- /*if (dragGroup)
+ QGraphicsView::mousePressEvent(event);
+
+ if (dragGroup) {
dragGroup->setSelected(selected);
- else*/
+ if (dragGroup->parentItem())
+ dragGroup->parentItem()->setSelected(selected);
+ }
+ else
m_dragItem->setSelected(selected);
if (selected == false) {
m_dragItem = NULL;
}
else updateClipTypeActions(NULL);
}
+ else {
+ QGraphicsView::mousePressEvent(event);
+ if (m_selectionGroup) {
+ QList<QGraphicsItem *> children = m_selectionGroup->childItems();
+ for (int i = 0; i < children.count(); i++) {
+ children.at(i)->setSelected(itemSelected);
+ }
+ m_selectionGroup->setSelected(itemSelected);
+
+ }
+ if (dragGroup)
+ dragGroup->setSelected(itemSelected);
+ m_dragItem->setSelected(itemSelected);
+ }
if (collisionClip != NULL || m_dragItem == NULL) {
if (m_dragItem && m_dragItem->type() == AVWIDGET && !m_dragItem->isItemLocked()) {
// If clicked item is selected, allow move
//if (!(event->modifiers() | Qt::ControlModifier) && m_operationMode == NONE)
- QGraphicsView::mousePressEvent(event);
+ //QGraphicsView::mousePressEvent(event);
if (m_dragItem) {
m_clickPoint = QPoint((int)(mapToScene(event->pos()).x() - m_dragItem->startPos().frames(m_document->fps())), (int)(event->pos().y() - m_dragItem->pos().y()));
}
m_blockRefresh = false;
- //kDebug()<<pos;
- QGraphicsView::mousePressEvent(event);
}
void CustomTrackView::rebuildGroup(int childTrack, GenTime childPos)
void CustomTrackView::rebuildGroup(AbstractGroupItem *group)
{
if (group) {
- resetSelectionGroup(false);
- m_scene->clearSelection();
-
QList <QGraphicsItem *> children = group->childItems();
m_document->clipManager()->removeGroup(group);
- scene()->destroyItemGroup(group);
- for (int i = 0; i < children.count(); i++)
- children.at(i)->setSelected(true);
- groupSelectedItems(false, true);
+ /*for (int i = 0; i < children.count(); i++) {
+ group->removeFromGroup(children.at(i));
+ }*/
+ scene()->destroyItemGroup(group);
+ groupSelectedItems(children, false, true, true);
}
}
QList<QGraphicsItem *> children = m_selectionGroup->childItems();
scene()->destroyItemGroup(m_selectionGroup);
+ m_selectionGroup = NULL;
for (int i = 0; i < children.count(); i++) {
if (children.at(i)->parentItem() == 0 && (children.at(i)->type() == AVWIDGET || children.at(i)->type() == TRANSITIONWIDGET)) {
if (!static_cast <AbstractClipItem *>(children.at(i))->isItemLocked()) {
children.at(i)->setSelected(selectItems);
}
}
-
- m_selectionGroup = NULL;
KdenliveSettings::setSnaptopoints(snap);
}
}
-void CustomTrackView::groupSelectedItems(bool force, bool createNewGroup)
+void CustomTrackView::groupSelectedItems(QList <QGraphicsItem *> selection, bool force, bool createNewGroup, bool selectNewGroup)
{
if (m_selectionGroup) {
kDebug() << "///// ERROR, TRYING TO OVERRIDE EXISTING GROUP";
return;
}
- QList<QGraphicsItem *> selection = m_scene->selectedItems();
- if (m_dragItem && !selection.contains(m_dragItem)) {
- selection << m_dragItem;
+ if (selection.isEmpty()) selection = m_scene->selectedItems();
+ // Split groups and items
+ QSet <QGraphicsItemGroup *> groupsList;
+ QSet <QGraphicsItem *> itemsList;
+
+ for (int i = 0; i < selection.count(); i++) {
+ if (selection.at(i)->type() == GROUPWIDGET) {
+ groupsList.insert(static_cast<AbstractGroupItem*> (selection.at(i)));
+ }
+ }
+ 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()));
+ }
+ else {
+ itemsList.insert(selection.at(i));
+ }
+ }
}
- if (selection.isEmpty()) return;
+ if (itemsList.isEmpty() && groupsList.isEmpty()) return;
+
QRectF rectUnion;
// Find top left position of selection
- for (int i = 0; i < selection.count(); i++) {
- if (selection.at(i)->parentItem() == 0 && (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET)) {
- rectUnion = rectUnion.united(selection.at(i)->sceneBoundingRect());
- } else if (selection.at(i)->parentItem()) {
- rectUnion = rectUnion.united(selection.at(i)->parentItem()->sceneBoundingRect());
- }
+ foreach (const QGraphicsItemGroup *value, groupsList) {
+ rectUnion = rectUnion.united(value->sceneBoundingRect());
+ }
+ foreach (const QGraphicsItem *value, itemsList) {
+ rectUnion = rectUnion.united(value->sceneBoundingRect());
}
-
if (force || selection.count() > 1) {
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
//newGroup->translate((int) -rectUnion.left(), (int) -rectUnion.top() + 1);
scene()->addItem(newGroup);
-
// Check if we are trying to include a group in a group
- QList <AbstractGroupItem *> groups;
- for (int i = 0; i < selection.count(); i++) {
- if (selection.at(i)->type() == GROUPWIDGET && !groups.contains(static_cast<AbstractGroupItem *>(selection.at(i))))
- groups.append(static_cast<AbstractGroupItem *>(selection.at(i)));
- else if (selection.at(i)->parentItem() && !groups.contains(static_cast<AbstractGroupItem *>(selection.at(i)->parentItem())))
- groups.append(static_cast<AbstractGroupItem *>(selection.at(i)->parentItem()));
- }
- if (!groups.isEmpty()) {
- // ungroup previous groups
- while (!groups.isEmpty()) {
- AbstractGroupItem *grp = groups.takeFirst();
- m_document->clipManager()->removeGroup(grp);
- scene()->destroyItemGroup(grp);
- }
- selection = m_scene->selectedItems();
- }
+ foreach (QGraphicsItemGroup *value, groupsList) {
+ QList<QGraphicsItem *> children = value->childItems();
+ for (int i = 0; i < children.count(); i++) {
+ if (children.at(i)->type() == AVWIDGET || children.at(i)->type() == TRANSITIONWIDGET)
+ itemsList.insert(children.at(i));
+ }
+ AbstractGroupItem *grp = static_cast<AbstractGroupItem *>(value);
+ m_document->clipManager()->removeGroup(grp);
+ scene()->destroyItemGroup(grp);
+ }
- for (int i = 0; i < selection.count(); i++) {
- if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET) {
- newGroup->addToGroup(selection.at(i));
- selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
- }
+ foreach (QGraphicsItem *value, itemsList) {
+ newGroup->addItem(value);
}
KdenliveSettings::setSnaptopoints(snap);
+ if (selectNewGroup) newGroup->setSelected(true);
} else {
m_selectionGroup = new AbstractGroupItem(m_document->fps());
m_selectionGroup->setPos(rectUnion.left(), rectUnion.top() - 1);
m_selectionGroup->translate(- diff.x(), -diff.y());
scene()->addItem(m_selectionGroup);
- for (int i = 0; i < selection.count(); i++) {
- if (selection.at(i)->parentItem() == 0 && (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET)) {
- m_selectionGroup->addToGroup(selection.at(i));
- selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
- }
+ foreach (QGraphicsItemGroup *value, groupsList) {
+ m_selectionGroup->addItem(value);
+ }
+ foreach (QGraphicsItem *value, itemsList) {
+ m_selectionGroup->addItem(value);
}
KdenliveSettings::setSnaptopoints(snap);
if (m_selectionGroup) {
m_selectionGroupInfo.startPos = GenTime(m_selectionGroup->scenePos().x(), m_document->fps());
m_selectionGroupInfo.track = m_selectionGroup->track();
+ if (selectNewGroup) m_selectionGroup->setSelected(true);
}
}
} else resetSelectionGroup();
}
m_selectionGroup = new AbstractGroupItem(m_document->fps());
ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1, getFrameWidth());
- m_selectionGroup->addToGroup(item);
- item->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(item);
QList <GenTime> offsetList;
offsetList.append(info.endPos);
start += info.cropDuration;
offsetList.append(start);
ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1, getFrameWidth(), false);
- item->setFlag(QGraphicsItem::ItemIsMovable, false);
- m_selectionGroup->addToGroup(item);
+ m_selectionGroup->addItem(item);
if (!clip->isPlaceHolder()) m_waitingThumbs.append(item);
}
if (m_selectionGroup && m_clipDrag) {
QList<QGraphicsItem *> items = m_selectionGroup->childItems();
resetSelectionGroup();
+ m_dragItem = NULL;
m_scene->clearSelection();
bool hasVideoClip = false;
QUndoCommand *addCommand = new QUndoCommand();
m_pasteEffectsAction->setEnabled(m_copiedItems.count() == 1);
if (items.count() > 1) {
- groupSelectedItems(true);
+ groupSelectedItems(items, true);
} else if (items.count() == 1) {
m_dragItem = static_cast <AbstractClipItem *>(items.at(0));
emit clipItemSelected((ClipItem*) m_dragItem, false);
}
+ m_document->renderer()->doRefresh();
event->setDropAction(Qt::MoveAction);
event->accept();
scene()->addItem(m_selectionGroup);
for (int i = 0; i < selection.count(); i++) {
if ((!selection.at(i)->parentItem()) && (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET)) {
- m_selectionGroup->addToGroup(selection.at(i));
- selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(selection.at(i));
}
}
// Move graphic items
scene()->addItem(m_selectionGroup);
for (int i = 0; i < selection.count(); i++) {
if ((!selection.at(i)->parentItem()) && (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET)) {
- m_selectionGroup->addToGroup(selection.at(i));
- selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(selection.at(i));
}
}
// Move graphic items
clip = getClipItemAtStart(clipsToMove.at(i).startPos + offset, clipsToMove.at(i).track);
if (clip) {
if (clip->parentItem()) {
- m_selectionGroup->addToGroup(clip->parentItem());
- clip->parentItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(clip->parentItem());
} else {
- m_selectionGroup->addToGroup(clip);
- clip->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(clip);
}
if (trackClipStartList.value(m_document->tracksCount() - clipsToMove.at(i).track) == -1 || clipsToMove.at(i).startPos.frames(m_document->fps()) < trackClipStartList.value(m_document->tracksCount() - clipsToMove.at(i).track))
trackClipStartList[m_document->tracksCount() - clipsToMove.at(i).track] = clipsToMove.at(i).startPos.frames(m_document->fps());
transition = getTransitionItemAtStart(transToMove.at(i).startPos + offset, transToMove.at(i).track);
if (transition) {
if (transition->parentItem()) {
- m_selectionGroup->addToGroup(transition->parentItem());
- transition->parentItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(transition->parentItem());
} else {
- m_selectionGroup->addToGroup(transition);
- transition->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(transition);
}
if (trackTransitionStartList.value(m_document->tracksCount() - transToMove.at(i).track) == -1 || transToMove.at(i).startPos.frames(m_document->fps()) < trackTransitionStartList.value(m_document->tracksCount() - transToMove.at(i).track))
trackTransitionStartList[m_document->tracksCount() - transToMove.at(i).track] = transToMove.at(i).startPos.frames(m_document->fps());
void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
{
if (m_moveOpMode == SEEK) m_moveOpMode = NONE;
- if (!m_controlModifier) QGraphicsView::mouseReleaseEvent(event);
- setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
-#if QT_VERSION >= 0x040600
- if (m_dragItem) m_dragItem->setGraphicsEffect(NULL);
+ if (!m_controlModifier && m_operationMode != RUBBERSELECTION) {
+ //event->accept();
+ if (m_clipDrag) QGraphicsView::mouseReleaseEvent(event);
+ }
+ m_clipDrag = false;
+ //setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
+#if QT_VERSION >= 0x040800
+ if (m_dragItem) {
+ m_dragItem->setGraphicsEffect(NULL);
+ }
#endif
if (m_scrollTimer.isActive()) m_scrollTimer.stop();
if (event->button() == Qt::MidButton) {
return;
}
- setDragMode(QGraphicsView::NoDrag);
+
if (m_operationMode == MOVEGUIDE) {
setCursor(Qt::ArrowCursor);
m_operationMode = NONE;
updateTrackDuration(track, command);
m_commandStack->push(command);
if (track != -1) track = m_document->tracksCount() - track;
- kDebug() << "SPACER TRACK:" << track;
m_document->renderer()->mltInsertSpace(trackClipStartList, trackTransitionStartList, track, timeOffset, GenTime());
setDocumentModified();
}
}
- for (int i = 0; i < groups.count(); i++)
+ resetSelectionGroup();
+ for (int i = 0; i < groups.count(); i++) {
rebuildGroup(groups.at(i));
+ }
- resetSelectionGroup();
clearSelection();
m_operationMode = NONE;
} else if (m_operationMode == RUBBERSELECTION) {
+ //event->accept();
+ QGraphicsView::mouseReleaseEvent(event);
+ setDragMode(QGraphicsView::NoDrag);
+ setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
+ if (event->modifiers() != Qt::ControlModifier) m_dragItem = NULL;
resetSelectionGroup();
groupSelectedItems();
m_operationMode = NONE;
// Moving several clips. We need to delete them and readd them to new position,
// or they might overlap each other during the move
QGraphicsItemGroup *group;
- if (m_selectionGroup)
+ if (m_selectionGroup) {
group = static_cast <QGraphicsItemGroup *>(m_selectionGroup);
- else
+ }
+ else {
group = static_cast <QGraphicsItemGroup *>(m_dragItem->parentItem());
+ }
QList<QGraphicsItem *> items = group->childItems();
QList<ItemInfo> clipsToMove;
QList<ItemInfo> transitionsToMove;
if (m_selectionGroup) {
m_selectionGroupInfo.startPos = GenTime(m_selectionGroup->scenePos().x(), m_document->fps());
m_selectionGroupInfo.track = m_selectionGroup->track();
-
- QList <AbstractGroupItem*> groupList;
- for (int i = 0; i < items.count(); ++i) {
- if (items.at(i)->type() == GROUPWIDGET) {
- AbstractGroupItem* group = (AbstractGroupItem*)items.at(i);
- if (!groupList.contains(group)) groupList.append(group);
- items.removeAt(i);
- --i;
+ items = m_selectionGroup->childItems();
+ resetSelectionGroup(false);
+
+ QSet <QGraphicsItem*> groupList;
+ QSet <QGraphicsItem*> itemList;
+ while (!items.isEmpty()) {
+ QGraphicsItem *first = items.takeFirst();
+ if (first->type() == GROUPWIDGET) {
+ if (first != m_selectionGroup) {
+ groupList.insert(first);
+ }
}
- }
- for (int i = 0; i < groupList.count(); ++i) {
- rebuildGroup(groupList.at(i));
+ else if (first->type() == AVWIDGET || first->type() == TRANSITIONWIDGET) {
+ if (first->parentItem() && first->parentItem()->type() == GROUPWIDGET) {
+ if (first->parentItem() != m_selectionGroup) {
+ groupList.insert(first->parentItem());
+ }
+ else itemList.insert(first);
+ }
+ else itemList.insert(first);
+ }
}
-
- for (int i = 0; i < items.count(); ++i) {
- if (items.at(i)) {
- items.at(i)->setSelected(true);
- if (items.at(i)->parentItem())
- items.at(i)->parentItem()->setSelected(true);
- }
+ foreach(QGraphicsItem *item, groupList) {
+ itemList.unite(item->childItems().toSet());
+ rebuildGroup(static_cast <AbstractGroupItem*>(item));
+ }
+
+ foreach(QGraphicsItem *item, itemList) {
+ item->setSelected(true);
+ if (item->parentItem())
+ item->parentItem()->setSelected(true);
}
resetSelectionGroup();
- groupSelectedItems();
+ groupSelectedItems(itemList.toList());
} else {
- rebuildGroup((AbstractGroupItem *)group);
+ AbstractGroupItem *grp = static_cast <AbstractGroupItem *>(group);
+ rebuildGroup(grp);
}
setDocumentModified();
}
setDocumentModified();
return;
}
-
- QList <QGraphicsItemGroup *> groups;
+ QList <QGraphicsItem *>list;
for (int i = 0; i < clipInfos.count(); i++) {
ClipItem *clip = getClipItemAt(clipInfos.at(i).startPos, clipInfos.at(i).track);
if (clip) {
- clip->setSelected(true);
+ list.append(clip);
+ //clip->setSelected(true);
}
}
for (int i = 0; i < transitionInfos.count(); i++) {
Transition *clip = getTransitionItemAt(transitionInfos.at(i).startPos, transitionInfos.at(i).track);
if (clip) {
- clip->setSelected(true);
+ list.append(clip);
+ //clip->setSelected(true);
}
}
- groupSelectedItems(false, true);
+ groupSelectedItems(list, false, true);
setDocumentModified();
}
if (clip) {
clip->setItemLocked(false);
if (clip->parentItem()) {
- m_selectionGroup->addToGroup(clip->parentItem());
- clip->parentItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(clip->parentItem());
} else {
- m_selectionGroup->addToGroup(clip);
- clip->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(clip);
}
m_document->renderer()->mltRemoveClip(m_document->tracksCount() - startClip.at(i).track, startClip.at(i).startPos);
} else kDebug() << "//MISSING CLIP AT: " << startClip.at(i).startPos.frames(25);
if (tr) {
tr->setItemLocked(false);
if (tr->parentItem()) {
- m_selectionGroup->addToGroup(tr->parentItem());
- tr->parentItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(tr->parentItem());
} else {
- m_selectionGroup->addToGroup(tr);
- tr->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(tr);
}
m_document->renderer()->mltDeleteTransition(tr->transitionTag(), tr->transitionEndTrack(), m_document->tracksCount() - startTransition.at(i).track, startTransition.at(i).startPos, startTransition.at(i).endPos, tr->toXML());
} else kDebug() << "//MISSING TRANSITION AT: " << startTransition.at(i).startPos.frames(25);
}
resetSelectionGroup(false);
- for (int i = 0; i < groupList.count(); i++)
+ for (int i = 0; i < groupList.count(); i++) {
rebuildGroup(groupList.at(i));
+ }
clearSelection();
for (int i = 0; i < groups.count(); i++) {
QDomNodeList children = groups.at(i).childNodes();
scene()->clearSelection();
+ QList <QGraphicsItem*>list;
for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
QDomElement elem = children.item(nodeindex).toElement();
int pos = elem.attribute("position").toInt();
int track = elem.attribute("track").toInt();
if (elem.tagName() == "clipitem") {
ClipItem *clip = getClipItemAt(pos, track); //m_document->tracksCount() - transitiontrack);
- if (clip) clip->setSelected(true);
+ if (clip) list.append(clip);//clip->setSelected(true);
} else {
Transition *clip = getTransitionItemAt(pos, track); //m_document->tracksCount() - transitiontrack);
- if (clip) clip->setSelected(true);
+ if (clip) list.append(clip);//clip->setSelected(true);
}
}
- groupSelectedItems(false, true);
+ groupSelectedItems(list, false, true);
}
}
}
}
}
- kDebug() << "GOT TRK: " << track;
if (freetrack == 0) {
emit displayMessage(i18n("No empty space to put clip audio"), ErrorMessage);
} else {
ItemInfo info = clip->info();
info.track = m_document->tracksCount() - freetrack;
- addClip(clip->xml(), clip->clipProducer(), info, clip->effectList());
- scene()->clearSelection();
+ QDomElement xml = clip->xml();
+ xml.setAttribute("audio_only", 1);
+ scene()->clearSelection();
+ addClip(xml, clip->clipProducer(), info, clip->effectList(), false, false, false);
clip->setSelected(true);
ClipItem *audioClip = getClipItemAt(start, info.track);
if (audioClip) {
+ clip->setVideoOnly(true);
Mlt::Tractor *tractor = m_document->renderer()->lockService();
- clip->setVideoOnly(true);
if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->videoProducer(info.track)) == false) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage);
}
- if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - info.track, start, clip->baseClip()->audioProducer(info.track)) == false) {
- emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, info.track), ErrorMessage);
- }
m_document->renderer()->unlockService(tractor);
audioClip->setSelected(true);
- audioClip->setAudioOnly(true);
// keep video effects, move audio effects to audio clip
int videoIx = 0;
videoIx++;
}
}
-
- groupSelectedItems(false, true);
+ groupSelectedItems(QList <QGraphicsItem*>()<<clip<<audioClip, false, true);
}
}
} else {
m_scene->addItem(grp);
scene()->destroyItemGroup(grp);
scene()->clearSelection();
- for (int j = 0; j < children.count(); j++) {
+ /*for (int j = 0; j < children.count(); j++) {
if (children.at(j)->type() == AVWIDGET || children.at(j)->type() == TRANSITIONWIDGET) {
//children.at(j)->setParentItem(0);
children.at(j)->setSelected(true);
}
- }
- groupSelectedItems(true, true);
+ }*/
+ groupSelectedItems(children, true, true);
} else if (itemList.at(i)->type() == GUIDEITEM) {
Guide *g = static_cast<Guide *>(itemList.at(i));
g->updatePos();
QRectF rect(0, m_selectedTrack * m_tracksHeight + m_tracksHeight / 2, sceneRect().width(), m_tracksHeight / 2 - 1);
QList<QGraphicsItem *> selection = m_scene->items(rect);
m_scene->clearSelection();
+ QList<QGraphicsItem *> list;
for (int i = 0; i < selection.count(); i++) {
if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET) {
- selection.at(i)->setSelected(true);
+ list.append(selection.at(i));
}
}
resetSelectionGroup();
- groupSelectedItems();
+ groupSelectedItems(list);
}
void CustomTrackView::slotSelectAllClips()
{
QList<QGraphicsItem *> selection = m_scene->items();
m_scene->clearSelection();
- for (int i = 0; i < selection.count(); i++) {
- if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET) {
- selection.at(i)->setSelected(true);
- }
- }
resetSelectionGroup();
- groupSelectedItems();
+ groupSelectedItems(selection);
}
void CustomTrackView::selectClip(bool add, bool group, int track, int pos)