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;
24 uint64_t id; // Used for progress callback only. Immutable.
27 class DataChangedReceiver {
29 virtual ~DataChangedReceiver() {}
30 virtual void emit_data_changed(size_t row) = 0;
33 // Like a smart pointer to a Clip, but emits dataChanged when it goes out of scope.
36 ClipProxy(Clip &clip, DataChangedReceiver *clip_list, size_t row)
37 : clip(clip), clip_list(clip_list), row(row) {}
40 if (clip_list != nullptr) {
41 clip_list->emit_data_changed(row);
44 Clip *operator->() { return &clip; }
45 Clip &operator*() { return clip; }
49 DataChangedReceiver *clip_list;
53 class ClipList : public QAbstractTableModel, public DataChangedReceiver {
57 ClipList(const ClipListProto &serialized);
63 CAMERA_1, // Then CAMERA_2, CAMERA_3, etc. as needed.
64 NUM_NON_CAMERA_COLUMNS = CAMERA_1
67 int rowCount(const QModelIndex &parent) const override;
68 int columnCount(const QModelIndex &parent) const override;
69 QVariant data(const QModelIndex &parent, int role) const override;
70 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
71 Qt::ItemFlags flags(const QModelIndex &index) const override;
72 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
74 void add_clip(const Clip &clip);
75 size_t size() const { return clips.size(); }
76 bool empty() const { return clips.empty(); }
78 ClipProxy mutable_clip(size_t index) { return ClipProxy(clips[index], this, index); }
79 const Clip *clip(size_t index) const { return &clips[index]; }
81 ClipProxy mutable_back() { return mutable_clip(size() - 1); }
82 const Clip *back() const { return clip(size() - 1); }
84 ClipListProto serialize() const;
86 void change_num_cameras(size_t num_cameras); // Defaults to 2. Cannot decrease.
87 void emit_data_changed(size_t row) override;
89 bool is_camera_column(int column) const
91 return (column >= int(Column::CAMERA_1) && column < int(Column::CAMERA_1) + int(num_cameras));
95 void any_content_changed();
98 std::vector<Clip> clips;
99 size_t num_cameras = 2;
102 class PlayList : public QAbstractTableModel, public DataChangedReceiver {
106 explicit PlayList(const ClipListProto &serialized);
120 int rowCount(const QModelIndex &parent) const override;
121 int columnCount(const QModelIndex &parent) const override;
122 QVariant data(const QModelIndex &parent, int role) const override;
123 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
124 Qt::ItemFlags flags(const QModelIndex &index) const override;
125 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
127 void add_clip(const Clip &clip);
129 // <last> is inclusive in all of these.
130 void duplicate_clips(size_t first, size_t last);
131 void erase_clips(size_t first, size_t last);
132 // <delta> is -1 to move upwards, +1 to move downwards.
133 void move_clips(size_t first, size_t last, int delta);
135 size_t size() const { return clips.size(); }
136 bool empty() const { return clips.empty(); }
138 ClipProxy mutable_clip(size_t index) { return ClipProxy(clips[index].clip, this, index); }
139 const Clip *clip(size_t index) const { return &clips[index].clip; }
140 const ClipWithID *clip_with_id(size_t index) const { return &clips[index]; }
142 ClipProxy mutable_back() { return mutable_clip(size() - 1); }
143 const Clip *back() const { return clip(size() - 1); }
145 void set_progress(const std::map<uint64_t, double> &progress);
147 ClipListProto serialize() const;
149 void change_num_cameras(size_t num_cameras) // Defaults to 2. Cannot decrease.
151 this->num_cameras = num_cameras;
154 void emit_data_changed(size_t row) override;
157 void any_content_changed();
160 std::vector<ClipWithID> clips;
161 double play_progress = 0.0;
162 std::map<uint64_t, double> current_progress;
163 size_t num_cameras = 2;
164 uint64_t clip_counter = 1000000; // Used for generating IDs. Starting at a high number to avoid any kind of bugs treating IDs as rows.
167 #endif // !defined (_CLIP_LIST_H)