X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=clip_list.cpp;h=14f083e91268984c043ac652cd74ff19b39cccc9;hb=3795723be95f2fe82f3c8b8b45b1a905b2c811fd;hp=5ee36df1cc432a50b5be00c152c9ea4274aed61d;hpb=fba9223dd99865e3cb90dc353f928ac3da3ac81e;p=nageru diff --git a/clip_list.cpp b/clip_list.cpp index 5ee36df..14f083e 100644 --- a/clip_list.cpp +++ b/clip_list.cpp @@ -142,7 +142,10 @@ QVariant PlayList::data(const QModelIndex &parent, int role) const } if (role == Qt::BackgroundRole) { if (Column(column) == Column::PLAYING) { - if (row == currently_playing_index) { + auto it = current_progress.find(row); + if (it != current_progress.end()) { + double play_progress = it->second; + // This only really works well for the first column, for whatever odd Qt reason. QLinearGradient grad(QPointF(0, 0), QPointF(1, 0)); grad.setCoordinateMode(grad.QGradient::ObjectBoundingMode); @@ -165,7 +168,7 @@ QVariant PlayList::data(const QModelIndex &parent, int role) const switch (Column(column)) { case Column::PLAYING: - return (row == currently_playing_index) ? "→" : ""; + return current_progress.count(row) ? "→" : ""; case Column::IN: return QString::fromStdString(pts_to_string(clips[row].pts_in)); case Column::OUT: @@ -431,6 +434,24 @@ void PlayList::set_currently_playing(int index, double progress) } } +void PlayList::set_progress(const map &progress) +{ + const int column = int(Column::PLAYING); + map old_progress = move(this->current_progress); + this->current_progress = progress; + + for (auto it : old_progress) { + size_t index = it.first; + if (current_progress.count(index) == 0) { + emit dataChanged(this->index(index, column), this->index(index, column)); + } + } + for (auto it : current_progress) { + size_t index = it.first; + emit dataChanged(this->index(index, column), this->index(index, column)); + } +} + namespace { Clip deserialize_clip(const ClipProto &clip_proto)