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

« back to all changes in this revision

Viewing changes to src/location/maps/qgeoroutesegment.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:
8
8
**
9
9
** $QT_BEGIN_LICENSE:LGPL$
10
10
** Commercial Usage
11
 
** Licensees holding valid Qt Commercial licenses may use this file in
12
 
** accordance with the Qt Solutions Commercial License Agreement provided
13
 
** with the Software or, alternatively, in accordance with the terms
 
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
14
** contained in a written agreement between you and Nokia.
15
15
**
16
16
** GNU Lesser General Public License Usage
33
33
** ensure the GNU General Public License version 3.0 requirements will be
34
34
** met: http://www.gnu.org/copyleft/gpl.html.
35
35
**
36
 
** Please note Third Party Software included with Qt Solutions may impose
37
 
** additional restrictions and it is the user's responsibility to ensure
38
 
** that they have met the licensing requirements of the GPL, LGPL, or Qt
39
 
** Solutions Commercial license and the relevant license of the Third
40
 
** Party Software they are using.
41
 
**
42
36
** If you are unsure which license is appropriate for your use, please
43
37
** contact the sales department at qt-sales@nokia.com.
44
38
** $QT_END_LICENSE$
62
56
    \ingroup maps-routing
63
57
 
64
58
    A QGeoRouteSegment instance has information about the physcial layout
65
 
    of the route segment, the length of the route and the estimated time and
66
 
    navigation instructions required to traverse the route segment.
 
59
    of the route segment, the length of the route and estimated time required
 
60
    to traverse the route segment and an optional QGeoManeuver associated with
 
61
    the end of the route segment.
 
62
 
 
63
    QGeoRouteSegment instances can be thought of as edges on a routing
 
64
    graph, with QGeoManeuver instances as optional labels attached to the
 
65
    vertices of the graph.
67
66
*/
68
67
 
69
68
/*!
70
 
    Constructs a route segment object.
 
69
    Constructs an invalid route segment object.
 
70
 
 
71
    The route segment will remain invalid until one of setNextRouteSegment(),
 
72
    setTravelTime(), setDistance(), setPath() or setManeuver() is called.
71
73
*/
72
74
QGeoRouteSegment::QGeoRouteSegment()
73
 
        : d_ptr(new QGeoRouteSegmentPrivate()) {}
 
75
    : d_ptr(new QGeoRouteSegmentPrivate()) {}
74
76
 
75
77
/*!
76
78
    Constructs a route segment object from the contents of \a other.
77
79
*/
78
80
QGeoRouteSegment::QGeoRouteSegment(const QGeoRouteSegment &other)
79
 
        : d_ptr(other.d_ptr) {}
 
81
    : d_ptr(other.d_ptr) {}
 
82
 
 
83
/*!
 
84
    \internal
 
85
*/
 
86
QGeoRouteSegment::QGeoRouteSegment(QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate> &d_ptr)
 
87
    : d_ptr(d_ptr) {}
80
88
 
