Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
rename_track_command.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <utility>
7
8#include "structure/tracks/track.h"
9
10#include <QUndoCommand>
11
12namespace zrythm::commands
13{
14class RenameTrackCommand : public QUndoCommand
15{
16
17public:
18 RenameTrackCommand (structure::tracks::Track &track, QString name)
19 : QUndoCommand (QObject::tr ("Rename Track")), track_ (track),
20 name_after_ (std::move (name))
21 {
22 }
23
24 void undo () override { track_.setName (name_before_); }
25 void redo () override
26 {
27 // note we are setting the previous track name here and not in the
28 // constructor because the action may have been created but not performed
29 // yet, and the track name may have changed meanwhile
30 name_before_ = track_.name ();
31 track_.setName (name_after_);
32 }
33
34private:
36 QString name_before_;
37 QString name_after_;
38};
39
40} // namespace zrythm::commands
Represents a track in the project.
Definition track.h:54