Skip to content

Commit f70349c

Browse files
committed
Fix bugs
1 parent 05439f8 commit f70349c

6 files changed

Lines changed: 360 additions & 52 deletions

File tree

‎src/libs/application/dspxmodel/src/AnchorNode.cpp‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ namespace dspx {
3030
}
3131

3232
void AnchorNodePrivate::setInterp(AnchorNode::InterpolationMode interp_) {
33+
Q_Q(AnchorNode);
34+
if (auto engine = qjsEngine(q); engine && (interp_ != AnchorNode::None && interp_ != AnchorNode::Linear && interp_ != AnchorNode::Hermite)) {
35+
engine->throwError(QJSValue::RangeError, QStringLiteral("Interpolation mode must be one of None, Linear, or Hermite"));
36+
return;
37+
}
3338
setInterpUnchecked(interp_);
3439
}
3540

@@ -66,7 +71,8 @@ namespace dspx {
6671

6772
void AnchorNode::setInterp(InterpolationMode interp) {
6873
Q_D(AnchorNode);
69-
d->setInterp(interp);
74+
Q_ASSERT(interp == None || interp == Linear || interp == Hermite);
75+
d->setInterpUnchecked(interp);
7076
}
7177

7278
int AnchorNode::x() const {
@@ -77,7 +83,7 @@ namespace dspx {
7783
void AnchorNode::setX(int x) {
7884
Q_D(AnchorNode);
7985
Q_ASSERT(x >= 0);
80-
d->setX(x);
86+
d->setXUnchecked(x);
8187
}
8288

8389
int AnchorNode::y() const {
@@ -87,7 +93,7 @@ namespace dspx {
8793

8894
void AnchorNode::setY(int y) {
8995
Q_D(AnchorNode);
90-
model()->strategy()->setEntityProperty(handle(), ModelStrategy::P_Position, y);
96+
model()->strategy()->setEntityProperty(handle(), ModelStrategy::P_Value, y);
9197
}
9298

9399
QDspx::AnchorNode AnchorNode::toQDspx() const {

‎src/libs/application/dspxmodel/src/Control.cpp‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,27 @@ namespace dspx {
1919
double pan;
2020
bool mute;
2121

22+
void setGainUnchecked(double gain_);
23+
void setGain(double gain_);
24+
2225
void setPanUnchecked(double pan_);
2326
void setPan(double pan_);
2427
};
2528

29+
void ControlPrivate::setGainUnchecked(double gain_) {
30+
Q_Q(Control);
31+
pModel->strategy->setEntityProperty(handle, ModelStrategy::P_ControlGain, gain_);
32+
}
33+
34+
void ControlPrivate::setGain(double gain_) {
35+
Q_Q(Control);
36+
if (auto engine = qjsEngine(q); engine && (gain_ < 0)) {
37+
engine->throwError(QJSValue::RangeError, QStringLiteral("Gain must be greater or equal to 0"));
38+
return;
39+
}
40+
setGainUnchecked(gain_);
41+
}
42+
2643
void ControlPrivate::setPanUnchecked(double pan_) {
2744
Q_Q(Control);
2845
pModel->strategy->setEntityProperty(handle, ModelStrategy::P_ControlPan, pan_);
@@ -56,7 +73,8 @@ namespace dspx {
5673

5774
void Control::setGain(double gain) {
5875
Q_D(Control);
59-
d->pModel->strategy->setEntityProperty(d->handle, ModelStrategy::P_ControlGain, gain);
76+
Q_ASSERT(gain >= 0.0);
77+
d->setGainUnchecked(gain);
6078
}
6179

6280
double Control::pan() const {

‎src/libs/application/dspxmodel/src/Control.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace dspx {
1818
QML_ELEMENT
1919
QML_UNCREATABLE("")
2020
Q_DECLARE_PRIVATE(Control)
21-
Q_PROPERTY(double gain READ gain WRITE setGain NOTIFY gainChanged)
21+
Q_PRIVATE_PROPERTY(d_func(), double gain MEMBER gain WRITE setGain NOTIFY gainChanged)
2222
Q_PRIVATE_PROPERTY(d_func(), double pan MEMBER pan WRITE setPan NOTIFY panChanged)
2323
Q_PROPERTY(bool mute READ mute WRITE setMute NOTIFY muteChanged)
2424

‎src/libs/application/dspxmodel/src/Model.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ namespace dspx {
116116
entityObject->handleSetEntityProperty(property, value);
117117
}
118118
});
119+
120+
QObject::connect(strategy, &ModelStrategy::spliceDataArrayNotified, q, [=, this](Handle entity, int index, int length, const QVariantList &values) {
121+
if (auto entityObject = mapToObject(entity)) {
122+
entityObject->handleSpliceDataArray(index, length, values);
123+
}
124+
});
125+
126+
QObject::connect(strategy, &ModelStrategy::rotateDataArrayNotified, q, [=, this](Handle entity, int leftIndex, int middleIndex, int rightIndex) {
127+
if (auto entityObject = mapToObject(entity)) {
128+
entityObject->handleRotateDataArray(leftIndex, middleIndex, rightIndex);
129+
}
130+
});
119131
}
120132

121133
EntityObject * ModelPrivate::mapToObject(Handle handle) const {

‎src/libs/application/dspxmodel/src/Note.cpp‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,20 @@ namespace dspx {
274274
Q_EMIT posChanged(d->pos);
275275
break;
276276
}
277+
case ModelStrategy::P_PronunciationOriginal:
278+
case ModelStrategy::P_PronunciationEdited: {
279+
ModelPrivate::proxySetEntityPropertyNotify(d->pronunciation, property, value);
280+
break;
281+
}
282+
case ModelStrategy::P_VibratoAmplitude:
283+
case ModelStrategy::P_VibratoEnd:
284+
case ModelStrategy::P_VibratoFrequency:
285+
case ModelStrategy::P_VibratoOffset:
286+
case ModelStrategy::P_VibratoPhase:
287+
case ModelStrategy::P_VibratoStart: {
288+
ModelPrivate::proxySetEntityPropertyNotify(d->vibrato, property, value);
289+
break;
290+
}
277291
default:
278292
Q_UNREACHABLE();
279293
}

0 commit comments

Comments
 (0)