16class ClipSlot :
public QObject
21 setRegion NOTIFY regionChanged)
22 Q_PROPERTY (ClipState state READ state WRITE setState NOTIFY stateChanged)
25 QML_EXTENDED_NAMESPACE (zrythm::structure::tracks)
41 if (region_ref_.has_value ())
43 return region_ref_->get ();
51 Q_INVOKABLE
void clearRegion ()
53 if (!region_ref_.has_value ())
59 Q_EMIT regionChanged (
nullptr);
62 ClipState state ()
const {
return state_.load (); }
63 void setState (ClipState state);
64 Q_SIGNAL
void stateChanged (ClipState state);
67 static constexpr auto kRegionIdKey =
"regionId"sv;
68 friend void to_json (nlohmann::json &j,
const ClipSlot &slot);
69 friend void from_json (
const nlohmann::json &j, ClipSlot &slot);
72 std::optional<arrangement::ArrangerObjectUuidReference> region_ref_;
74 std::atomic<ClipState> state_{ ClipState::Stopped };
77class ClipSlotList :
public QAbstractListModel
87 QObject * parent =
nullptr);
88 Q_DISABLE_COPY_MOVE (ClipSlotList)
90 enum ClipSlotListRoles
92 ClipSlotPtrRole = Qt::UserRole + 1,
94 Q_ENUM (ClipSlotListRoles)
103 .at (track_collection_.get_track_index (track->get_uuid ()))
107 QHash<int, QByteArray> roleNames ()
const override
109 QHash<int, QByteArray> roles;
110 roles[ClipSlotPtrRole] =
"clipSlot";
113 int rowCount (
const QModelIndex &parent = QModelIndex ())
const override
115 if (parent.isValid ())
117 return static_cast<int> (clip_slots_.size ());
120 data (
const QModelIndex &index,
int role = Qt::DisplayRole)
const override
122 const auto index_int = index.row ();
123 if (!index.isValid () || index_int >=
static_cast<int> (clip_slots_.size ()))
126 if (role == ClipSlotPtrRole)
128 return QVariant::fromValue (clip_slots_.at (index_int).get ());
136 auto &clip_slots ()
const {
return clip_slots_; }
139 friend void to_json (nlohmann::json &j,
const ClipSlotList &list);
140 friend void from_json (
const nlohmann::json &j, ClipSlotList &list);
144 std::vector<utils::QObjectUniquePtr<ClipSlot>> clip_slots_;