aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithproperties.cpp
blob: eb0dae7465fa165d76b6f1d8b96d09c298e06d9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#include "typewithproperties.h"

using namespace Qt::StringLiterals;

double TypeWithProperties::a() const
{
    return m_a;
}
QString TypeWithProperties::b() const
{
    return m_b;
}
QVariant TypeWithProperties::c() const
{
    return m_c;
}
int TypeWithProperties::d() const
{
    return m_d;
}

QJSValue TypeWithProperties::jsvalue() const
{
    return m_jsvalue;
}

void TypeWithProperties::setA(double a_)
{
    m_a = a_;
}
void TypeWithProperties::setB(const QString &b_)
{
    if (m_b != b_) {
        m_b = b_;
        Q_EMIT bChanged();
    }
}
void TypeWithProperties::setC(const QVariant &c_)
{
    if (m_c != c_) {
        m_c = c_;
        Q_EMIT cWeirdSignal(c_);
    }
}
void TypeWithProperties::setD(int d_)
{
    if (m_d != d_) {
        m_d = d_;
        Q_EMIT dSignal(u"d changed"_s, d_);
    }
}
void TypeWithProperties::setJsValue(const QJSValue &value)
{
    m_jsvalue = value;
}

QBindable<double> TypeWithProperties::bindableA()
{
    return QBindable<double>(&m_a);
}
QBindable<int> TypeWithProperties::bindableD()
{
    return QBindable<int>(&m_d);
}
QBindable<QJSValue> TypeWithProperties::bindableJsValue()
{
    return QBindable<QJSValue>(&m_jsvalue);
}