21class ChordEditor :
public QObject
26 getEditorSettings CONSTANT FINAL)
32 using ChordAccent = dsp::ChordAccent;
33 using ChordType = dsp::ChordType;
35 using MusicalNote = dsp::MusicalNote;
37 ChordEditor (QObject * parent =
nullptr);
43 auto getEditorSettings ()
const {
return editor_settings_.get (); }
53 apply_single_chord (
const ChordDescriptor &chord,
int idx,
bool undoable);
55 void apply_chords (
const std::vector<ChordDescriptor> &chords,
bool undoable);
57 void apply_preset_from_scale (
59 MusicalNote root_note,
62 void transpose_chords (
bool up,
bool undoable);
70 int get_chord_index (
const ChordDescriptor &chord)
const;
72 auto &get_chord_at_index (
size_t index) {
return chords_.at (index); }
73 auto &get_chord_at_index (
size_t index)
const {
return chords_.at (index); }
75 friend void init_from (
77 const ChordEditor &other,
81 obj.editor_settings_ =
82 utils::clone_unique_qobject (*other.editor_settings_, &obj);
85 void add_chord_descriptor (ChordDescriptor &&chord_descr)
87 chords_.emplace_back (std::move (chord_descr));
88 chords_.back ().update_notes ();
92 replace_chord_descriptor (
const auto index, ChordDescriptor &&chord_descr)
95 chords_.insert (
chords_.begin () + index, std::move (chord_descr));
96 get_chord_at_index (index).update_notes ();
100 static constexpr auto kEditorSettingsKey =
"editorSettings"sv;
101 static constexpr auto kChordsKey =
"chords"sv;
102 friend void to_json (nlohmann::json &j,
const ChordEditor &editor)
104 j[kEditorSettingsKey] = editor.editor_settings_;
105 j[kChordsKey] = editor.chords_;
107 friend void from_json (
const nlohmann::json &j, ChordEditor &editor)
109 j.at (kEditorSettingsKey).get_to (editor.editor_settings_);
110 j.at (kChordsKey).get_to (editor.chords_);
120 std::vector<ChordDescriptor>
chords_;