7 #include <QAbstractTableModel>
14 int64_t pts_in = -1, pts_out = -1; // pts_in is inclusive, pts_out is exclusive.
15 std::string descriptions[MAX_STREAMS];
17 // These are for the playlist only.
18 unsigned stream_idx = 0;
19 double fade_time_seconds = 0.5;
23 class DataChangedReceiver {
25 virtual ~DataChangedReceiver() {}
26 virtual void emit_data_changed(size_t row) = 0;
29 // Like a smart pointer to a Clip, but emits dataChanged when it goes out of scope.
32 ClipProxy(Clip &clip, DataChangedReceiver *clip_list, size_t row)
33 : clip(clip), clip_list(clip_list), row(row) {}
36 if (clip_list != nullptr) {
37 clip_list->emit_data_changed(row);
40 Clip *operator->() { return &clip; }
41 Clip &operator*() { return clip; }
45 DataChangedReceiver *clip_list;
49 class ClipList : public QAbstractTableModel, public DataChangedReceiver {
53 ClipList(const ClipListProto &serialized);
59 CAMERA_1, // Then CAMERA_2, CAMERA_3, etc. as needed.
60 NUM_NON_CAMERA_COLUMNS = CAMERA_1
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 change_num_cameras(size_t num_cameras); // Defaults to 2. Cannot decrease.
83 void emit_data_changed(size_t row) override;
85 bool is_camera_column(int column) const
87 return (column >= int(Column::CAMERA_1) && column < int(Column::CAMERA_1) + int(num_cameras));
91 void any_content_changed();
94 std::vector<Clip> clips;
95 size_t num_cameras = 2;
98 class PlayList : public QAbstractTableModel, public DataChangedReceiver {
102 explicit PlayList(const ClipListProto &serialized);
116 int rowCount(const QModelIndex &parent) const override;
117 int columnCount(const QModelIndex &parent) const override;
118 QVariant data(const QModelIndex &parent, int role) const override;
119 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
120 Qt::ItemFlags flags(const QModelIndex &index) const override;
121 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
123 void add_clip(const Clip &clip);
125 // <last> is inclusive in all of these.
126 void duplicate_clips(size_t first, size_t last);
127 void erase_clips(size_t first, size_t last);
128 // <delta> is -1 to move upwards, +1 to move downwards.
129 void move_clips(size_t first, size_t last, int delta);
131 size_t size() const { return clips.size(); }
132 bool empty() const { return clips.empty(); }
134 ClipProxy mutable_clip(size_t index) { return ClipProxy(clips[index], this, index); }
135 const Clip *clip(size_t index) const { return &clips[index]; }
137 ClipProxy mutable_back() { return mutable_clip(size() - 1); }
138 const Clip *back() const { return clip(size() - 1); }
140 // TODO: Move these out of PlayList.
141 void set_currently_playing(int index, double progress); // -1 = none.
142 int get_currently_playing() const { return currently_playing_index; }
144 void set_progress(const std::map<size_t, double> &progress);
146 ClipListProto serialize() const;
148 void change_num_cameras(size_t num_cameras) // Defaults to 2. Cannot decrease.
150 this->num_cameras = num_cameras;
153 void emit_data_changed(size_t row) override;
156 void any_content_changed();
159 std::vector<Clip> clips;
160 int currently_playing_index = -1;
161 double play_progress = 0.0;
162 std::map<size_t, double> current_progress;
163 size_t num_cameras = 2;
166 #endif // !defined (_CLIP_LIST_H)