17class Scene :
public QObject
20 Q_PROPERTY (QString name READ name WRITE setName NOTIFY nameChanged)
21 Q_PROPERTY (QColor color READ color WRITE setColor NOTIFY colorChanged)
31 QObject * parent =
nullptr);
33 ClipSlotList * clipSlots ()
const {
return clip_slot_list_.get (); }
36 QString name ()
const {
return name_; }
37 void setName (
const QString &name);
38 Q_SIGNAL
void nameChanged (
const QString &name);
41 QColor color ()
const {
return color_; }
42 void setColor (
const QColor &color);
43 Q_SIGNAL
void colorChanged (
const QColor &color);
46 auto &clip_slots ()
const {
return clip_slot_list_->clip_slots (); }
49 static constexpr auto kNameKey =
"name"sv;
50 static constexpr auto kColorKey =
"color"sv;
51 static constexpr auto kClipSlotsKey =
"clipSlots"sv;
52 friend void to_json (nlohmann::json &j,
const Scene &scene);
53 friend void from_json (
const nlohmann::json &j, Scene &scene);
61class SceneList :
public QAbstractListModel
71 QObject * parent =
nullptr);
75 ScenePtrRole = Qt::UserRole + 1,
80 Q_INVOKABLE
void removeScene (
int index);
81 Q_INVOKABLE
void moveScene (
int fromIndex,
int toIndex);
83 auto &scenes ()
const {
return scenes_; }
89 QHash<int, QByteArray> roleNames ()
const override
91 QHash<int, QByteArray> roles;
92 roles[ScenePtrRole] =
"scene";
95 int rowCount (
const QModelIndex &parent = QModelIndex ())
const override
97 if (parent.isValid ())
99 return static_cast<int> (scenes_.size ());
102 data (
const QModelIndex &index,
int role = Qt::DisplayRole)
const override
104 const auto index_int = index.row ();
105 if (!index.isValid () || index_int >=
static_cast<int> (scenes_.size ()))
108 if (role == ScenePtrRole)
110 return QVariant::fromValue (scenes_.at (index_int).get ());
118 friend void to_json (nlohmann::json &j,
const SceneList &list);
119 friend void from_json (
const nlohmann::json &j, SceneList &list);
122 std::vector<utils::QObjectUniquePtr<Scene>> scenes_;