+ int tracknumber = m_document->tracksCount() - ix;
+ m_document->switchTrackVideo(tracknumber - 1, !m_document->trackInfoAt(tracknumber - 1).isBlind);
+ m_document->renderer()->mltChangeTrackState(tracknumber, m_document->trackInfoAt(tracknumber - 1).isMute, m_document->trackInfoAt(tracknumber - 1).isBlind);
+ m_document->setModified(true);
+}
+
+void CustomTrackView::slotRemoveSpace() {
+ GenTime pos;
+ int track = 0;
+ if (m_menuPosition.isNull()) {
+ pos = GenTime(cursorPos(), m_document->fps());
+ bool ok;
+ track = QInputDialog::getInteger(this, i18n("Remove Space"), i18n("Track"), 0, 0, m_document->tracksCount() - 1, 1, &ok);
+ if (!ok) return;
+ } else {
+ pos = GenTime((int)(mapToScene(m_menuPosition).x()), m_document->fps());
+ track = (int)(mapToScene(m_menuPosition).y() / m_tracksHeight);
+ }
+ ClipItem *item = getClipItemAt(pos, track);
+ if (item) {
+ emit displayMessage(i18n("You must be in an empty space to remove space (time=%1, track:%2)", m_document->timecode().getTimecodeFromFrames(mapToScene(m_menuPosition).x()), track), ErrorMessage);
+ return;
+ }
+ int length = m_document->renderer()->mltGetSpaceLength(pos, m_document->tracksCount() - track);
+ //kDebug() << "// GOT LENGT; " << length;
+ if (length <= 0) {
+ emit displayMessage(i18n("You must be in an empty space to remove space (time=%1, track:%2)", m_document->timecode().getTimecodeFromFrames(mapToScene(m_menuPosition).x()), track), ErrorMessage);
+ return;
+ }
+ InsertSpaceCommand *command = new InsertSpaceCommand(this, pos, track, GenTime(-length, m_document->fps()), true);
+ m_commandStack->push(command);
+}
+
+void CustomTrackView::slotInsertSpace() {
+ GenTime pos;
+ int track = 0;
+ if (m_menuPosition.isNull()) {
+ pos = GenTime(cursorPos(), m_document->fps());
+ } else {
+ pos = GenTime((int)(mapToScene(m_menuPosition).x()), m_document->fps());
+ track = (int)(mapToScene(m_menuPosition).y() / m_tracksHeight) + 1;
+ }
+ SpacerDialog d(GenTime(65, m_document->fps()), m_document->timecode(), track, m_document->tracksCount(), this);
+ if (d.exec() != QDialog::Accepted) return;
+ GenTime spaceDuration = d.selectedDuration();
+ track = d.selectedTrack();
+ ClipItem *item = getClipItemAt(pos, track);
+ if (item) pos = item->startPos();
+
+ InsertSpaceCommand *command = new InsertSpaceCommand(this, pos, track, spaceDuration, true);
+ m_commandStack->push(command);
+}
+
+void CustomTrackView::insertSpace(const GenTime &pos, int track, const GenTime duration, bool add) {
+ int diff = duration.frames(m_document->fps());
+ if (!add) diff = -diff;
+ QList<QGraphicsItem *> itemList;
+ if (track == -1) itemList = scene()->items(pos.frames(m_document->fps()) , 1, sceneRect().width() - pos.frames(m_document->fps()), sceneRect().height());
+ else itemList = scene()->items(pos.frames(m_document->fps()) , track * m_tracksHeight + 1, sceneRect().width() - pos.frames(m_document->fps()), m_tracksHeight - 2);
+ resetSelectionGroup();
+ m_selectionGroup = new AbstractGroupItem(m_document->fps());
+ scene()->addItem(m_selectionGroup);
+ for (int i = 0; i < itemList.count(); i++) {
+ if (itemList.at(i)->type() == AVWIDGET || itemList.at(i)->type() == TRANSITIONWIDGET) {
+ /*AbstractClipItem *item = static_cast <AbstractClipItem *> (itemList.at(i));
+ if (item->endPos() > pos)*/
+ m_selectionGroup->addToGroup(itemList.at(i));
+ //item->moveBy(diff, 0);
+ }
+ }
+ QPointF top = m_selectionGroup->boundingRect().topLeft();
+ const int width = m_selectionGroup->boundingRect().width();
+ const int height = m_selectionGroup->boundingRect().height();
+ m_selectionGroup->setPos(top);
+ m_selectionGroup->translate(-top.x(), -top.y() + 1);
+ m_selectionGroup->moveBy(diff, 0);
+ resetSelectionGroup();
+ if (track != -1) track = m_document->tracksCount() - track;
+ if (!add) m_document->renderer()->mltInsertSpace(pos, track, GenTime() - duration);
+ else m_document->renderer()->mltInsertSpace(pos, track, duration);