summaryrefslogtreecommitdiff
path: root/src/imports/location/declarativeplaces/qdeclarativecontact.cpp
blob: 2ad1a0f2805d71446afa0f834b4cce7ab23dbd9b (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "qdeclarativecontact_p.h"

QT_USE_NAMESPACE

/*!
    \qmlclass Contact

    \brief The Contact element holds contact data.
    \inherits QObject

    \ingroup qml-places
*/

QDeclarativeContact::QDeclarativeContact(QObject* parent)
        : QObject(parent)
{
}

QDeclarativeContact::QDeclarativeContact(const QPlaceContact &value,
        QObject *parent)
        : QObject(parent),
          m_value(value)
{
}

QDeclarativeContact::~QDeclarativeContact()
{
}

void QDeclarativeContact::setContact(const QPlaceContact &value)
{
    QPlaceContact previous = m_value;
    m_value = value;

    if (previous.description() != m_value.description()) {
        emit descriptionChanged();
    }
    if (previous.type() != m_value.type()) {
        emit typeChanged();
    }
    if (previous.value() != m_value.value()) {
        emit valueChanged();
    }
}

QPlaceContact QDeclarativeContact::contact() const
{
    return m_value;
}

/*!
    \qmlproperty string Contact::description

    This property holds description.
*/

void QDeclarativeContact::setDescription(const QString &description)
{
    if (m_value.description() != description) {
        m_value.setDescription(description);
        emit descriptionChanged();
    }
}

QString QDeclarativeContact::description() const
{
    return m_value.description();
}

/*!
    \qmlproperty string Contact::type

    This property holds type.
*/
void QDeclarativeContact::setType(const QDeclarativeContact::ContactType &type)
{
    if (m_value.type() != (QPlaceContact::ContactType)type) {
        m_value.setType((QPlaceContact::ContactType)type);
        emit typeChanged();
    }
}

QDeclarativeContact::ContactType QDeclarativeContact::type() const
{
    return (QDeclarativeContact::ContactType) m_value.type();
}

/*!
    \qmlproperty string Contact::value

    This property holds value.
*/

void QDeclarativeContact::setValue(const QString &value)
{
    if (m_value.value() != value) {
        m_value.setValue(value);
        emit valueChanged();
    }
}

QString QDeclarativeContact::value() const
{
    return m_value.value();
}