~ubuntu-branches/ubuntu/quantal/qtmobility/quantal

« back to all changes in this revision

Viewing changes to plugins/declarative/location/qdeclarativegeoaddress.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-16 16:18:07 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101116161807-k2dzt2nyse975r3l
Tags: 1.1.0-0ubuntu1
* New upstream release
* Syncronise with Debian, no remaining changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 
4
** All rights reserved.
 
5
** Contact: Nokia Corporation (qt-info@nokia.com)
 
6
**
 
7
** This file is part of the Qt Mobility Components.
 
8
**
 
9
** $QT_BEGIN_LICENSE:LGPL$
 
10
** Commercial Usage
 
11
** Licensees holding valid Qt Commercial licenses may use this file in 
 
12
** accordance with the Qt Commercial License Agreement provided with
 
13
** the Software or, alternatively, in accordance with the terms
 
14
** contained in a written agreement between you and Nokia.
 
15
**
 
16
** GNU Lesser General Public License Usage
 
17
** Alternatively, this file may be used under the terms of the GNU Lesser
 
18
** General Public License version 2.1 as published by the Free Software
 
19
** Foundation and appearing in the file LICENSE.LGPL included in the
 
20
** packaging of this file.  Please review the following information to
 
21
** ensure the GNU Lesser General Public License version 2.1 requirements
 
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
23
**
 
24
** In addition, as a special exception, Nokia gives you certain additional
 
25
** rights.  These rights are described in the Nokia Qt LGPL Exception
 
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
27
**
 
28
** GNU General Public License Usage
 
29
** Alternatively, this file may be used under the terms of the GNU
 
30
** General Public License version 3.0 as published by the Free Software
 
31
** Foundation and appearing in the file LICENSE.GPL included in the
 
32
** packaging of this file.  Please review the following information to
 
33
** ensure the GNU General Public License version 3.0 requirements will be
 
34
** met: http://www.gnu.org/copyleft/gpl.html.
 
35
**
 
36
** If you are unsure which license is appropriate for your use, please
 
37
** contact the sales department at qt-sales@nokia.com.
 
38
** $QT_END_LICENSE$
 
39
**
 
40
***************************************************************************/
 
41
 
 
42
#include "qdeclarativegeoaddress_p.h"
 
43
 
 
44
QTM_BEGIN_NAMESPACE
 
45
 
 
46
/*!
 
47
    \qmlclass Address QDeclarativeGeoAddress
 
48
    \brief The Address element presents an address.
 
49
    \ingroup qml-location
 
50
 
 
51
    The Address element presents an address of a location.
 
52
    This element is part of the \bold{QtMobility.location 1.1} module.
 
53
 
 
54
    \sa Landmark, Place, {QGeoAddress}
 
55
*/
 
56
 
 
57
QDeclarativeGeoAddress::QDeclarativeGeoAddress(QObject* parent) :
 
58
        QObject(parent)
 
59
{
 
60
}
 
61
 
 
62
QDeclarativeGeoAddress::QDeclarativeGeoAddress(const QGeoAddress& address, QObject* parent) :
 
63
        QObject(parent), m_address(address)
 
64
{
 
65
}
 
66
 
 
67
QGeoAddress QDeclarativeGeoAddress::address() const
 
68
{
 
69
    return m_address;
 
70
}
 
71
 
 
72
void QDeclarativeGeoAddress::setAddress(const QGeoAddress& address)
 
73
{
 
74
    // Elaborate but takes care of emiting needed signals
 
75
    setCountry(address.country());
 
76
    setCountryCode(address.countryCode());
 
77
    setState(address.state());
 
78
    setCounty(address.county());
 
79
    setCity(address.city());
 
80
    setDistrict(address.district());
 
81
    setStreet(address.street());
 
82
    setPostcode(address.postcode());
 
83
    m_address = address;
 
84
}
 
85
 
 
86
QString QDeclarativeGeoAddress::country() const
 
87
{
 
88
    return m_address.country();
 
89
}
 
90
 
 
91
/*!
 
92
  \qmlproperty string Address::country
 
93
 
 
94
  This property holds the country of the address.
 
95
 
 
96
  */
 
97
 
 
98
void QDeclarativeGeoAddress::setCountry(const QString& country)
 
99
{
 
100
    if (m_address.country() == country)
 
101
        return;
 
102
    m_address.setCountry(country);
 
103
    emit countryChanged();
 
104
}
 
