+void CustomTrackView::slotInsertTrack(int ix) {
+ kDebug() << "// INSERTING TRK: " << ix;
+ QDialog d(parentWidget());
+ Ui::AddTrack_UI view;
+ view.setupUi(&d);
+ view.track_nb->setMaximum(m_scene->m_tracksList.count() - 1);
+ view.track_nb->setValue(ix);
+
+ if (d.exec() == QDialog::Accepted) {
+ if (view.before_select->currentIndex() == 2) {
+ kDebug() << "// AFTER";
+ ix++;
+ }
+ TrackInfo info;
+ if (view.video_track->isChecked()) {
+ info.type = VIDEOTRACK;
+ info.isMute = false;
+ info.isBlind = false;
+ } else {
+ info.type = AUDIOTRACK;
+ info.isMute = false;
+ info.isBlind = false;
+ }
+ addTimelineTrack(ix, info);
+ m_document->setModified(true);
+ /*AddTrackCommand* command = new AddTrackCommand(this, ix, info, true, true);
+ m_commandStack->push(command);*/
+ }
+}
+
+void CustomTrackView::slotDeleteTrack(int ix) {
+ bool ok;
+ ix = QInputDialog::getInteger(this, i18n("Remove Track"), i18n("Track"), ix, 0, m_scene->m_tracksList.count() - 1, 1, &ok);
+ if (ok) {
+ TrackInfo info = m_scene->m_tracksList.at(m_scene->m_tracksList.count() - ix - 1);
+ deleteTimelineTrack(ix, info);
+ m_document->setModified(true);
+ /*AddTrackCommand* command = new AddTrackCommand(this, ix, info, false, true);
+ m_commandStack->push(command);*/
+ }
+}
+
+void CustomTrackView::addTimelineTrack(int ix, TrackInfo trackinfo) {
+ double startY = ix * m_tracksHeight + 1 + m_tracksHeight / 2;
+ QRectF r(0, startY, sceneRect().width(), sceneRect().height() - startY);
+ QList<QGraphicsItem *> selection = m_scene->items(r);
+ kDebug() << "// TRK RECT: " << r << ", ITEMS: " << selection.count();
+ QUndoCommand *addTrack = new QUndoCommand();
+ addTrack->setText("Add track");
+ new AddTrackCommand(this, ix, trackinfo, true, true, addTrack);
+
+ m_commandStack->push(addTrack);
+ kDebug() << "// ADD TRCKL DONE...";
+ update();
+}
+
+void CustomTrackView::deleteTimelineTrack(int ix, TrackInfo trackinfo) {
+ double startY = ix * m_tracksHeight + 1 + m_tracksHeight / 2;
+ QRectF r(0, startY, sceneRect().width(), m_tracksHeight / 2 - 1);
+ QList<QGraphicsItem *> selection = m_scene->items(r);
+ QUndoCommand *deleteTrack = new QUndoCommand();
+ deleteTrack->setText("Delete track");
+
+ // Delete all clips in selected track
+ for (int i = 0; i < selection.count(); i++) {
+ if (selection.at(i)->type() == AVWIDGET) {
+ ClipItem *item = static_cast <ClipItem *>(selection.at(i));
+ new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), false, true, deleteTrack);
+ m_scene->removeItem(item);
+ delete item;
+ item = NULL;
+ } else if (selection.at(i)->type() == TRANSITIONWIDGET) {
+ Transition *item = static_cast <Transition *>(selection.at(i));
+ new AddTransitionCommand(this, item->info(), item->transitionEndTrack(), item->toXML(), true, false, deleteTrack);
+ m_scene->removeItem(item);
+ delete item;
+ item = NULL;
+ }
+ }
+
+ new AddTrackCommand(this, ix, trackinfo, false, true, deleteTrack);
+ m_commandStack->push(deleteTrack);
+ //removeTrack(ix, trackinfo);
+ kDebug() << "// REM TRK DONE...";
+ update();
+}
+