Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
track_collection_operator.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "structure/tracks/track_collection.h"
7#include "undo/undo_stack.h"
8
9#include <QtQmlIntegration/qqmlintegration.h>
10
11namespace zrythm::actions
12{
13
20class TrackCollectionOperator : public QObject
21{
22 Q_OBJECT
23 Q_PROPERTY (
24 zrythm::structure::tracks::TrackCollection * collection READ collection
25 WRITE setCollection NOTIFY collectionChanged)
26 Q_PROPERTY (
27 zrythm::undo::UndoStack * undoStack READ undoStack WRITE setUndoStack NOTIFY
28 undoStackChanged)
29 QML_ELEMENT
30
31public:
32 explicit TrackCollectionOperator (QObject * parent = nullptr)
33 : QObject (parent)
34 {
35 }
36
37 structure::tracks::TrackCollection * collection () const
38 {
39 return collection_;
40 }
41 void setCollection (structure::tracks::TrackCollection * collection)
42 {
43 if (collection_ != collection)
44 {
45 collection_ = collection;
46 Q_EMIT collectionChanged ();
47 }
48 }
49 Q_SIGNAL void collectionChanged ();
50
51 undo::UndoStack * undoStack () const { return undo_stack_; }
52 void setUndoStack (undo::UndoStack * undoStack)
53 {
54 if (undo_stack_ != undoStack)
55 {
56 undo_stack_ = undoStack;
57 Q_EMIT undoStackChanged ();
58 }
59 }
60 Q_SIGNAL void undoStackChanged ();
61
71 Q_INVOKABLE void moveTracks (
72 const QList<zrythm::structure::tracks::Track *> &tracks,
73 int targetPosition,
75
78 *
79 * QML cannot resolve C++ default parameters on Q_INVOKABLE methods.
80 * Use this overload when no target folder is needed.
81 */
82 Q_INVOKABLE void moveTracks (
83 const QList<zrythm::structure::tracks::Track *> &tracks,
84 int targetPosition)
85 {
86 moveTracks (tracks, targetPosition, nullptr);
87 }
88
89private:
91 undo::UndoStack * undo_stack_{};
92};
93
94} // namespace zrythm::actions
Q_INVOKABLE void moveTracks(const QList< zrythm::structure::tracks::Track * > &tracks, int targetPosition, zrythm::structure::tracks::Track *targetFolder)
Moves tracks to a new position in the collection.
A collection of tracks that provides a QAbstractListModel interface.
Represents a track in the project.
Definition track.h:54