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

« back to all changes in this revision

Viewing changes to plugins/declarative/location/qdeclarativegeomaprectangleobject.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:
11
11
**
12
12
** $QT_BEGIN_LICENSE:LGPL$
13
13
** Commercial Usage
14
 
** Licensees holding valid Qt Commercial licenses may use this file in
15
 
** accordance with the Qt Solutions Commercial License Agreement provided
16
 
** with the Software or, alternatively, in accordance with the terms
 
14
** Licensees holding valid Qt Commercial licenses may use this file in 
 
15
** accordance with the Qt Commercial License Agreement provided with
 
16
** the Software or, alternatively, in accordance with the terms
17
17
** contained in a written agreement between you and Nokia.
18
18
**
19
19
** GNU Lesser General Public License Usage
36
36
** ensure the GNU General Public License version 3.0 requirements will be
37
37
** met: http://www.gnu.org/copyleft/gpl.html.
38
38
**
39
 
** Please note Third Party Software included with Qt Solutions may impose
40
 
** additional restrictions and it is the user's responsibility to ensure
41
 
** that they have met the licensing requirements of the GPL, LGPL, or Qt
42
 
** Solutions Commercial license and the relevant license of the Third
43
 
** Party Software they are using.
44
 
**
45
39
** If you are unsure which license is appropriate for your use, please
46
40
** contact the sales department at qt-sales@nokia.com.
47
41
** $QT_END_LICENSE$
55
49
 
56
50
QTM_BEGIN_NAMESPACE
57
51
 
 
52
/*!
 
53
    \qmlclass MapRectangle
 
54
 
 
55
    \brief The MapRectangle element displays a rectangle on a map.
 
56
    \inherits QGeoMapRectangleObject
 
57
 
 
58
    \ingroup qml-location-maps
 
59
 
 
60
    The rectangle is specified in terms of the top left and bottom 
 
61
    right coordinates.
 
62
 
 
63
    If \l topLeft and \l bottomRight are not specified and valid the 
 
64
    rectangle will not be displayed.
 
65
 
 
66
    The MapRectangle element is part of the \bold{QtMobility.location 1.1} module.
 
67
*/
 
68
 
58
69
QDeclarativeGeoMapRectangleObject::QDeclarativeGeoMapRectangleObject()
59
70
{
60
71
    m_topLeft = new QDeclarativeCoordinate(this);
 
72
 
 
73
    connect(m_topLeft,
 
74
            SIGNAL(latitudeChanged(double)),
 
75
            this,
 
76
            SLOT(topLeftLatitudeChanged(double)));
 
77
    connect(m_topLeft,
 
78
            SIGNAL(longitudeChanged(double)),
 
79
            this,
 
80
            SLOT(topLeftLongitudeChanged(double)));
 
81
    connect(m_topLeft,
 
82
            SIGNAL(altitudeChanged(double)),
 
83
            this,
 
84
            SLOT(topLeftAltitudeChanged(double)));
 
85
 
61
86
    m_bottomRight = new QDeclarativeCoordinate(this);
 
87
 
 
88
    connect(m_bottomRight,
 
89
            SIGNAL(latitudeChanged(double)),
 
90
            this,
 
91
            SLOT(bottomRightLatitudeChanged(double)));
 
92
    connect(m_bottomRight,
 
93
            SIGNAL(longitudeChanged(double)),
 
94
            this,
 
95
            SLOT(bottomRightLongitudeChanged(double)));
 
96
    connect(m_bottomRight,
 
97
            SIGNAL(altitudeChanged(double)),
 
98
            this,
 
99
            SLOT(bottomRightAltitudeChanged(double)));
 
100
 
 
101
    connect(&m_border,
 
102
            SIGNAL(colorChanged(QColor)),
 
103
            this,
 
104
            SLOT(borderColorChanged(QColor)));
 
105
    connect(&m_border,
 
106
            SIGNAL(widthChanged(int)),
 
107
            this,
 
108
            SLOT(borderWidthChanged(int)));
62
109
}
63
110
 
64
111
QDeclarativeGeoMapRectangleObject::~QDeclarativeGeoMapRectangleObject()
65
112
{
66
113
}
67
114
 
 
115
/*!
 
116
    \qmlproperty Coordinate MapRectangle::topLeft
 
117
    
 
118
    This property holds the coordinate corresponding to the top left 
 
119
    corner of the rectangle.
 
120
 
 
121
    The default value is an invalid coordinate.
 
122
*/
 
123
 
68
124
void QDeclarativeGeoMapRectangleObject::setDeclarativeTopLeft(const QDeclarativeCoordinate *topLeft)
69
125
{
70
126
    if (m_topLeft->coordinate() == topLeft->coordinate())
76
132
    emit declarativeTopLeftChanged(m_topLeft);
77
133
}
78
134
 
79
 
QDeclarativeCoordinate* QDeclarativeGeoMapRectangleObject::declarativeTopLeft() const
 
