|
Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
A collection of tracks that provides a QAbstractListModel interface. More...
#include <src/structure/tracks/track_collection.h>


Public Types | |
| enum | TrackRoles { TrackPtrRole = Qt::UserRole + 1 , TrackFoldableRole , TrackExpandedRole , TrackDepthRole , TrackNameRole } |
Public Member Functions | |
| TrackCollection (TrackRegistry &track_registry, QObject *parent=nullptr) noexcept | |
| QHash< int, QByteArray > | roleNames () const override |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
| Q_INVOKABLE void | setTrackExpanded (const Track *track, bool expanded) |
| int | numSoloedTracks () const |
| Q_SIGNAL void | numSoloedTracksChanged () |
| int | numMutedTracks () const |
| Q_SIGNAL void | numMutedTracksChanged () |
| int | numListenedTracks () const |
| Q_SIGNAL void | numListenedTracksChanged () |
| Q_SIGNAL void | tracksMoved (const QList< int > &rows) |
| Emitted after tracks are moved within the collection. | |
| TrackPtrVariant | get_track_at_index (size_t index) const |
| Get the track at the given index. | |
| TrackUuidReference | get_track_ref_at_index (size_t index) const |
| Get the track reference at the given index. | |
| auto | get_track_index (const Track::Uuid &track_id) const |
| Get the index of the track with the given UUID. | |
| TrackUuidReference | track_ref_at_id (const Track::Uuid &track_id) const |
| auto | track_count () const |
| Get the number of tracks in the collection. | |
| bool | contains (const Track::Uuid &track_id) const |
| Check if the collection contains a track with the given UUID. | |
| void | add_track (const TrackUuidReference &track_id) |
| Add a track to the collection. | |
| void | insert_track (const TrackUuidReference &track_id, int pos) |
| Insert a track at the given position. | |
| void | remove_track (const Track::Uuid &track_id) |
| Remove a track from the collection. | |
| void | detach_track (const Track::Uuid &track_id) |
| Remove a track from the collection without clearing its folder metadata (expanded state and folder parent relationships). | |
| void | reattach_track (const TrackUuidReference &track_id, int pos) |
| Insert a track without initializing or modifying folder metadata. | |
| template<typename Container> | |
| void | notify_tracks_moved (const Container &uuids) |
| Notify that the given tracks have been moved. | |
| void | move_track (const Track::Uuid &track_id, int pos) |
| Move a track from one position to another. | |
| void | clear () |
| Clear all tracks from the collection. | |
| auto | get_track_span () const |
| Get a span view of all tracks. | |
| const std::vector< TrackUuidReference > & | tracks () const |
| Get the underlying tracks vector. | |
| TrackRegistry & | get_track_registry () const |
| Get the track registry. | |
| void | set_track_expanded (const Track::Uuid &track_id, bool expanded) |
| Set the expanded state of a foldable track. | |
| bool | get_track_expanded (const Track::Uuid &track_id) const |
| Get the expanded state of a foldable track. | |
| void | set_folder_parent (const Track::Uuid &child_id, const Track::Uuid &parent_id, bool auto_reposition=false) |
| Set the folder parent for a track. | |
| std::optional< Track::Uuid > | get_folder_parent (const Track::Uuid &child_id) const |
| Get the folder parent for a track. | |
| void | remove_folder_parent (const Track::Uuid &child_id, bool auto_reposition=false) |
| Remove the folder parent for a track. | |
| bool | is_track_foldable (const Track::Uuid &track_id) const |
| Check if a track is foldable. | |
| bool | is_ancestor_of (const Track::Uuid &possible_ancestor, const Track::Uuid &track_id) const |
Check if possible_ancestor is an ancestor of track_id. | |
| std::optional< Track::Uuid > | get_enclosing_folder (size_t index) const |
| Get the innermost enclosing folder at the given track index. | |
| size_t | get_child_count (const Track::Uuid &parent_id) const |
| Get the number of children for a foldable track. | |
| std::vector< Track::Uuid > | get_all_descendants (const Track::Uuid &parent_id) const |
| Get all descendant track UUIDs of a folder, in list order. | |
| size_t | get_last_child_index (const Track::Uuid &parent_id) const |
| Get the last child index for a foldable track. | |
Properties | |
| int | numSoloedTracks |
| int | numMutedTracks |
| int | numListenedTracks |
Friends | |
| void | to_json (nlohmann::json &j, const TrackCollection &collection) |
| void | from_json (const nlohmann::json &j, TrackCollection &collection) |
A collection of tracks that provides a QAbstractListModel interface.
Tracks are stored in a flat list, and the model provides facilities to get whether a track is foldable, expanded, and its depth (0 means not part of a foldable parent).
Definition at line 22 of file track_collection.h.
| enum zrythm::structure::tracks::TrackCollection::TrackRoles |
Definition at line 32 of file track_collection.h.
| void zrythm::structure::tracks::TrackCollection::detach_track | ( | const Track::Uuid & | track_id | ) |
Remove a track from the collection without clearing its folder metadata (expanded state and folder parent relationships).
Use this when repositioning tracks that will be re-inserted immediately (e.g., during undo/redo of a move operation), so that folder metadata is preserved across the remove+insert cycle.
| std::vector< Track::Uuid > zrythm::structure::tracks::TrackCollection::get_all_descendants | ( | const Track::Uuid & | parent_id | ) | const |
Get all descendant track UUIDs of a folder, in list order.
Walks forward from the folder's position, collecting all tracks whose folder_parent chain leads back to parent_id (direct children and nested descendants).
| std::optional< Track::Uuid > zrythm::structure::tracks::TrackCollection::get_enclosing_folder | ( | size_t | index | ) | const |
Get the innermost enclosing folder at the given track index.
Walks backward from the given index to find the nearest expanded foldable track whose child range covers the index. Returns nullopt if the position is not inside any folder.
|
inline |
Get the index of the track with the given UUID.
Definition at line 98 of file track_collection.h.
|
inline |
Get the track registry.
Definition at line 205 of file track_collection.h.
|
inline |
Get a span view of all tracks.
Definition at line 195 of file track_collection.h.
| bool zrythm::structure::tracks::TrackCollection::is_ancestor_of | ( | const Track::Uuid & | possible_ancestor, |
| const Track::Uuid & | track_id ) const |
Check if possible_ancestor is an ancestor of track_id.
Walks the folder_parent_ chain from track_id upward. Returns true if possible_ancestor is found in the chain.
|
inline |
Notify that the given tracks have been moved.
Looks up current row indices for each UUID and emits tracksMoved(). UUIDs not found in the collection are silently skipped.
| Container | A container of Track::Uuid with a contains() method. |
Definition at line 166 of file track_collection.h.
| void zrythm::structure::tracks::TrackCollection::reattach_track | ( | const TrackUuidReference & | track_id, |
| int | pos ) |
Insert a track without initializing or modifying folder metadata.
Unlike insert_track, this does not auto-expand foldable tracks or modify expanded_tracks_. Use after detach_track to re-insert a track while preserving its original folder state.
| void zrythm::structure::tracks::TrackCollection::remove_folder_parent | ( | const Track::Uuid & | child_id, |
| bool | auto_reposition = false ) |
Remove the folder parent for a track.
When auto_reposition is true, the child is automatically moved to after the folder's last child. When false, only the folder_parent_ entry is erased (use when the caller handles positioning separately).
| void zrythm::structure::tracks::TrackCollection::set_folder_parent | ( | const Track::Uuid & | child_id, |
| const Track::Uuid & | parent_id, | ||
| bool | auto_reposition = false ) |
Set the folder parent for a track.
When auto_reposition is true, the child is automatically moved to be the last child of the parent. When false, only the folder_parent_ entry is updated (use when the caller handles positioning separately).
|
inline |
Get the number of tracks in the collection.
Definition at line 113 of file track_collection.h.
|
inline |
Definition at line 105 of file track_collection.h.
|
inline |
Get the underlying tracks vector.
Definition at line 200 of file track_collection.h.
| Q_SIGNAL void zrythm::structure::tracks::TrackCollection::tracksMoved | ( | const QList< int > & | rows | ) |
Emitted after tracks are moved within the collection.
| rows | Source model row indices of the moved tracks, in ascending order. |
|
read |
Definition at line 27 of file track_collection.h.
|
read |
Definition at line 26 of file track_collection.h.
|
read |
Definition at line 25 of file track_collection.h.