X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=clip_list.cpp;h=5602d90e6376f51c265d6e2e95163a07a53153e0;hb=3a2c9e40ad5550a729a754de5df83a0650724415;hp=0d9fc6c66e49c97a35b30e4b44be25ceac667467;hpb=d357bff359e00a9ad8e5a1d7ec70d0653db46398;p=nageru diff --git a/clip_list.cpp b/clip_list.cpp index 0d9fc6c..5602d90 100644 --- a/clip_list.cpp +++ b/clip_list.cpp @@ -32,23 +32,48 @@ QVariant ClipList::data(const QModelIndex &parent, int role) const { if (size_t(row) >= clips.size()) return QVariant(); - switch (column) { - case 0: - return qlonglong(clips[row].pts_in); - case 1: - if (clips[row].pts_out >= 0) { - return qlonglong(clips[row].pts_out); - } else { - return QVariant(); + if (display_type == ListDisplay::CLIP_LIST) { + switch (ClipListColumn(column)) { + case ClipListColumn::IN: + return qlonglong(clips[row].pts_in); + case ClipListColumn::OUT: + if (clips[row].pts_out >= 0) { + return qlonglong(clips[row].pts_out); + } else { + return QVariant(); + } + case ClipListColumn::DURATION: + if (clips[row].pts_out >= 0) { + return qlonglong(clips[row].pts_out - clips[row].pts_in); + } else { + return QVariant(); + } + default: + return ""; } - case 2: - if (clips[row].pts_out >= 0) { - return qlonglong(clips[row].pts_out - clips[row].pts_in); - } else { - return QVariant(); + } else { + switch (PlayListColumn(column)) { + case PlayListColumn::PLAYING: + return (row == currently_playing_index) ? "→" : ""; + case PlayListColumn::IN: + return qlonglong(clips[row].pts_in); + case PlayListColumn::OUT: + if (clips[row].pts_out >= 0) { + return qlonglong(clips[row].pts_out); + } else { + return QVariant(); + } + case PlayListColumn::DURATION: + if (clips[row].pts_out >= 0) { + return qlonglong(clips[row].pts_out - clips[row].pts_in); + } else { + return QVariant(); + } + case PlayListColumn::CAMERA: + return qlonglong(clips[row].stream_idx + 1); + default: + return ""; } - default: - return QVariant(); } } @@ -79,6 +104,8 @@ QVariant ClipList::headerData(int section, Qt::Orientation orientation, int role } } else { switch (PlayListColumn(section)) { + case PlayListColumn::PLAYING: + return ""; case PlayListColumn::IN: return "In"; case PlayListColumn::OUT: @@ -110,3 +137,17 @@ void ClipList::emit_data_changed(size_t row) emit dataChanged(index(row, 0), index(row, int(PlayListColumn::NUM_COLUMNS))); } } + +void ClipList::set_currently_playing(int index) +{ + int old_index = currently_playing_index; + if (index != old_index) { + currently_playing_index = index; + if (old_index != -1) { + emit_data_changed(old_index); + } + if (index != -1) { + emit_data_changed(index); + } + } +}