105
 
 
106
QString QDeclarativeGeoAddress::countryCode() const
 
107
{
 
108
    return m_address.countryCode();
 
109
}
 
110
 
 
111
/*!
 
112
  \qmlproperty string Address::countryCode
 
113
 
 
114
  This property holds the country code of the address.
 
115
 
 
116
  */
 
117
 
 
118
void QDeclarativeGeoAddress::setCountryCode(const QString& countryCode)
 
119
{
 
120
    if (m_address.countryCode() == countryCode)
 
121
        return;
 
122
    m_address.setCountryCode(countryCode);
 
123
    emit countryCodeChanged();
 
124
}
 
125
 
 
126
QString QDeclarativeGeoAddress::state() const
 
127
{
 
128
    return m_address.state();
 
129
}
 
130
 
 
131
/*!
 
132
  \qmlproperty string Address::state
 
133
 
 
134
  This property holds the state of the address.
 
135
 
 
136
  */
 
137
 
 
138
void QDeclarativeGeoAddress::setState(const QString& state)
 
139
{
 
140
    if (m_address.state() == state)
 
141
        return;
 
142
    m_address.setState(state);
 
143
    emit stateChanged();
 
144
}
 
145
 
 
146
QString QDeclarativeGeoAddress::county() const
 
147
{
 
148
    return m_address.county();
 
149
}
 
150
 
 
151
/*!
 
152
  \qmlproperty string Address::county
 
153
 
 
154
  This property holds the county of the address.
 
155
 
 
156
  */
 
157
 
 
158
void QDeclarativeGeoAddress::setCounty(const QString& county)
 
159
{
 
160
    if (m_address.county() == county)
 
161
        return;
 
162
    m_address.setCounty(county);
 
163
    emit countyChanged();
 
164
}
 
165
 
 
166
QString QDeclarativeGeoAddress::city() const
 
167
{
 
168
    return m_address.city();
 
169
}
 
170
 
 
171
/*!
 
172
  \qmlproperty string Address::city
 
173
 
 
174
  This property holds the city of the address.
 
175
 
 
176
  */
 
177
 
 
178
void QDeclarativeGeoAddress::setCity(const QString& city)
 
179
{
 
180
    if (m_address.city() == city)
 
181
        return;
 
182
    m_address.setCity(city);
 
183
    emit cityChanged();
 
184
}
 
185
 
 
186
QString QDeclarativeGeoAddress::district() const
 
187
{
 
188
    return m_address.district();
 
189
}
 
190
 
 
191
/*!
 
192
  \qmlproperty string Address::district
 
193
 
 
194
  This property holds the district of the address.
 
195
 
 
196
  */
 
197
 
 
198
void QDeclarativeGeoAddress::setDistrict(const QString& district)
 
199
{
 
200
    if (m_address.district() == district)
 
201
        return;
 
202
    m_address.setDistrict(district);
 
203
    emit districtChanged();
 
204
}
 
205
 
 
206
QString QDeclarativeGeoAddress::street() const
 
207
{
 
208
    return m_address.street();
 
209
}
 
210
 
 
211
/*!
 
212
  \qmlproperty string Address::street
 
213
 
 
214
  This property holds the street of the address.
 
215
 
 
216
  */
 
217
 
 
218
void QDeclarativeGeoAddress::setStreet(const QString& street)
 
219
{
 
220
    if (m_address.street() == street)
 
221
        return;
 
222
    m_address.setStreet(street);
 
223
    emit streetChanged();
 
224
}
 
225
 
 
226
QString QDeclarativeGeoAddress::postcode() const
 
227
{
 
228
    return m_address.postcode();
 
229
}
 
230
 
 
231
/*!
 
232
  \qmlproperty string Address::postcode
 
233
 
 
234
  This property holds the post code of the address.
 
235
 
 
236
  */
 
237
 
 
238
void QDeclarativeGeoAddress::setPostcode(const QString& postcode)
 
239
{
 
240
    if (m_address.postcode() == postcode)
 
241
        return;
 
242
    m_address.setPostcode(postcode);
 
243
    emit postcodeChanged();
 
244
}
 
245
 
 
246
#include "moc_qdeclarativegeoaddress_p.cpp"
 
247
 
 
248
QTM_END_NAMESPACE