while (!m_dragGuide && ct < collisionList.count()) {
if (collisionList.at(ct)->type() == AVWIDGET || collisionList.at(ct)->type() == TRANSITIONWIDGET) {
collisionClip = static_cast <AbstractClipItem *>(collisionList.at(ct));
- if (collisionClip->isItemLocked())
- break;
+ if (collisionClip->isItemLocked() || !collisionClip->isEnabled()) {
+ ct++;
+ continue;
+ }
if (collisionClip == m_dragItem) {
collisionClip = NULL;
}
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) emit clipItemSelected(NULL);
m_dragItem = NULL;
}
+
#if QT_VERSION >= 0x040800
// Add shadow to dragged item, currently disabled because of painting artifacts
/*if (m_dragItem) {
m_dragItem->setGraphicsEffect(eff);
}*/
#endif
- if (m_dragItem && m_dragItem->type() == TRANSITIONWIDGET) {
+ if (m_dragItem && m_dragItem->type() == TRANSITIONWIDGET && m_dragItem->isEnabled()) {
// update transition menu action
m_autoTransition->setChecked(static_cast<Transition *>(m_dragItem)->isAutomatic());
m_autoTransition->setEnabled(true);
- } else m_autoTransition->setEnabled(false);
-
+ // A transition is selected
+ QPoint p;
+ ClipItem *transitionClip = getClipItemAt(m_dragItemInfo.startPos, m_dragItemInfo.track);
+ if (transitionClip && transitionClip->baseClip()) {
+ QString size = transitionClip->baseClip()->getProperty("frame_size");
+ double factor = transitionClip->baseClip()->getProperty("aspect_ratio").toDouble();
+ if (factor == 0) factor = 1.0;
+ p.setX((int)(size.section('x', 0, 0).toInt() * factor + 0.5));
+ p.setY(size.section('x', 1, 1).toInt());
+ }
+ emit transitionItemSelected(static_cast <Transition *>(m_dragItem), getPreviousVideoTrack(m_dragItem->track()), p);
+ } else {
+ emit transitionItemSelected(NULL);
+ m_autoTransition->setEnabled(false);
+ }
// context menu requested
if (event->button() == Qt::RightButton) {
if (!m_dragItem && !m_dragGuide) {
if (selected == false) {
m_dragItem = NULL;
}
- groupSelectedItems(QList <QGraphicsItem*>(), false, false, true);
+ groupSelectedItems(QList <QGraphicsItem*>(), false, true);
if (m_dragItem) {
ClipItem *clip = static_cast <ClipItem *>(m_dragItem);
updateClipTypeActions(dragGroup == NULL ? clip : NULL);
resetSelectionGroup(false);
m_dragItem->setSelected(true);
}
-
m_blockRefresh = false;
}
group->removeFromGroup(children.at(i));
}*/
scene()->destroyItemGroup(group);
- groupSelectedItems(children, false, true, true);
+ groupSelectedItems(children, true, true);
}
}
}
}
-void CustomTrackView::groupSelectedItems(QList <QGraphicsItem *> selection, bool force, bool createNewGroup, bool selectNewGroup)
+void CustomTrackView::groupSelectedItems(QList <QGraphicsItem *> selection, bool createNewGroup, bool selectNewGroup)
{
if (m_selectionGroup) {
kDebug() << "///// ERROR, TRYING TO OVERRIDE EXISTING GROUP";
}
}
if (itemsList.isEmpty() && groupsList.isEmpty()) return;
- if (itemsList.count() == 1) {
+ if (itemsList.count() == 1 && groupsList.isEmpty()) {
// only one item selected:
QSetIterator<QGraphicsItem *> it(itemsList);
m_dragItem = static_cast<AbstractClipItem *>(it.next());
m_dragItem->setSelected(true);
- emit clipItemSelected(static_cast<ClipItem *>(m_dragItem));
+ return;
}
-
+
QRectF rectUnion;
// Find top left position of selection
foreach (const QGraphicsItemGroup *value, groupsList) {
foreach (const QGraphicsItem *value, itemsList) {
rectUnion = rectUnion.united(value->sceneBoundingRect());
}
- if (force || selection.count() > 1) {
- bool snap = KdenliveSettings::snaptopoints();
- KdenliveSettings::setSnaptopoints(false);
- if (createNewGroup) {
- AbstractGroupItem *newGroup = m_document->clipManager()->createGroup();
- newGroup->setPos(rectUnion.left(), rectUnion.top() - 1);
- QPointF diff = newGroup->pos();
- newGroup->translate(-diff.x(), -diff.y());
- //newGroup->translate((int) -rectUnion.left(), (int) -rectUnion.top() + 1);
-
- scene()->addItem(newGroup);
- // Check if we are trying to include a group in a group
- 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);
+ bool snap = KdenliveSettings::snaptopoints();
+ KdenliveSettings::setSnaptopoints(false);
+ if (createNewGroup) {
+ AbstractGroupItem *newGroup = m_document->clipManager()->createGroup();
+ newGroup->setPos(rectUnion.left(), rectUnion.top() - 1);
+ QPointF diff = newGroup->pos();
+ newGroup->translate(-diff.x(), -diff.y());
+ //newGroup->translate((int) -rectUnion.left(), (int) -rectUnion.top() + 1);
+
+ scene()->addItem(newGroup);
+ // Check if we are trying to include a group in a group
+ 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);
+ }
- 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);
- QPointF diff = m_selectionGroup->pos();
- //m_selectionGroup->translate((int) - rectUnion.left(), (int) -rectUnion.top() + 1);
- m_selectionGroup->translate(- diff.x(), -diff.y());
+ 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);
+ QPointF diff = m_selectionGroup->pos();
+ //m_selectionGroup->translate((int) - rectUnion.left(), (int) -rectUnion.top() + 1);
+ m_selectionGroup->translate(- diff.x(), -diff.y());
- scene()->addItem(m_selectionGroup);
- 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);
- }
+ scene()->addItem(m_selectionGroup);
+ 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();
+ }
}
void CustomTrackView::mouseDoubleClickEvent(QMouseEvent *event)
m_pasteEffectsAction->setEnabled(m_copiedItems.count() == 1);
if (items.count() > 1) {
- groupSelectedItems(items, true);
+ groupSelectedItems(items);
} else if (items.count() == 1) {
m_dragItem = static_cast <AbstractClipItem *>(items.at(0));
emit clipItemSelected((ClipItem*) m_dragItem, false);
resetSelectionGroup();
QList<QGraphicsItem *> itemList = items();
QUndoCommand *deleteCommand = new QUndoCommand();
+ new RefreshMonitorCommand(this, false, true, deleteCommand);
int count = 0;
for (int i = 0; i < itemList.count(); i++) {
if (itemList.at(i)->type() == AVWIDGET) {
ClipItem *item = (ClipItem *)itemList.at(i);
if (item->clipProducer() == clipId) {
- count++;
+ count++;
if (item->parentItem()) {
- // Clip is in a group, destroy the group
- new GroupClipsCommand(this, QList<ItemInfo>() << item->info(), QList<ItemInfo>(), false, deleteCommand);
+ // Clip is in a group, destroy the group
+ new GroupClipsCommand(this, QList<ItemInfo>() << item->info(), QList<ItemInfo>(), false, deleteCommand);
}
new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), false, false, true, true, deleteCommand);
}
}
}
- deleteCommand->setText(i18np("Delete timeline clip", "Delete timeline clips", count));
if (count == 0) {
delete deleteCommand;
} else {
+ deleteCommand->setText(i18np("Delete timeline clip", "Delete timeline clips", count));
+ new RefreshMonitorCommand(this, true, false, deleteCommand);
updateTrackDuration(-1, deleteCommand);
- new RefreshMonitorCommand(this, false, deleteCommand);
m_commandStack->push(deleteCommand);
}
- m_document->renderer()->doRefresh();
}
void CustomTrackView::seekCursorPos(int pos)
resetSelectionGroup();
groupSelectedItems();
m_operationMode = NONE;
+ if (m_selectionGroup == NULL && m_dragItem) {
+ // Only 1 item selected
+ if (m_dragItem->type() == AVWIDGET)
+ emit clipItemSelected(static_cast<ClipItem *>(m_dragItem));
+ }
}
if (m_dragItem == NULL && m_selectionGroup == NULL) {
updateEffect(m_document->tracksCount() - item->track(), item->startPos(), item->selectedEffect());
emit clipItemSelected(item);
}
- if (m_dragItem && m_dragItem->type() == TRANSITIONWIDGET && m_dragItem->isSelected()) {
- // A transition is selected
- QPoint p;
- ClipItem *transitionClip = getClipItemAt(m_dragItemInfo.startPos, m_dragItemInfo.track);
- if (transitionClip && transitionClip->baseClip()) {
- QString size = transitionClip->baseClip()->getProperty("frame_size");
- double factor = transitionClip->baseClip()->getProperty("aspect_ratio").toDouble();
- if (factor == 0) factor = 1.0;
- p.setX((int)(size.section('x', 0, 0).toInt() * factor + 0.5));
- p.setY(size.section('x', 1, 1).toInt());
- }
- emit transitionItemSelected(static_cast <Transition *>(m_dragItem), getPreviousVideoTrack(m_dragItem->track()), p);
- } else emit transitionItemSelected(NULL);
if (m_operationMode != NONE && m_operationMode != MOVE) setDocumentModified();
m_operationMode = NONE;
}
}
scene()->clearSelection();
QUndoCommand *deleteSelected = new QUndoCommand();
+ new RefreshMonitorCommand(this, false, true, deleteSelected);
int groupCount = 0;
int clipCount = 0;
deleteSelected->setText(i18np("Delete selected transition", "Delete selected transitions", transitionCount));
else deleteSelected->setText(i18n("Delete selected items"));
updateTrackDuration(-1, deleteSelected);
- new RefreshMonitorCommand(this, false, deleteSelected);
+ new RefreshMonitorCommand(this, true, false, deleteSelected);
m_commandStack->push(deleteSelected);
- m_document->renderer()->doRefresh();
}
//clip->setSelected(true);
}
}
- groupSelectedItems(list, false, true, true);
+ groupSelectedItems(list, true, true);
setDocumentModified();
}
m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(item->effect(i)), false);
}
setDocumentModified();
- if (refresh)
+ if (refresh) {
m_document->renderer()->doRefresh();
+ }
if (!baseclip->isPlaceHolder())
m_waitingThumbs.append(item);
m_thumbsTimer.start();
}
QUndoCommand *pasteClips = new QUndoCommand();
pasteClips->setText("Paste clips");
+ new RefreshMonitorCommand(this, false, true, pasteClips);
for (int i = 0; i < m_copiedItems.count(); i++) {
// parse all clip names
}
}
updateTrackDuration(-1, pasteClips);
- new RefreshMonitorCommand(this, false, pasteClips);
+ new RefreshMonitorCommand(this, false, false, pasteClips);
m_commandStack->push(pasteClips);
}
if (clip) list.append(clip);//clip->setSelected(true);
}
}
- groupSelectedItems(list, false, true);
+ groupSelectedItems(list, true);
}
}
videoIx++;
}
}
- groupSelectedItems(QList <QGraphicsItem*>()<<clip<<audioClip, false, true);
+ groupSelectedItems(QList <QGraphicsItem*>()<<clip<<audioClip, true);
}
}
} else {
children.at(j)->setSelected(true);
}
}*/
- groupSelectedItems(children, true, true);
+ groupSelectedItems(children, true);
} else if (itemList.at(i)->type() == GUIDEITEM) {
Guide *g = static_cast<Guide *>(itemList.at(i));
g->updatePos();
list.append(selection.at(i));
}
}
- groupSelectedItems(list, false, false, true);
+ groupSelectedItems(list, false, true);
}
void CustomTrackView::slotSelectAllClips()
{
m_scene->clearSelection();
resetSelectionGroup();
- groupSelectedItems(m_scene->items(), false, false, true);
+ groupSelectedItems(m_scene->items(), false, true);
}
void CustomTrackView::selectClip(bool add, bool group, int track, int pos)