+Qt::ItemFlags ClipList::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+ const int row = index.row(), column = index.column();
+ if (size_t(row) >= clips.size())
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+
+ switch (Column(column)) {
+ case Column::CAMERA_1:
+ case Column::CAMERA_2:
+ case Column::CAMERA_3:
+ case Column::CAMERA_4:
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
+ default:
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+ }
+}
+
+bool ClipList::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (!index.isValid() || role != Qt::EditRole) {
+ return false;
+ }
+
+ const int row = index.row(), column = index.column();
+ if (size_t(row) >= clips.size())
+ return false;
+
+ switch (Column(column)) {
+ case Column::CAMERA_1:
+ case Column::CAMERA_2:
+ case Column::CAMERA_3:
+ case Column::CAMERA_4: {
+ unsigned stream_idx = column - int(Column::CAMERA_1);
+ clips[row].descriptions[stream_idx] = value.toString().toStdString();
+ emit_data_changed(row);
+ return true;
+ }
+ default:
+ return false;
+ }
+}
+