81
89
/*!
82
90
    Destroys this route segment object.
96
104
 
97
105
/*!
98
106
    Returns whether this route segment and \a other are equal.
 
107
 
 
108
    The value of nextRouteSegment() is not considered in the comparison.
99
109
*/
100
110
bool QGeoRouteSegment::operator ==(const QGeoRouteSegment &other) const
101
111
{
104
114
 
105
115
/*!
106
116
    Returns whether this route segment and \a other are not equal.
 
117
 
 
118
    The value of nextRouteSegment() is not considered in the comparison.
107
119
*/
108
120
bool QGeoRouteSegment::operator !=(const QGeoRouteSegment &other) const
109
121
{
110
 
    return (d_ptr.constData() != other.d_ptr.constData());
 
122
    return !(operator==(other));
 
123
}
 
124
 
 
125
/*!
 
126
    Returns whether this route segment is valid or not.
 
127
 
 
128
    If nextRouteSegment() is called on the last route segment of a route, the
 
129
    returned value will be an invalid route segment.
 
130
*/
 
131
bool QGeoRouteSegment::isValid() const
 
132
{
 
133
    return d_ptr->valid;
 
134
}
 
135
 
 
136
/*!
 
137
    Sets the next route segment in the route to \a routeSegment.
 
138
*/
 
139
void QGeoRouteSegment::setNextRouteSegment(const QGeoRouteSegment &routeSegment)
 
140
{
 
141
    d_ptr->valid = true;
 
142
    d_ptr->nextSegment = routeSegment.d_ptr;
 
143
}
 
144
 
 
145
/*!
 
146
    Returns the next route segment in the route.
 
147
 
 
148
    Will return an invalid route segment if this is the last route
 
149
    segment in the route.
 
150
*/
 
151
QGeoRouteSegment QGeoRouteSegment::nextRouteSegment() const
 
152
{
 
153
    if (d_ptr->valid && d_ptr->nextSegment)
 
154
        return QGeoRouteSegment(d_ptr->nextSegment);
 
155
 
 
156
    QGeoRouteSegment segment;
 
157
    segment.d_ptr->valid = false;
 
158
    return segment;
111
159
}
112
160
 
113
161
/*!
116
164
*/
117
165
void QGeoRouteSegment::setTravelTime(int secs)
118
166
{
 
167
    d_ptr->valid = true;
119
168
    d_ptr->travelTime = secs;
120
169
}
121
170
 
133
182
*/
134
183
void QGeoRouteSegment::setDistance(qreal distance)
135
184
{
 
185
    d_ptr->valid = true;
136
186
    d_ptr->distance = distance;
137
187
}
138
188
 
152
202
*/
153
203
void QGeoRouteSegment::setPath(const QList<QGeoCoordinate> &path)
154
204
{
 
205
    d_ptr->valid = true;
155
206
    d_ptr->path = path;
156
207
}
157
208
 
166
217
{
167
218
    return d_ptr->path;
168
219
}
 
220
 
169
221
/*!
170
 
    Sets the instruction for this route segement to \a instruction.
 
222
    Sets the maneuver for this route segement to \a maneuver.
171
223
*/
172
 
void QGeoRouteSegment::setInstruction(const QGeoInstruction &instruction)
 
224
void QGeoRouteSegment::setManeuver(const QGeoManeuver &maneuver)
173
225
{
174
 
    d_ptr->instruction = instruction;
 
226
    d_ptr->valid = true;
 
227
    d_ptr->maneuver = maneuver;
175
228
}
176
229
 
177
230
/*!
178
 
    Returns the instruction for this route segment.
 
231
    Returns the manevuer for this route segment.
 
232
 
 
233
    Will return an invalid QGeoManeuver if no information has been attached 
 
234
    to the endpoint of this route segment.
179
235
*/
180
 
QGeoInstruction QGeoRouteSegment::instruction() const
 
236
QGeoManeuver QGeoRouteSegment::maneuver() const
181
237
{
182
 
    return d_ptr->instruction;
 
238
    return d_ptr->maneuver;
183
239
}
184
240
 
185
241
/*******************************************************************************
186
242
*******************************************************************************/
187
243
 
188
244
QGeoRouteSegmentPrivate::QGeoRouteSegmentPrivate()
189
 
        : travelTime(0),
190
 
        distance(0.0) {}
 
245
    : valid(true),
 
246
      travelTime(0),
 
247
      distance(0.0) {}
191
248
 
192
249
QGeoRouteSegmentPrivate::QGeoRouteSegmentPrivate(const QGeoRouteSegmentPrivate &other)
193
 
        : QSharedData(other),
194
 
        travelTime(other.travelTime),
195
 
        distance(other.distance),
196
 
        path(other.path),
197
 
        instruction(other.instruction) {}
 
250
    : QSharedData(other),
 
251
      valid(other.valid),
 
252
      travelTime(other.travelTime),
 
253
      distance(other.distance),
 
254
      path(other.path),
 
255
      maneuver(other.maneuver),
 
256
      nextSegment(other.nextSegment) {}
198
257
 
199
 
QGeoRouteSegmentPrivate::~QGeoRouteSegmentPrivate() {}
 
258
QGeoRouteSegmentPrivate::~QGeoRouteSegmentPrivate()
 
259
{
 
260
    nextSegment.reset();
 
261
}
200
262
 
201
263
bool QGeoRouteSegmentPrivate::operator ==(const QGeoRouteSegmentPrivate &other) const
202
264
{
203
 
    return ((travelTime == other.travelTime)
 
265
    return ((valid == other.valid)
 
266
            && (travelTime == other.travelTime)
204
267
            && (distance == other.distance)
205
268
            && (path == other.path)
206
 
            && (instruction == other.instruction));
 
269
            && (maneuver == other.maneuver));
207
270
}
208
271
 
 
272
/*******************************************************************************
 
273
*******************************************************************************/
 
274
 
209
275
QTM_END_NAMESPACE
210
276