Debian Codegraph @

au4/src/playback/view/toolbars/components/bpmmodel.h

raw
1 /*
2 * Audacity: A Digital Audio Editor
3 */
4 #pragma once
5
6 #include <QAbstractListModel>
7 #include <QQuickItem>
8
9 #include "timecodeformatter.h"
10 #include "fieldsinteractioncontroller.h"
11
12 namespace au::playback {
13 class BPMModel : public QAbstractListModel
14 {
15 Q_OBJECT
16
17 Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged FINAL)
18
19 Q_PROPERTY(int currentEditedFieldIndex READ currentEditedFieldIndex
20 WRITE setCurrentEditedFieldIndex NOTIFY currentEditedFieldIndexChanged FINAL)
21
22 Q_PROPERTY(QQuickItem * visualItem READ visualItem WRITE setVisualItem CONSTANT)
23
24 public:
25 explicit BPMModel(QObject* parent = nullptr);
26
27 Q_INVOKABLE void upValue();
28 Q_INVOKABLE void downValue();
29
30 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
31 QVariant data(const QModelIndex& index, int role) const override;
32 QHash<int, QByteArray> roleNames() const override;
33
34 double value() const;
35 void setValue(double value);
36
37 int currentEditedFieldIndex() const;
38 void setCurrentEditedFieldIndex(int index);
39
40 QQuickItem* visualItem() const;
41 void setVisualItem(QQuickItem* item);
42
43 signals:
44 void valueChanged();
45 void currentEditedFieldIndexChanged();
46 void visualItemChanged();
47
48 private:
49 enum Roles {
50 rSymbol = Qt::UserRole + 1,
51 rIsEditable
52 };
53
54 void reloadFormatter();
55 void initFormatter();
56
57 void initFieldInteractionController();
58
59 void updateValueString();
60
61 double m_value = -1.0;
62 QString m_valueString;
63
64 std::shared_ptr<TimecodeFormatter> m_formatter;
65 std::shared_ptr<FieldsInteractionController> m_fieldsInteractionController;
66 };
67 }