Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qgeoroute.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qgeoroute.h"
5#include "qgeoroute_p.h"
6
7#include "qgeorectangle.h"
8#include "qgeoroutesegment.h"
9
10#include <QDateTime>
11#include <QVariantMap>
12
14
16
17
74 : d_ptr(new QGeoRoutePrivate())
75{}
76
80QExplicitlySharedDataPointer<QGeoRoutePrivate> &QGeoRoute::d()
81{
82 return d_ptr;
83}
84
85const QExplicitlySharedDataPointer<QGeoRoutePrivate> &QGeoRoute::const_d() const
86{
87 return d_ptr;
88}
89
93QGeoRoute::QGeoRoute(const QGeoRoute &other) noexcept = default;
94
98QGeoRoute::~QGeoRoute() = default;
99
105{
106 if (this == &other)
107 return *this;
108
109 d_ptr = other.d_ptr;
110 return *this;
111}
112
125bool QGeoRoute::isEqual(const QGeoRoute &other) const noexcept
126{
127 return ( (d_ptr.constData() == other.d_ptr.constData())
128 || (*d_ptr) == (*other.d_ptr));
129}
130
131
142{
143 d_ptr->setId(id);
144}
145
147{
148 return d_ptr->id();
149}
150
161
163{
164 return d_ptr->request();
165}
166
178{
179 d_ptr->setBounds(bounds);
180}
181
183{
184 return d_ptr->bounds();
185}
186
191{
192 d_ptr->setFirstSegment(routeSegment);
193}
194
205{
206 return d_ptr->firstSegment();
207}
208
224{
225 return d_ptr->segmentsCount();
226}
227
244QList<QGeoRouteSegment> QGeoRoute::segments() const
245{
246 return d_ptr->segments();
247}
248
262{
263 d_ptr->setTravelTime(secs);
264}
265
267{
268 return d_ptr->travelTime();
269}
270
285
287{
288 return d_ptr->distance();
289}
290
300
307{
308 return d_ptr->travelMode();
309}
310
332void QGeoRoute::setPath(const QList<QGeoCoordinate> &path)
333{
334 d_ptr->setPath(path);
335}
336
337
338QList<QGeoCoordinate> QGeoRoute::path() const
339{
340 return d_ptr->path();
341}
342
360void QGeoRoute::setRouteLegs(const QList<QGeoRoute> &legs)
361{
362 d_ptr->setRouteLegs(legs);
363}
364
365QList<QGeoRoute> QGeoRoute::routeLegs() const
366{
367 return d_ptr->routeLegs();
368}
369
370
393void QGeoRoute::setExtendedAttributes(const QVariantMap &extendedAttributes)
394{
396}
397
399{
400 return d_ptr->extendedAttributes();
401}
402
421{
422 d()->setLegIndex(idx);
423}
424
426{
427 return const_d()->legIndex();
428}
429
444{
445 d()->setContainingRoute(route);
446}
447
449{
450 return const_d()->containingRoute();
451}
452
453/*******************************************************************************
454*******************************************************************************/
455
457{
458 return equals(other);
459}
460
462{
463 // here both routes are of type QGeoRoutePrivate
465 QGeoRouteSegment s2 = other.firstSegment();
466
467 while (true) {
468 if (s1.isValid() != s2.isValid())
469 return false;
470 if (!s1.isValid())
471 break;
472 if (s1 != s2)
473 return false;
474 s1 = s1.nextRouteSegment();
475 s2 = s2.nextRouteSegment();
476 }
477
478 return id() == other.id()
479 && request() == other.request()
480 && bounds() == other.bounds()
481 && travelTime() == other.travelTime()
482 && distance() == other.distance()
483 && travelMode() == other.travelMode()
484 && path() == other.path()
485 && routeLegs() == other.routeLegs()
486 && extendedAttributes() == other.extendedAttributes();
487}
488
490{
491 m_id = id;
492}
493
495{
496 return m_id;
497}
498
500{
501 m_request = request;
502}
503
505{
506 return m_request;
507}
508
510{
511 m_bounds = bounds;
512}
513
515{
516 return m_bounds;
517}
518
520{
521 m_travelTime = travelTime;
522}
523
525{
526 return m_travelTime;
527}
528
530{
531 m_distance = distance;
532}
533
535{
536 return m_distance;
537}
538
543
545{
546 return m_travelMode;
547}
548
549void QGeoRoutePrivate::setPath(const QList<QGeoCoordinate> &path)
550{
551 m_path = path;
552}
553
554QList<QGeoCoordinate> QGeoRoutePrivate::path() const
555{
556 return m_path;
557}
558
560{
561 m_firstSegment = firstSegment;
562 m_numSegments = -1;
563}
564
566{
567 return m_firstSegment;
568}
569
571{
572 if (m_numSegments >= 0)
573 return m_numSegments;
574
575 int count = 0;
576 forEachSegment([&count](const QGeoRouteSegment &){
577 ++count;
578 });
579 m_numSegments = count;
580 return count;
581}
582
583QList<QGeoRouteSegment> QGeoRoutePrivate::segments() const
584{
585 QList<QGeoRouteSegment> segments;
586 forEachSegment([&segments](const QGeoRouteSegment &segment){
587 segments.append(segment);
588 });
589 return segments;
590}
591
592void QGeoRoutePrivate::setRouteLegs(const QList<QGeoRoute> &legs)
593{
594 m_legs = legs;
595}
596
597QList<QGeoRoute> QGeoRoutePrivate::routeLegs() const
598{
599 return m_legs;
600}
601
603{
604 m_extendedAttributes = extendedAttributes;
605}
606
608{
609 return m_extendedAttributes;
610}
611
613{
614 if (idx >= 0)
615 m_legIndex = idx;
616}
617
619{
620 return m_legIndex;
621}
622
624{
625 m_containingRoute.reset(new QGeoRoute(route));
626}
627
629{
630 if (m_containingRoute)
631 return *m_containingRoute;
632 return QGeoRoute();
633}
634
636
637#include "moc_qgeoroute.cpp"
\inmodule QtPositioning
QGeoRoute containingRoute() const
void setLegIndex(int idx)
QVariantMap extendedAttributes() const
void setTravelTime(int travelTime)
QGeoRouteSegment firstSegment() const
void setDistance(qreal distance)
void setTravelMode(QGeoRouteRequest::TravelMode mode)
QGeoRouteRequest request() const
bool operator==(const QGeoRoutePrivate &other) const
int segmentsCount() const
void setRouteLegs(const QList< QGeoRoute > &legs)
void setBounds(const QGeoRectangle &bounds)
void setId(const QString &id)
QList< QGeoRoute > routeLegs() const
void setFirstSegment(const QGeoRouteSegment &firstSegment)
bool equals(const QGeoRoutePrivate &other) const
QGeoRouteRequest::TravelMode travelMode() const
QGeoRectangle bounds() const
void setExtendedAttributes(const QVariantMap &extendedAttributes)
QString id() const
QList< QGeoCoordinate > path() const
int legIndex() const
void setPath(const QList< QGeoCoordinate > &path)
void setContainingRoute(const QGeoRoute &route)
qreal distance() const
void setRequest(const QGeoRouteRequest &request)
QList< QGeoRouteSegment > segments() const
int travelTime() const
\inmodule QtLocation
TravelMode
Defines modes of travel to be used for a route.
\inmodule QtLocation
\inmodule QtLocation
Definition qgeoroute.h:24
void setOverallRoute(const QGeoRoute &route)
const QExplicitlySharedDataPointer< QGeoRoutePrivate > & const_d() const
Definition qgeoroute.cpp:85
QList< QGeoCoordinate > path
\qmlproperty list<coordinate> QtLocation::route::path
Definition qgeoroute.h:33
QVariantMap extendedAttributes
\qmlproperty Object route::extendedAttributes
Definition qgeoroute.h:35
void setRouteId(const QString &id)
QList< QGeoRouteSegment > segments
\qmlproperty list<routeSegment> QtLocation::route::segments
Definition qgeoroute.h:39
void setLegIndex(int idx)
QGeoRouteRequest request() const
the route request which describes the criteria used in the calculation of this route
void setRequest(const QGeoRouteRequest &request)
QGeoRoute overallRoute
\qmlproperty Route QtLocation::route::overallRoute
Definition qgeoroute.h:37
QGeoRouteSegment firstRouteSegment() const
Returns the first route segment in the route.
QGeoRoute()
\qmlvaluetype route \inqmlmodule QtLocation
Definition qgeoroute.cpp:73
QGeoRectangle bounds
\qmlproperty georectangle QtLocation::route::bounds
Definition qgeoroute.h:30
qreal distance
\qmlproperty real QtLocation::route::distance
Definition qgeoroute.h:32
qsizetype segmentsCount
\qmlmethod int QtLocation::route::segmentsCount()
Definition qgeoroute.h:38
QGeoRoute & operator=(const QGeoRoute &other) noexcept
Assigns the contents of other to this route and returns a reference to this route.
void setFirstRouteSegment(const QGeoRouteSegment &routeSegment)
Sets the first route segment in the route to routeSegment.
QExplicitlySharedDataPointer< QGeoRoutePrivate > & d()
Returns the private implementation.
Definition qgeoroute.cpp:80
void setDistance(qreal distance)
QList< QGeoRoute > routeLegs
\qmlproperty list<route> QtLocation::route::legs
Definition qgeoroute.h:34
void setTravelTime(int secs)
void setTravelMode(QGeoRouteRequest::TravelMode mode)
Sets the travel mode for this route to mode.
void setPath(const QList< QGeoCoordinate > &path)
QGeoRouteRequest::TravelMode travelMode() const
Returns the travel mode for the this route.
~QGeoRoute()
Destroys this route object.
void setRouteLegs(const QList< QGeoRoute > &legs)
void setBounds(const QGeoRectangle &bounds)
void setExtendedAttributes(const QVariantMap &extendedAttributes)
int travelTime
\qmlproperty int QtLocation::route::travelTime
Definition qgeoroute.h:31
int legIndex
\qmlproperty int QtLocation::route::legIndex
Definition qgeoroute.h:36
QML_STRUCTURED_VALUEQString routeId
the identifier of this route
Definition qgeoroute.h:29
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
GLenum mode
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GLenum GLenum GLsizei count
GLsizei GLsizei GLfloat distance
GLuint segment
GLsizei const GLchar *const * path
GLuint segments
#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class)
#define s2
ptrdiff_t qsizetype
Definition qtypes.h:165
double qreal
Definition qtypes.h:187
QSharedPointer< T > other(t)
[5]
QNetworkRequest request(url)