135
QDeclarativeCoordinate* QDeclarativeGeoMapRectangleObject::declarativeTopLeft()
80
136
{
81
137
    return m_topLeft;
82
138
}
83
139
 
 
140
void QDeclarativeGeoMapRectangleObject::topLeftLatitudeChanged(double /*latitude*/)
 
141
{
 
142
    setTopLeft(m_topLeft->coordinate());
 
143
}
 
144
 
 
145
void QDeclarativeGeoMapRectangleObject::topLeftLongitudeChanged(double /*longitude*/)
 
146
{
 
147
    setTopLeft(m_topLeft->coordinate());
 
148
}
 
149
 
 
150
void QDeclarativeGeoMapRectangleObject::topLeftAltitudeChanged(double /*altitude*/)
 
151
{
 
152
    setTopLeft(m_topLeft->coordinate());
 
153
}
 
154
 
 
155
/*!
 
156
    \qmlproperty Coordinate MapRectangle::bottomRight
 
157
    
 
158
    This property holds the coordinate corresponding to the bottom right
 
159
    corner of the rectangle.
 
160
 
 
161
    The default value is an invalid coordinate.
 
162
*/
 
163
 
84
164
void QDeclarativeGeoMapRectangleObject::setDeclarativeBottomRight(const QDeclarativeCoordinate *bottomRight)
85
165
{
86
166
    if (m_bottomRight->coordinate() == bottomRight->coordinate())
92
172
    emit declarativeBottomRightChanged(m_bottomRight);
93
173
}
94
174
 
95
 
QDeclarativeCoordinate* QDeclarativeGeoMapRectangleObject::declarativeBottomRight() const
 
175
QDeclarativeCoordinate* QDeclarativeGeoMapRectangleObject::declarativeBottomRight()
96
176
{
97
177
    return m_bottomRight;
98
178
}
99
179
 
 
180
void QDeclarativeGeoMapRectangleObject::bottomRightLatitudeChanged(double /*latitude*/)
 
181
{
 
182
    setBottomRight(m_bottomRight->coordinate());
 
183
}
 
184
 
 
185
void QDeclarativeGeoMapRectangleObject::bottomRightLongitudeChanged(double /*longitude*/)
 
186
{
 
187
    setBottomRight(m_bottomRight->coordinate());
 
188
}
 
189
 
 
190
void QDeclarativeGeoMapRectangleObject::bottomRightAltitudeChanged(double /*altitude*/)
 
191
{
 
192
    setBottomRight(m_bottomRight->coordinate());
 
193
}
 
194
 
 
195
/*!
 
196
    \qmlproperty color MapRectangle::color
 
197
 
 
198
    This property holds the color used to fill the circle.
 
199
 
 
200
    The default value corresponds to a transparent color.
 
201
*/
 
202
 
100
203
void QDeclarativeGeoMapRectangleObject::setColor(const QColor &color)
101
204
{
102
205
    if (m_color == color)
113
216
    return m_color;
114
217
}
115
218
 
 
219
/*!
 
220
    \qmlproperty int MapRectangle::border.width
 
221
    \qmlproperty color MapRectangle::border.color
 
222
 
 
223
    These properties hold the width and color used to draw the border of the circle.
 
224
 
 
225
    The width is in pixels and is independent of the zoom level of the map.
 
226
 
 
227
    The default values correspond to a black border with a width of 1 pixel.
 
228
 
 
229
    For no line, use a width of 0 or a transparent color.
 
230
*/
 
231
 
 
232
QDeclarativeGeoMapObjectBorder* QDeclarativeGeoMapRectangleObject::border()
 
233
{
 
234
    return &m_border;
 
235
}
 
236
 
 
237
void QDeclarativeGeoMapRectangleObject::borderColorChanged(const QColor &color)
 
238
{
 
239
    QPen p = pen();
 
240
    p.setColor(color);
 
241
    setPen(p);
 
242
}
 
243
 
 
244
void QDeclarativeGeoMapRectangleObject::borderWidthChanged(int width)
 
245
{
 
246
    QPen p = pen();
 
247
    p.setWidth(width);
 
248
    if (width == 0)
 
249
        p.setStyle(Qt::NoPen);
 
250
    else
 
251
        p.setStyle(Qt::SolidLine);
 
252
    setPen(p);
 
253
}
 
254
 
 
255
/*!
 
256
    \qmlproperty int MapRectangle::zValue
 
257
 
 
258
    This property holds the z-value of the rectangle.
 
259
 
 
260
    Map objects are drawn in z-value order, and objects with the 
 
261
    same z-value will be drawn in insertion order.
 
262
*/
 
263
 
 
264
/*!
 
265
    \qmlproperty bool MapRectangle::visible
 
266
 
 
267
    This property holds a boolean corresponding to whether or not the 
 
268
    rectangle is visible.
 
269
*/
 
270
 
 
271
/*!
 
272
    \qmlproperty bool MapRectangle::selected
 
273
 
 
274
    This property holds a boolean corresponding to whether or not the 
 
275
    rectangle is selected.
 
276
*/
 
277
 
116
278
#include "moc_qdeclarativegeomaprectangleobject_p.cpp"
117
279
 
118
280
QTM_END_NAMESPACE