m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight - 1);
setSceneRect(0, 0, sceneRect().width(), m_tracksHeight * m_document->tracksCount());
viewport()->update();
- emit tracksChanged();
//QTimer::singleShot(500, this, SIGNAL(trackHeightChanged()));
//setFixedHeight(50 * m_tracksCount);
+
+ updateTrackNames(ix, true);
}
void CustomTrackView::removeTrack(int ix)
m_selectedTrack = qMin(m_selectedTrack, m_document->tracksCount() - 1);
viewport()->update();
- emit tracksChanged();
+
+ updateTrackNames(ix, false);
//QTimer::singleShot(500, this, SIGNAL(trackHeightChanged()));
}
if (effects.count() > 0)
emit clipItemSelected(item, item->selectedEffectIndex());
}
+
+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();
+}
+
* @param cutPos (optional) if clip was cut, cut position relative to the original's clip position */
void updatePanZoom(ClipItem *item, GenTime cutPos = GenTime());
+ /** @brief Update Tracknames to fit again after track was added/deleted.
+ * @param track Number of track which was added/deleted
+ * @param added true = track added, false = track deleted
+ *
+ * The default track name consists of type + number. If we add/delete a track the number has to be adjusted
+ * if the name is still the default one. */
+ void updateTrackNames(int track, bool added);
+
private slots:
void slotRefreshGuides();
void slotEnableRefresh();