4 #include <QAbstractTableModel>
14 int64_t pts_in = -1, pts_out = -1; // pts_in is inclusive, pts_out is exclusive.
15 std::string descriptions[NUM_CAMERAS];
16 unsigned stream_idx = 0; // For the playlist only.
19 class DataChangedReceiver {
21 virtual void emit_data_changed(size_t row) = 0;
24 // Like a smart pointer to a Clip, but emits dataChanged when it goes out of scope.
27 ClipProxy(Clip &clip, DataChangedReceiver *clip_list, size_t row)
28 : clip(clip), clip_list(clip_list), row(row) {}
30 if (clip_list != nullptr) {
31 clip_list->emit_data_changed(row);
34 Clip *operator->() { return &clip; }
35 Clip &operator*() { return clip; }
39 DataChangedReceiver *clip_list;
43 class ClipList : public QAbstractTableModel, public DataChangedReceiver {
60 int rowCount(const QModelIndex &parent) const override;
61 int columnCount(const QModelIndex &parent) const override;
62 QVariant data(const QModelIndex &parent, int role) const override;
63 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
64 Qt::ItemFlags flags(const QModelIndex &index) const override;
65 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
67 void add_clip(const Clip &clip);
68 size_t size() const { return clips.size(); }
69 bool empty() const { return clips.empty(); }
71 ClipProxy clip(size_t index) { return ClipProxy(clips[index], this, index); }
72 const Clip *clip(size_t index) const { return &clips[index]; }
74 ClipProxy back() { return clip(size() - 1); }
75 const Clip *back() const { return clip(size() - 1); }
77 void emit_data_changed(size_t row) override;
80 std::vector<Clip> clips;
83 class PlayList : public QAbstractTableModel, public DataChangedReceiver {
99 int rowCount(const QModelIndex &parent) const override;
100 int columnCount(const QModelIndex &parent) const override;
101 QVariant data(const QModelIndex &parent, int role) const override;
102 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
103 Qt::ItemFlags flags(const QModelIndex &index) const override;
104 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
106 void add_clip(const Clip &clip);
108 // <last> is inclusive in all of these.
109 void duplicate_clips(size_t first, size_t last);
110 void erase_clips(size_t first, size_t last);
111 // <delta> is -1 to move upwards, +1 to move downwards.
112 void move_clips(size_t first, size_t last, int delta);
114 size_t size() const { return clips.size(); }
115 bool empty() const { return clips.empty(); }
117 ClipProxy clip(size_t index) { return ClipProxy(clips[index], this, index); }
118 const Clip *clip(size_t index) const { return &clips[index]; }
120 ClipProxy back() { return clip(size() - 1); }
121 const Clip *back() const { return clip(size() - 1); }
123 void set_currently_playing(int index); // -1 = none.
124 int get_currently_playing() const { return currently_playing_index; }
126 void emit_data_changed(size_t row) override;
129 std::vector<Clip> clips;
130 int currently_playing_index = -1;
133 #endif // !defined (_CLIP_LIST_H)