cleanup qml, fix red track on insert

parent 09a70bb1
......@@ -95,7 +95,7 @@ QModelIndex TimelineItemModel::index(int row, int column, const QModelIndex &par
// Invalid index requested
Q_ASSERT(false);
}
} else if (row < getTracksCount() && row >= 0) {
} else if (row < (int)m_allTracks.size() && row >= 0) {
// Get sort order
// row = getTracksCount() - 1 - row;
auto it = m_allTracks.cbegin();
......@@ -176,7 +176,7 @@ int TimelineItemModel::rowCount(const QModelIndex &parent) const
}
return getTrackClipsCount(id) + getTrackCompositionsCount(id);
}
return getTracksCount();
return (int)m_allTracks.size();
}
int TimelineItemModel::columnCount(const QModelIndex &parent) const
......
......@@ -2474,7 +2474,7 @@ bool TimelineModel::requestTrackInsertion(int position, int &id, const QString &
emit dataChanged(ix, ix, {TimelineModel::TrackTagRole});
}
} else {
for (int i = position; i < getTracksCount(); i++) {
for (int i = position; i < (int)m_allTracks.size(); i++) {
QModelIndex ix = makeTrackIndexFromID(getTrackIndexFromPosition(i));
emit dataChanged(ix, ix, {TimelineModel::TrackTagRole});
}
......@@ -2658,11 +2658,11 @@ void TimelineModel::registerTrack(std::shared_ptr<TrackModel> track, int pos, bo
// we now insert in the list
auto posIt = m_allTracks.begin();
std::advance(posIt, pos);
beginInsertRows(QModelIndex(), pos, pos);
auto it = m_allTracks.insert(posIt, std::move(track));
// it now contains the iterator to the inserted element, we store it
Q_ASSERT(m_iteratorTable.count(id) == 0); // check that id is not used (shouldn't happen)
m_iteratorTable[id] = it;
beginInsertRows(QModelIndex(), pos, pos);
endInsertRows();
int cache = (int)QThread::idealThreadCount() + ((int)m_allTracks.size() + 1) * 2;
mlt_service_cache_set_size(NULL, "producer_avformat", qMax(4, cache));
......
......@@ -1032,7 +1032,7 @@ Rectangle {
border.width: 1
border.color: root.frameColor
height: model.trackHeight
color: tracksRepeater.itemAt(index) ? ((tracksRepeater.itemAt(index).trackInternalId === timeline.activeTrack) ? Qt.tint(getTrackColor(tracksRepeater.itemAt(index).isAudio, false), selectedTrackColor) : getTrackColor(tracksRepeater.itemAt(index).isAudio, false)) : 'red'
color: (model.item == timeline.activeTrack) ? Qt.tint(getTrackColor(model.audio, false), selectedTrackColor) : getTrackColor(model.audio, false)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment