4 #include <QAbstractTableModel>
15 int64_t pts_in = -1, pts_out = -1; // pts_in is inclusive, pts_out is exclusive.
16 std::string descriptions[NUM_CAMERAS];
17 unsigned stream_idx = 0; // For the playlist only.
18 double fade_time_seconds = 0.5; // For the playlist only.
21 class DataChangedReceiver {
23 virtual void emit_data_changed(size_t row) = 0;
26 // Like a smart pointer to a Clip, but emits dataChanged when it goes out of scope.
29 ClipProxy(Clip &clip, DataChangedReceiver *clip_list, size_t row)
30 : clip(clip), clip_list(clip_list), row(row) {}
32 if (clip_list != nullptr) {
33 clip_list->emit_data_changed(row);
36 Clip *operator->() { return &clip; }
37 Clip &operator*() { return clip; }
41 DataChangedReceiver *clip_list;
45 class ClipList : public QAbstractTableModel, public DataChangedReceiver {
49 explicit ClipList(const ClipListProto &serialized);
62 int rowCount(const QModelIndex &parent) const override;
63 int columnCount(const QModelIndex &parent) const override;
64 QVariant data(const QModelIndex &parent, int role) const override;
65 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
66 Qt::ItemFlags flags(const QModelIndex &index) const override;
67 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
69 void add_clip(const Clip &clip);
70 size_t size() const { return clips.size(); }
71 bool empty() const { return clips.empty(); }
73 ClipProxy mutable_clip(size_t index) { return ClipProxy(clips[index], this, index); }
74 const Clip *clip(size_t index) const { return &clips[index]; }
76 ClipProxy mutable_back() { return mutable_clip(size() - 1); }
77 const Clip *back() const { return clip(size() - 1); }
79 ClipListProto serialize() const;
81 void emit_data_changed(size_t row) override;
84 void any_content_changed();
87 std::vector<Clip> clips;
90 class PlayList : public QAbstractTableModel, public DataChangedReceiver {
94 explicit PlayList(const ClipListProto &serialized);
107 int rowCount(const QModelIndex &parent) const override;
108 int columnCount(const QModelIndex &parent) const override;
109 QVariant data(const QModelIndex &parent, int role) const override;
110 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
111 Qt::ItemFlags flags(const QModelIndex &index) const override;
112 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
114 void add_clip(const Clip &clip);
116 // <last> is inclusive in all of these.
117 void duplicate_clips(size_t first, size_t last);
118 void erase_clips(size_t first, size_t last);
119 // <delta> is -1 to move upwards, +1 to move downwards.
120 void move_clips(size_t first, size_t last, int delta);
122 size_t size() const { return clips.size(); }
123 bool empty() const { return clips.empty(); }
125 ClipProxy mutable_clip(size_t index) { return ClipProxy(clips[index], this, index); }
126 const Clip *clip(size_t index) const { return &clips[index]; }
128 ClipProxy mutable_back() { return mutable_clip(size() - 1); }
129 const Clip *back() const { return clip(size() - 1); }
131 // TODO: Move these out of PlayList.
132 void set_currently_playing(int index, double progress); // -1 = none.
133 int get_currently_playing() const { return currently_playing_index; }
135 ClipListProto serialize() const;
137 void emit_data_changed(size_t row) override;
140 void any_content_changed();
143 std::vector<Clip> clips;
144 int currently_playing_index = -1;
145 double play_progress = 0.0;
148 #endif // !defined (_CLIP_LIST_H)