22class ChordEditor :
public QObject
27 getEditorSettings CONSTANT FINAL)
33 using ChordAccent = dsp::ChordAccent;
34 using ChordType = dsp::ChordType;
36 using MusicalNote = dsp::MusicalNote;
38 ChordEditor (QObject * parent =
nullptr);
44 auto getEditorSettings ()
const {
return editor_settings_.get (); }
54 apply_single_chord (
const ChordDescriptor &chord,
int idx,
bool undoable);
56 void apply_chords (
const std::vector<ChordDescriptor> &chords,
bool undoable);
58 void apply_preset_from_scale (
60 MusicalNote root_note,
63 void transpose_chords (
bool up,
bool undoable);
71 int get_chord_index (
const ChordDescriptor &chord)
const;
73 auto &get_chord_at_index (
size_t index) {
return chords_.at (index); }
74 auto &get_chord_at_index (
size_t index)
const {
return chords_.at (index); }
76 friend void init_from (
78 const ChordEditor &other,
82 obj.editor_settings_ =
83 utils::clone_unique_qobject (*other.editor_settings_, &obj);
86 void add_chord_descriptor (ChordDescriptor &&chord_descr)
88 chords_.emplace_back (std::move (chord_descr));
89 chords_.back ().update_notes ();
93 replace_chord_descriptor (
const auto index, ChordDescriptor &&chord_descr)
96 chords_.insert (
chords_.begin () + index, std::move (chord_descr));
97 get_chord_at_index (index).update_notes ();
101 static constexpr auto kEditorSettingsKey =
"editorSettings"sv;
102 static constexpr auto kChordsKey =
"chords"sv;
103 friend void to_json (nlohmann::json &j,
const ChordEditor &editor);
104 friend void from_json (
const nlohmann::json &j, ChordEditor &editor);
113 std::vector<ChordDescriptor>
chords_;