Skip to content

Commit 8b59ed6

Browse files
committed
Update dspxmodel
1 parent 39092c9 commit 8b59ed6

25 files changed

Lines changed: 58 additions & 472 deletions

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

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "AnchorNode.h"
22
#include "AnchorNode_p.h"
33

4-
#include <QJSEngine>
54
#include <QVariant>
65

76
#include <opendspx/anchornode.h>
@@ -12,36 +11,6 @@
1211

1312
namespace dspx {
1413

15-
void AnchorNodePrivate::setInterpUnchecked(AnchorNode::InterpolationMode interp_) {
16-
Q_Q(AnchorNode);
17-
q->model()->strategy()->setEntityProperty(q->handle(), ModelStrategy::P_Type, QVariant::fromValue(interp_));
18-
}
19-
20-
void AnchorNodePrivate::setInterp(AnchorNode::InterpolationMode interp_) {
21-
Q_Q(AnchorNode);
22-
if ((interp_ != AnchorNode::None && interp_ != AnchorNode::Linear && interp_ != AnchorNode::Hermite)) {
23-
if (auto engine = qjsEngine(q))
24-
engine->throwError(QJSValue::RangeError, QStringLiteral("Interpolation mode must be one of None, Linear, or Hermite"));
25-
return;
26-
}
27-
setInterpUnchecked(interp_);
28-
}
29-
30-
void AnchorNodePrivate::setXUnchecked(int x_) {
31-
Q_Q(AnchorNode);
32-
q->model()->strategy()->setEntityProperty(q->handle(), ModelStrategy::P_Position, x_);
33-
}
34-
35-
void AnchorNodePrivate::setX(int x_) {
36-
Q_Q(AnchorNode);
37-
if (x_ < 0) {
38-
if (auto engine = qjsEngine(q))
39-
engine->throwError(QJSValue::RangeError, QStringLiteral("Position must be greater or equal to 0"));
40-
return;
41-
}
42-
setXUnchecked(x_);
43-
}
44-
4514
void AnchorNodePrivate::setAnchorNodeSequence(AnchorNode *item, AnchorNodeSequence *anchorNodeSequence) {
4615
auto d = item->d_func();
4716
if (d->anchorNodeSequence != anchorNodeSequence) {
@@ -70,7 +39,7 @@ namespace dspx {
7039
void AnchorNode::setInterp(InterpolationMode interp) {
7140
Q_D(AnchorNode);
7241
Q_ASSERT(interp == None || interp == Linear || interp == Hermite);
73-
d->setInterpUnchecked(interp);
42+
model()->strategy()->setEntityProperty(handle(), ModelStrategy::P_Type, QVariant::fromValue(interp));
7443
}
7544

7645
int AnchorNode::x() const {
@@ -81,7 +50,7 @@ namespace dspx {
8150
void AnchorNode::setX(int x) {
8251
Q_D(AnchorNode);
8352
Q_ASSERT(x >= 0);
84-
d->setXUnchecked(x);
53+
model()->strategy()->setEntityProperty(handle(), ModelStrategy::P_Position, x);
8554
}
8655

8756
int AnchorNode::y() const {

src/libs/application/dspxmodel/src/AnchorNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ namespace dspx {
2222
QML_ELEMENT
2323
QML_UNCREATABLE("")
2424
Q_DECLARE_PRIVATE(AnchorNode)
25-
Q_PRIVATE_PROPERTY(d_func(), InterpolationMode interp MEMBER interp WRITE setInterp NOTIFY interpChanged)
26-
Q_PRIVATE_PROPERTY(d_func(), int x MEMBER x WRITE setX NOTIFY xChanged)
25+
Q_PROPERTY(InterpolationMode interp READ interp WRITE setInterp NOTIFY interpChanged)
26+
Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged)
2727
Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged)
2828
Q_PROPERTY(AnchorNodeSequence *anchorNodeSequence READ anchorNodeSequence NOTIFY anchorNodeSequenceChanged)
2929

src/libs/application/dspxmodel/src/AnchorNode_p.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ namespace dspx {
1414
int y;
1515
AnchorNodeSequence *anchorNodeSequence{};
1616

17-
void setInterpUnchecked(AnchorNode::InterpolationMode interp_);
18-
void setInterp(AnchorNode::InterpolationMode interp_);
19-
void setXUnchecked(int x_);
20-
void setX(int x_);
17+
2118

2219
static void setAnchorNodeSequence(AnchorNode *item, AnchorNodeSequence *anchorNodeSequence);
2320
};

src/libs/application/dspxmodel/src/ClipTime.cpp

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#include "ClipTime.h"
2-
3-
#include <QJSEngine>
42
#include <QVariant>
53

64
#include <opendspx/cliptime.h>
@@ -21,59 +19,9 @@ namespace dspx {
2119
int length;
2220
int clipStart;
2321
int clipLen;
24-
25-
void setLengthUnchecked(int length_);
26-
void setLength(int length_);
27-
void setClipStartUnchecked(int clipStart_);
28-
void setClipStart(int clipStart_);
29-
void setClipLenUnchecked(int clipLen_);
30-
void setClipLen(int clipLen_);
3122
};
3223

33-
void ClipTimePrivate::setLengthUnchecked(int length_) {
34-
Q_Q(ClipTime);
35-
pModel->strategy->setEntityProperty(handle, ModelStrategy::P_Length, length_);
36-
}
37-
38-
void ClipTimePrivate::setLength(int length_) {
39-
Q_Q(ClipTime);
40-
if (length_ < 0) {
41-
if (auto engine = qjsEngine(q))
42-
engine->throwError(QJSValue::RangeError, QStringLiteral("Length must be greater than or equal to 0"));
43-
return;
44-
}
45-
setLengthUnchecked(length_);
46-
}
47-
48-
void ClipTimePrivate::setClipStartUnchecked(int clipStart_) {
49-
Q_Q(ClipTime);
50-
pModel->strategy->setEntityProperty(handle, ModelStrategy::P_ClipStart, clipStart_);
51-
}
5224

53-
void ClipTimePrivate::setClipStart(int clipStart_) {
54-
Q_Q(ClipTime);
55-
if (clipStart_ < 0) {
56-
if (auto engine = qjsEngine(q))
57-
engine->throwError(QJSValue::RangeError, QStringLiteral("ClipStart must be greater than or equal to 0"));
58-
return;
59-
}
60-
setClipStartUnchecked(clipStart_);
61-
}
62-
63-
void ClipTimePrivate::setClipLenUnchecked(int clipLen_) {
64-
Q_Q(ClipTime);
65-
pModel->strategy->setEntityProperty(handle, ModelStrategy::P_ClipLength, clipLen_);
66-
}
67-
68-
void ClipTimePrivate::setClipLen(int clipLen_) {
69-
Q_Q(ClipTime);
70-
if (clipLen_ < 0) {
71-
if (auto engine = qjsEngine(q))
72-
engine->throwError(QJSValue::RangeError, QStringLiteral("ClipLen must be greater than or equal to 0"));
73-
return;
74-
}
75-
setClipLenUnchecked(clipLen_);
76-
}
7725

7826
ClipTime::ClipTime(Handle handle, Model *model) : QObject(model), d_ptr(new ClipTimePrivate) {
7927
Q_D(ClipTime);
@@ -106,7 +54,7 @@ namespace dspx {
10654
void ClipTime::setLength(int length) {
10755
Q_D(ClipTime);
10856
Q_ASSERT(length >= 0);
109-
d->setLengthUnchecked(length);
57+
d->pModel->strategy->setEntityProperty(d->handle, ModelStrategy::P_Length, length);
11058
}
11159

11260
int ClipTime::clipStart() const {
@@ -117,7 +65,7 @@ namespace dspx {
11765
void ClipTime::setClipStart(int clipStart) {
11866
Q_D(ClipTime);
11967
Q_ASSERT(clipStart >= 0);
120-
d->setClipStartUnchecked(clipStart);
68+
d->pModel->strategy->setEntityProperty(d->handle, ModelStrategy::P_ClipStart, clipStart);
12169
}
12270

12371
int ClipTime::clipLen() const {
@@ -128,7 +76,7 @@ namespace dspx {
12876
void ClipTime::setClipLen(int clipLen) {
12977
Q_D(ClipTime);
13078
Q_ASSERT(clipLen >= 0);
131-
d->setClipLenUnchecked(clipLen);
79+
d->pModel->strategy->setEntityProperty(d->handle, ModelStrategy::P_ClipLength, clipLen);
13280
}
13381

13482
QDspx::ClipTime ClipTime::toQDspx() const {

src/libs/application/dspxmodel/src/ClipTime.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ namespace dspx {
2424
QML_UNCREATABLE("")
2525
Q_DECLARE_PRIVATE(ClipTime)
2626
Q_PROPERTY(int start READ start WRITE setStart NOTIFY startChanged)
27-
Q_PRIVATE_PROPERTY(d_func(), int length MEMBER length WRITE setLength NOTIFY lengthChanged)
28-
Q_PRIVATE_PROPERTY(d_func(), int clipStart MEMBER clipStart WRITE setClipStart NOTIFY clipStartChanged)
29-
Q_PRIVATE_PROPERTY(d_func(), int clipLen MEMBER clipLen WRITE setClipLen NOTIFY clipLenChanged)
27+
Q_PROPERTY(int length READ length WRITE setLength NOTIFY lengthChanged)
28+
Q_PROPERTY(int clipStart READ clipStart WRITE setClipStart NOTIFY clipStartChanged)
29+
Q_PROPERTY(int clipLen READ clipLen WRITE setClipLen NOTIFY clipLenChanged)
3030

3131
public:
3232
~ClipTime() override;

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

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#include "Control.h"
2-
3-
#include <QJSEngine>
42
#include <QVariant>
53

64
#include <dspxmodel/ModelStrategy.h>
@@ -19,42 +17,10 @@ namespace dspx {
1917
double pan;
2018
bool mute;
2119

22-
void setGainUnchecked(double gain_);
23-
void setGain(double gain_);
2420

25-
void setPanUnchecked(double pan_);
26-
void setPan(double pan_);
2721
};
2822

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 ((gain_ < 0)) {
37-
if (auto engine = qjsEngine(q))
38-
engine->throwError(QJSValue::RangeError, QStringLiteral("Gain must be greater or equal to 0"));
39-
return;
40-
}
41-
setGainUnchecked(gain_);
42-
}
4323

44-
void ControlPrivate::setPanUnchecked(double pan_) {
45-
Q_Q(Control);
46-
pModel->strategy->setEntityProperty(handle, ModelStrategy::P_ControlPan, pan_);
47-
}
48-
49-
void ControlPrivate::setPan(double pan_) {
50-
Q_Q(Control);
51-
if ((pan_ < -1 || pan_ > 1)) {
52-
if (auto engine = qjsEngine(q))
53-
engine->throwError(QJSValue::RangeError, QStringLiteral("Pan must be in range [-1.0, 1.0]"));
54-
return;
55-
}
56-
setPanUnchecked(pan_);
57-
}
5824

5925
Control::Control(Handle handle, Model *model) : QObject(model), d_ptr(new ControlPrivate) {
6026
Q_D(Control);
@@ -76,7 +42,7 @@ namespace dspx {
7642
void Control::setGain(double gain) {
7743
Q_D(Control);
7844
Q_ASSERT(gain >= 0.0);
79-
d->setGainUnchecked(gain);
45+
d->pModel->strategy->setEntityProperty(d->handle, ModelStrategy::P_ControlGain, gain);
8046
}
8147

8248
double Control::pan() const {
@@ -87,7 +53,7 @@ namespace dspx {
8753
void Control::setPan(double pan) {
8854
Q_D(Control);
8955
Q_ASSERT(pan >= -1.0 && pan <= 1.0);
90-
d->setPanUnchecked(pan);
56+
d->pModel->strategy->setEntityProperty(d->handle, ModelStrategy::P_ControlPan, pan);
9157
}
9258

9359
bool Control::mute() const {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ namespace dspx {
1919
QML_ELEMENT
2020
QML_UNCREATABLE("")
2121
Q_DECLARE_PRIVATE(Control)
22-
Q_PRIVATE_PROPERTY(d_func(), double gain MEMBER gain WRITE setGain NOTIFY gainChanged)
23-
Q_PRIVATE_PROPERTY(d_func(), double pan MEMBER pan WRITE setPan NOTIFY panChanged)
22+
Q_PROPERTY(double gain READ gain WRITE setGain NOTIFY gainChanged)
23+
Q_PROPERTY(double pan READ pan WRITE setPan NOTIFY panChanged)
2424
Q_PROPERTY(bool mute READ mute WRITE setMute NOTIFY muteChanged)
2525

2626
public:

src/libs/application/dspxmodel/src/Global.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#include "Global.h"
2-
3-
#include <QJSEngine>
42
#include <QVariant>
53

64
#include <opendspx/global.h>
@@ -19,28 +17,14 @@ namespace dspx {
1917
Handle handle;
2018

2119
int centShift() const;
22-
void setCentShiftUnchecked(int centShift);
23-
void setCentShift(int centShift);
20+
2421
};
2522

2623
int GlobalPrivate::centShift() const {
2724
return pModel->centShift;
2825
}
2926

30-
void GlobalPrivate::setCentShiftUnchecked(int centShift) {
31-
Q_Q(Global);
32-
pModel->strategy->setEntityProperty(handle, ModelStrategy::P_CentShift, centShift);
33-
}
3427

35-
void GlobalPrivate::setCentShift(int centShift) {
36-
Q_Q(Global);
37-
if ((centShift < -50 || centShift > 50)) {
38-
if (auto engine = qjsEngine(q))
39-
engine->throwError(QJSValue::RangeError, QStringLiteral("Cent shift must be in range [-50, 50]"));
40-
return;
41-
}
42-
setCentShiftUnchecked(centShift);
43-
}
4428

4529
Global::Global(Model *model) : QObject(model), d_ptr(new GlobalPrivate) {
4630
Q_D(Global);
@@ -73,7 +57,7 @@ namespace dspx {
7357
void Global::setCentShift(int centShift) {
7458
Q_D(Global);
7559
Q_ASSERT(centShift >= -50 && centShift <= 50);
76-
d->setCentShiftUnchecked(centShift);
60+
d->pModel->strategy->setEntityProperty(d->handle, ModelStrategy::P_CentShift, centShift);
7761
}
7862
QString Global::editorId() const {
7963
Q_D(const Global);

src/libs/application/dspxmodel/src/Global.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace dspx {
2626
Q_DECLARE_PRIVATE(Global)
2727
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
2828
Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged)
29-
Q_PRIVATE_PROPERTY(d_func(), int centShift READ centShift WRITE setCentShift NOTIFY centShiftChanged)
29+
Q_PROPERTY(int centShift READ centShift WRITE setCentShift NOTIFY centShiftChanged)
3030
Q_PROPERTY(QString editorId READ editorId WRITE setEditorId NOTIFY editorIdChanged)
3131
Q_PROPERTY(QString editorName READ editorName WRITE setEditorName NOTIFY editorNameChanged)
3232

src/libs/application/dspxmodel/src/Label.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include "Label.h"
22
#include "Label_p.h"
3-
4-
#include <QJSEngine>
53
#include <QVariant>
64

75
#include <opendspx/label.h>
@@ -12,20 +10,7 @@
1210

1311
namespace dspx {
1412

15-
void LabelPrivate::setPosUnchecked(int pos_) {
16-
Q_Q(Label);
17-
q->model()->strategy()->setEntityProperty(q->handle(), ModelStrategy::P_Position, pos_);
18-
}
1913

20-
void LabelPrivate::setPos(int pos_) {
21-
Q_Q(Label);
22-
if (pos_ < -0) {
23-
if (auto engine = qjsEngine(q))
24-
engine->throwError(QJSValue::RangeError, QStringLiteral("Pos must be greater or equal to 0"));
25-
return;
26-
}
27-
setPosUnchecked(pos_);
28-
}
2914

3015
void LabelPrivate::setLabelSequence(Label *item, LabelSequence *labelSequence) {
3116
auto d = item->d_func();
@@ -53,7 +38,7 @@ namespace dspx {
5338
void Label::setPos(int pos) {
5439
Q_D(Label);
5540
Q_ASSERT(pos >= 0);
56-
d->setPosUnchecked(pos);
41+
model()->strategy()->setEntityProperty(handle(), ModelStrategy::P_Position, pos);
5742
}
5843

5944
QString Label::text() const {

0 commit comments

Comments
 (0)