1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtLocation module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#include "qdeclarativeplaceuser_p.h"
38
39QT_BEGIN_NAMESPACE
40
41/*!
42 \qmltype User
43 \instantiates QDeclarativePlaceUser
44 \inqmlmodule QtLocation
45 \ingroup qml-QtLocation5-places
46 \ingroup qml-QtLocation5-places-data
47 \since QtLocation 5.5
48
49 \brief The User type identifies a user who contributed a particular \l Place content item.
50
51 Each \l Place content item has an associated user who contributed the content. This type
52 provides information about that user.
53
54 \sa ImageModel, ReviewModel, EditorialModel
55
56 \section1 Example
57
58 The following example shows how to display information about the user who
59 submitted an editorial:
60
61 \snippet declarative/places.qml QtQuick import
62 \snippet declarative/maps.qml QtLocation import
63 \codeline
64 \snippet declarative/places.qml EditorialModel
65*/
66
67QDeclarativePlaceUser::QDeclarativePlaceUser(QObject *parent)
68 : QObject(parent) {}
69
70QDeclarativePlaceUser::QDeclarativePlaceUser(const QPlaceUser &user,
71 QObject *parent)
72 : QObject(parent),
73 m_user(user) {}
74
75QDeclarativePlaceUser::~QDeclarativePlaceUser() {}
76
77/*!
78 \qmlproperty QPlaceUser QtLocation::User::user
79
80 For details on how to use this property to interface between C++ and QML see
81 "\l {User - QPlaceUser} {Interfaces between C++ and QML Code}".
82*/
83void QDeclarativePlaceUser::setUser(const QPlaceUser &user)
84{
85 QPlaceUser previousUser = m_user;
86 m_user = user;
87
88 if (m_user.userId() != previousUser.userId())
89 emit userIdChanged();
90
91 if (m_user.name() != previousUser.name())
92 emit nameChanged();
93}
94
95QPlaceUser QDeclarativePlaceUser::user() const
96{
97 return m_user;
98}
99
100/*!
101 \qmlproperty string QtLocation::User::userId
102
103 This property holds the unique identifier of the user.
104*/
105
106void QDeclarativePlaceUser::setUserId(const QString &id)
107{
108 if (m_user.userId() == id)
109 return;
110
111 m_user.setUserId(id);
112 emit userIdChanged();
113}
114
115QString QDeclarativePlaceUser::userId() const
116{
117 return m_user.userId();
118}
119
120/*!
121 \qmlproperty string QtLocation::User::name
122
123 This property holds the name of a user.
124*/
125void QDeclarativePlaceUser::setName(const QString &name)
126{
127 if (m_user.name() == name)
128 return;
129
130 m_user.setName(name);
131 emit nameChanged();
132}
133
134QString QDeclarativePlaceUser::name() const
135{
136 return m_user.name();
137}
138
139QT_END_NAMESPACE
140

source code of qtlocation/src/location/declarativeplaces/qdeclarativeplaceuser.cpp