7 #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.
17 double fade_time_seconds = 0.5; // For the playlist only.
20 class DataChangedReceiver {
22 virtual ~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) {}
33 if (clip_list != nullptr) {
34 clip_list->emit_data_changed(row);
37 Clip *operator->() { return &clip; }
38 Clip &operator*() { return clip; }
42 DataChangedReceiver *clip_list;
46 class ClipList : public QAbstractTableModel, public DataChangedReceiver {
50 explicit ClipList(const ClipListProto &serialized);
63 int rowCount(const QModelIndex &parent) const override;
64 int columnCount(const QModelIndex &parent) const override;
65 QVariant data(const QModelIndex &parent, int role) const override;
66 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
67 Qt::ItemFlags flags(const QModelIndex &index) const override;
68 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
70 void add_clip(const Clip &clip);
71 size_t size() const { return clips.size(); }
72 bool empty() const { return clips.empty(); }
74 ClipProxy mutable_clip(size_t index) { return ClipProxy(clips[index], this, index); }
75 const Clip *clip(size_t index) const { return &clips[index]; }
77 ClipProxy mutable_back() { return mutable_clip(size() - 1); }
78 const Clip *back() const { return clip(size() - 1); }
80 ClipListProto serialize() const;
82 void emit_data_changed(size_t row) override;
85 void any_content_changed();
88 std::vector<Clip> clips;
91 class PlayList : public QAbstractTableModel, public DataChangedReceiver {
95 explicit PlayList(const ClipListProto &serialized);
108 int rowCount(const QModelIndex &parent) const override;
109 int columnCount(const QModelIndex &parent) const override;
110 QVariant data(const QModelIndex &parent, int role) const override;
111 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
112 Qt::ItemFlags flags(const QModelIndex &index) const override;
113 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
115 void add_clip(const Clip &clip);
117 // <last> is inclusive in all of these.
118 void duplicate_clips(size_t first, size_t last);
119 void erase_clips(size_t first, size_t last);
120 // <delta> is -1 to move upwards, +1 to move downwards.
121 void move_clips(size_t first, size_t last, int delta);
123 size_t size() const { return clips.size(); }
124 bool empty() const { return clips.empty(); }
126 ClipProxy mutable_clip(size_t index) { return ClipProxy(clips[index], this, index); }
127 const Clip *clip(size_t index) const { return &clips[index]; }
129 ClipProxy mutable_back() { return mutable_clip(size() - 1); }
130 const Clip *back() const { return clip(size() - 1); }
132 // TODO: Move these out of PlayList.
133 void set_currently_playing(int index, double progress); // -1 = none.
134 int get_currently_playing() const { return currently_playing_index; }
136 void set_progress(const std::map<size_t, double> &progress);
138 ClipListProto serialize() const;
140 void emit_data_changed(size_t row) override;
143 void any_content_changed();
146 std::vector<Clip> clips;
147 int currently_playing_index = -1;
148 double play_progress = 0.0;
149 std::map<size_t, double> current_progress;
152 #endif // !defined (_CLIP_LIST_H)