Zrythm v2.0.0-alpha.1+31.4967fd053471
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
chord_row_list_model.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "dsp/chord_descriptor.h"
7#include "structure/arrangement/chord_object.h"
8#include "structure/arrangement/chord_region.h"
9
10#include <QAbstractListModel>
11#include <QPointer>
12#include <QtQmlIntegration/qqmlintegration.h>
13
14namespace zrythm::gui::qquick
15{
16
24class ChordRowListModel : public QAbstractListModel
25{
26 Q_OBJECT
27 Q_PROPERTY (
28 zrythm::structure::arrangement::ChordRegion * region READ region WRITE
29 setRegion NOTIFY regionChanged)
30 QML_ELEMENT
31
32public:
33 enum Roles
34 {
35 ChordNameRole = Qt::UserRole + 1,
36 ChordDescriptorRole,
37 ChordObjectCountRole
38 };
39 Q_ENUM (Roles)
40
41 explicit ChordRowListModel (QObject * parent = nullptr);
42
43 structure::arrangement::ChordRegion * region () const { return region_; }
44 void setRegion (structure::arrangement::ChordRegion * region);
45
46 QHash<int, QByteArray> roleNames () const override;
47 int rowCount (const QModelIndex &parent = QModelIndex ()) const override;
48 QVariant
49 data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
50
55 Q_INVOKABLE int
57
61 Q_INVOKABLE zrythm::dsp::ChordDescriptor * descriptorAtRow (int row) const;
62
66 Q_INVOKABLE QVariantList chordObjectsAtRow (int row) const;
67
68 Q_SIGNAL void regionChanged ();
69
75 Q_SIGNAL void contentChanged ();
76
77private:
78 struct Row
79 {
80 dsp::ChordDescriptor * descriptor;
81 std::vector<zrythm::structure::arrangement::ChordObject *> objects;
82 };
83
84 void rebuild ();
85 void connect_to_region_model ();
86 void disconnect_from_region_model ();
87 void connect_descriptor_signals ();
88 void disconnect_descriptor_signals ();
89
90 QPointer<structure::arrangement::ChordRegion> region_;
91 std::vector<Row> rows_;
92 std::vector<QMetaObject::Connection> descriptor_connections_;
93};
94
95} // namespace zrythm::gui::qquick
Describes a musical chord by its root note, type, accent, inversion, and optional bass note.
Q_INVOKABLE zrythm::dsp::ChordDescriptor * descriptorAtRow(int row) const
Returns the representative ChordDescriptor for the given row.
Q_SIGNAL void contentChanged()
Emitted after every rebuild (when chord objects are added, removed, moved, or have their descriptors ...
Q_INVOKABLE int rowForChordObject(zrythm::structure::arrangement::ChordObject *object) const
Returns the row index (into this model) that the given chord object belongs to, or -1 if not found.
Q_INVOKABLE QVariantList chordObjectsAtRow(int row) const
Returns all ChordObjects on the given row (for batch editing).
A chord placed inside a ChordRegion on the chord track.