+
+void CustomTrackView::updateTrackNames(int track, bool added)
+{
+ QList <TrackInfo> tracks = m_document->tracksList();
+ int max = tracks.count();
+ int docTrack = max - track - 1;
+
+ // count number of tracks of each type
+ int videoTracks = 0;
+ int audioTracks = 0;
+ for (int i = max - 1; i >= 0; --i) {
+ TrackInfo info = tracks.at(i);
+ if (info.type == VIDEOTRACK)
+ videoTracks++;
+ else
+ audioTracks++;
+
+ if (i <= docTrack) {
+ QString type = (info.type == VIDEOTRACK ? "Video " : "Audio ");
+ int typeNumber = (info.type == VIDEOTRACK ? videoTracks : audioTracks);
+
+ if (added) {
+ if (i == docTrack || info.trackName == type + QString::number(typeNumber - 1)) {
+ info.trackName = type + QString::number(typeNumber);
+ m_document->setTrackType(i, info);
+ }
+ } else {
+ if (info.trackName == type + QString::number(typeNumber + 1)) {
+ info.trackName = type + QString::number(typeNumber);
+ m_document->setTrackType(i, info);
+ }
+ }
+ }
+ }
+ emit tracksChanged();
+}
+
+void CustomTrackView::updateTrackDuration(int track, QUndoCommand *command)
+{
+ Q_UNUSED(command)
+
+ QList<int> tracks;
+ if (track >= 0) {
+ tracks << m_document->tracksCount() - track - 1;
+ } else {
+ // negative track number -> update all tracks
+ for (int i = 0; i < m_document->tracksCount(); ++i)
+ tracks << i;
+ }
+ int t, duration;
+ for (int i = 0; i < tracks.count(); ++i) {
+ t = tracks.at(i);
+ // t + 1 because of black background track
+ duration = m_document->renderer()->mltTrackDuration(t + 1);
+ if (duration != m_document->trackDuration(t)) {
+ m_document->setTrackDuration(t, duration);
+
+ // update effects
+ EffectsList effects = m_document->getTrackEffects(t);
+ for (int j = 0; j < effects.count(); ++j) {
+ /* TODO
+ * - lookout for keyframable parameters and update them so all keyframes are in the new range (0 - duration)
+ * - update the effectstack if necessary
+ */
+ }
+ }
+ }
+}
+
+void CustomTrackView::slotRefreshThumbs(const QString &id, bool resetThumbs)
+{
+ QList<QGraphicsItem *> list = scene()->items();
+ ClipItem *clip = NULL;
+ for (int i = 0; i < list.size(); ++i) {
+ if (list.at(i)->type() == AVWIDGET) {
+ clip = static_cast <ClipItem *>(list.at(i));
+ if (clip->clipProducer() == id) {
+ clip->refreshClip(true, resetThumbs);
+ }
+ }
+ }
+}
+
+void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, QUndoCommand* command)
+{
+ QMap<int, QDomElement> effects = item->adjustEffectsToDuration(m_document->width(), m_document->height(), oldInfo);
+
+ if (effects.count()) {
+ QMap<int, QDomElement>::const_iterator i = effects.constBegin();
+ while (i != effects.constEnd()) {
+ new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), i.value(), item->effectAt(i.key()), i.key(), false, command);
+ ++i;
+ }
+ }
+}
+
+