Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Itinerary
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
20
Issues
20
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PIM
Itinerary
Commits
e96b5266
Commit
e96b5266
authored
Jan 03, 2019
by
Volker Krause
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support real-time journey data
parent
b6df8957
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
163 additions
and
59 deletions
+163
-59
autotests/navitiaparsertest.cpp
autotests/navitiaparsertest.cpp
+12
-10
src/publictransport/backends/hafasmgateparser.cpp
src/publictransport/backends/hafasmgateparser.cpp
+10
-3
src/publictransport/backends/navitiaparser.cpp
src/publictransport/backends/navitiaparser.cpp
+3
-2
src/publictransport/datatypes/journey.cpp
src/publictransport/datatypes/journey.cpp
+66
-16
src/publictransport/datatypes/journey.h
src/publictransport/datatypes/journey.h
+47
-15
src/publictransport/journeyreply.cpp
src/publictransport/journeyreply.cpp
+5
-5
tests/journeyquery.cpp
tests/journeyquery.cpp
+2
-2
tests/journeyquery.qml
tests/journeyquery.qml
+18
-6
No files found.
autotests/navitiaparsertest.cpp
View file @
e96b5266
...
@@ -49,12 +49,12 @@ private Q_SLOTS:
...
@@ -49,12 +49,12 @@ private Q_SLOTS:
{
{
const
auto
journey
=
res
[
0
];
const
auto
journey
=
res
[
0
];
QCOMPARE
(
journey
.
sections
().
size
(),
6
);
QCOMPARE
(
journey
.
sections
().
size
(),
6
);
QCOMPARE
(
journey
.
d
epartureTime
(),
QDateTime
({
2018
,
12
,
2
},
{
22
,
4
,
51
}));
QCOMPARE
(
journey
.
scheduledD
epartureTime
(),
QDateTime
({
2018
,
12
,
2
},
{
22
,
4
,
51
}));
QEXPECT_FAIL
(
""
,
"tz propagation not implemented yet"
,
Continue
);
QEXPECT_FAIL
(
""
,
"tz propagation not implemented yet"
,
Continue
);
QCOMPARE
(
journey
.
d
epartureTime
().
timeZone
().
id
(),
"Europe/Paris"
);
QCOMPARE
(
journey
.
scheduledD
epartureTime
().
timeZone
().
id
(),
"Europe/Paris"
);
QCOMPARE
(
journey
.
a
rrivalTime
(),
QDateTime
({
2018
,
12
,
2
},
{
23
,
0
,
15
}));
QCOMPARE
(
journey
.
scheduledA
rrivalTime
(),
QDateTime
({
2018
,
12
,
2
},
{
23
,
0
,
15
}));
QEXPECT_FAIL
(
""
,
"tz propagation not implemented yet"
,
Continue
);
QEXPECT_FAIL
(
""
,
"tz propagation not implemented yet"
,
Continue
);
QCOMPARE
(
journey
.
a
rrivalTime
().
timeZone
().
id
(),
"Europe/Paris"
);
QCOMPARE
(
journey
.
scheduledA
rrivalTime
().
timeZone
().
id
(),
"Europe/Paris"
);
QCOMPARE
(
journey
.
duration
(),
3324
);
QCOMPARE
(
journey
.
duration
(),
3324
);
auto
sec
=
journey
.
sections
()[
0
];
auto
sec
=
journey
.
sections
()[
0
];
...
@@ -64,10 +64,12 @@ private Q_SLOTS:
...
@@ -64,10 +64,12 @@ private Q_SLOTS:
sec
=
journey
.
sections
()[
1
];
sec
=
journey
.
sections
()[
1
];
QCOMPARE
(
sec
.
mode
(),
KPublicTransport
::
JourneySection
::
PublicTransport
);
QCOMPARE
(
sec
.
mode
(),
KPublicTransport
::
JourneySection
::
PublicTransport
);
QCOMPARE
(
sec
.
departureTime
(),
QDateTime
({
2018
,
12
,
2
},
{
22
,
6
},
QTimeZone
(
"Europe/Paris"
)));
QCOMPARE
(
sec
.
scheduledDepartureTime
(),
QDateTime
({
2018
,
12
,
2
},
{
22
,
6
},
QTimeZone
(
"Europe/Paris"
)));
QCOMPARE
(
sec
.
departureTime
().
timeZone
().
id
(),
"Europe/Paris"
);
QCOMPARE
(
sec
.
scheduledDepartureTime
().
timeZone
().
id
(),
"Europe/Paris"
);
QCOMPARE
(
sec
.
arrivalTime
(),
QDateTime
({
2018
,
12
,
2
},
{
22
,
41
},
QTimeZone
(
"Europe/Paris"
)));
QCOMPARE
(
sec
.
hasExpectedDepartureTime
(),
false
);
QCOMPARE
(
sec
.
arrivalTime
().
timeZone
().
id
(),
"Europe/Paris"
);
QCOMPARE
(
sec
.
scheduledArrivalTime
(),
QDateTime
({
2018
,
12
,
2
},
{
22
,
41
},
QTimeZone
(
"Europe/Paris"
)));
QCOMPARE
(
sec
.
scheduledArrivalTime
().
timeZone
().
id
(),
"Europe/Paris"
);
QCOMPARE
(
sec
.
hasExpectedArrivalTime
(),
false
);
QCOMPARE
(
sec
.
duration
(),
2100
);
QCOMPARE
(
sec
.
duration
(),
2100
);
QCOMPARE
(
sec
.
from
().
name
(),
QStringLiteral
(
"Aéroport CDG 2 TGV (Le Mesnil-Amelot)"
));
QCOMPARE
(
sec
.
from
().
name
(),
QStringLiteral
(
"Aéroport CDG 2 TGV (Le Mesnil-Amelot)"
));
QCOMPARE
(
sec
.
from
().
latitude
(),
49.0047
f
);
QCOMPARE
(
sec
.
from
().
latitude
(),
49.0047
f
);
...
@@ -88,8 +90,8 @@ private Q_SLOTS:
...
@@ -88,8 +90,8 @@ private Q_SLOTS:
QCOMPARE
(
sec
.
mode
(),
KPublicTransport
::
JourneySection
::
Waiting
);
QCOMPARE
(
sec
.
mode
(),
KPublicTransport
::
JourneySection
::
Waiting
);
sec
=
journey
.
sections
()[
4
];
sec
=
journey
.
sections
()[
4
];
QCOMPARE
(
sec
.
d
epartureTime
(),
QDateTime
({
2018
,
12
,
2
},
{
22
,
49
},
QTimeZone
(
"Europe/Paris"
)));
QCOMPARE
(
sec
.
scheduledD
epartureTime
(),
QDateTime
({
2018
,
12
,
2
},
{
22
,
49
},
QTimeZone
(
"Europe/Paris"
)));
QCOMPARE
(
sec
.
a
rrivalTime
(),
QDateTime
({
2018
,
12
,
2
},
{
22
,
51
},
QTimeZone
(
"Europe/Paris"
)));
QCOMPARE
(
sec
.
scheduledA
rrivalTime
(),
QDateTime
({
2018
,
12
,
2
},
{
22
,
51
},
QTimeZone
(
"Europe/Paris"
)));
QCOMPARE
(
sec
.
duration
(),
120
);
QCOMPARE
(
sec
.
duration
(),
120
);
QCOMPARE
(
sec
.
route
().
line
().
name
(),
QStringLiteral
(
"A"
));
QCOMPARE
(
sec
.
route
().
line
().
name
(),
QStringLiteral
(
"A"
));
QCOMPARE
(
sec
.
route
().
line
().
color
(),
QColor
(
QStringLiteral
(
"#D1302F"
)));
QCOMPARE
(
sec
.
route
().
line
().
color
(),
QColor
(
QStringLiteral
(
"#D1302F"
)));
...
...
src/publictransport/backends/hafasmgateparser.cpp
View file @
e96b5266
...
@@ -270,16 +270,23 @@ std::vector<Journey> HafasMgateParser::parseTripSearch(const QJsonObject &obj) c
...
@@ -270,16 +270,23 @@ std::vector<Journey> HafasMgateParser::parseTripSearch(const QJsonObject &obj) c
const
auto
secObj
=
secV
.
toObject
();
const
auto
secObj
=
secV
.
toObject
();
JourneySection
section
;
JourneySection
section
;
// TODO add real-time data
const
auto
dep
=
secObj
.
value
(
QLatin1String
(
"dep"
)).
toObject
();
const
auto
dep
=
secObj
.
value
(
QLatin1String
(
"dep"
)).
toObject
();
section
.
setDepartureTime
(
QDateTime
::
fromString
(
dateStr
+
dep
.
value
(
QLatin1String
(
"dTimeS"
)).
toString
(),
QLatin1String
(
"yyyyMMddhhmmss"
)));
section
.
setScheduledDepartureTime
(
QDateTime
::
fromString
(
dateStr
+
dep
.
value
(
QLatin1String
(
"dTimeS"
)).
toString
(),
QLatin1String
(
"yyyyMMddhhmmss"
)));
const
auto
dTimeR
=
dep
.
value
(
QLatin1String
(
"dTimeR"
)).
toString
();
if
(
!
dTimeR
.
isEmpty
())
{
section
.
setExpectedDepartureTime
(
QDateTime
::
fromString
(
dateStr
+
dTimeR
,
QLatin1String
(
"yyyyMMddhhmmss"
)));
}
auto
locIdx
=
dep
.
value
(
QLatin1String
(
"locX"
)).
toInt
();
auto
locIdx
=
dep
.
value
(
QLatin1String
(
"locX"
)).
toInt
();
if
((
unsigned
int
)
locIdx
<
locs
.
size
())
{
if
((
unsigned
int
)
locIdx
<
locs
.
size
())
{
section
.
setFrom
(
locs
[
locIdx
]);
section
.
setFrom
(
locs
[
locIdx
]);
}
}
const
auto
arr
=
secObj
.
value
(
QLatin1String
(
"arr"
)).
toObject
();
const
auto
arr
=
secObj
.
value
(
QLatin1String
(
"arr"
)).
toObject
();
section
.
setArrivalTime
(
QDateTime
::
fromString
(
dateStr
+
arr
.
value
(
QLatin1String
(
"aTimeS"
)).
toString
(),
QLatin1String
(
"yyyyMMddhhmmss"
)));
section
.
setScheduledArrivalTime
(
QDateTime
::
fromString
(
dateStr
+
arr
.
value
(
QLatin1String
(
"aTimeS"
)).
toString
(),
QLatin1String
(
"yyyyMMddhhmmss"
)));
const
auto
aTimeR
=
dep
.
value
(
QLatin1String
(
"aTimeR"
)).
toString
();
if
(
!
aTimeR
.
isEmpty
())
{
section
.
setExpectedArrivalTime
(
QDateTime
::
fromString
(
dateStr
+
aTimeR
,
QLatin1String
(
"yyyyMMddhhmmss"
)));
}
locIdx
=
arr
.
value
(
QLatin1String
(
"locX"
)).
toInt
();
locIdx
=
arr
.
value
(
QLatin1String
(
"locX"
)).
toInt
();
if
((
unsigned
int
)
locIdx
<
locs
.
size
())
{
if
((
unsigned
int
)
locIdx
<
locs
.
size
())
{
section
.
setTo
(
locs
[
locIdx
]);
section
.
setTo
(
locs
[
locIdx
]);
...
...
src/publictransport/backends/navitiaparser.cpp
View file @
e96b5266
...
@@ -130,8 +130,9 @@ static JourneySection parseJourneySection(const QJsonObject &obj)
...
@@ -130,8 +130,9 @@ static JourneySection parseJourneySection(const QJsonObject &obj)
section
.
setFrom
(
parseWrappedLocation
(
obj
.
value
(
QLatin1String
(
"from"
)).
toObject
()));
section
.
setFrom
(
parseWrappedLocation
(
obj
.
value
(
QLatin1String
(
"from"
)).
toObject
()));
section
.
setTo
(
parseWrappedLocation
(
obj
.
value
(
QLatin1String
(
"to"
)).
toObject
()));
section
.
setTo
(
parseWrappedLocation
(
obj
.
value
(
QLatin1String
(
"to"
)).
toObject
()));
section
.
setRoute
(
route
);
section
.
setRoute
(
route
);
section
.
setDepartureTime
(
parseDateTime
(
obj
.
value
(
QLatin1String
(
"departure_date_time"
)),
section
.
from
().
timeZone
()));
// TODO realtime data
section
.
setArrivalTime
(
parseDateTime
(
obj
.
value
(
QLatin1String
(
"arrival_date_time"
)),
section
.
to
().
timeZone
()));
section
.
setScheduledArrivalTime
(
parseDateTime
(
obj
.
value
(
QLatin1String
(
"departure_date_time"
)),
section
.
from
().
timeZone
()));
section
.
setScheduledDepartureTime
(
parseDateTime
(
obj
.
value
(
QLatin1String
(
"arrival_date_time"
)),
section
.
to
().
timeZone
()));
const
auto
typeStr
=
obj
.
value
(
QLatin1String
(
"type"
)).
toString
();
const
auto
typeStr
=
obj
.
value
(
QLatin1String
(
"type"
)).
toString
();
if
(
typeStr
==
QLatin1String
(
"public_transport"
))
{
if
(
typeStr
==
QLatin1String
(
"public_transport"
))
{
...
...
src/publictransport/datatypes/journey.cpp
View file @
e96b5266
...
@@ -28,8 +28,10 @@ class JourneySectionPrivate : public QSharedData
...
@@ -28,8 +28,10 @@ class JourneySectionPrivate : public QSharedData
{
{
public:
public:
JourneySection
::
Mode
mode
=
JourneySection
::
Invalid
;
JourneySection
::
Mode
mode
=
JourneySection
::
Invalid
;
QDateTime
departureTime
;
QDateTime
scheduledDepartureTime
;
QDateTime
arrivalTime
;
QDateTime
expectedDepartureTime
;
QDateTime
scheduledArrivalTime
;
QDateTime
expectedArrivalTime
;
Location
from
;
Location
from
;
Location
to
;
Location
to
;
Route
route
;
Route
route
;
...
@@ -56,31 +58,79 @@ void JourneySection::setMode(JourneySection::Mode mode)
...
@@ -56,31 +58,79 @@ void JourneySection::setMode(JourneySection::Mode mode)
d
->
mode
=
mode
;
d
->
mode
=
mode
;
}
}
QDateTime
JourneySection
::
d
epartureTime
()
const
QDateTime
JourneySection
::
scheduledD
epartureTime
()
const
{
{
return
d
->
d
epartureTime
;
return
d
->
scheduledD
epartureTime
;
}
}
void
JourneySection
::
setDepartureTime
(
const
QDateTime
&
dt
)
void
JourneySection
::
set
Scheduled
DepartureTime
(
const
QDateTime
&
dt
)
{
{
d
.
detach
();
d
.
detach
();
d
->
d
epartureTime
=
dt
;
d
->
scheduledD
epartureTime
=
dt
;
}
}
QDateTime
JourneySection
::
arrival
Time
()
const
QDateTime
JourneySection
::
expectedDeparture
Time
()
const
{
{
return
d
->
arrival
Time
;
return
d
->
expectedDeparture
Time
;
}
}
void
JourneySection
::
set
Arrival
Time
(
const
QDateTime
&
dt
)
void
JourneySection
::
set
ExpectedDeparture
Time
(
const
QDateTime
&
dt
)
{
{
d
.
detach
();
d
.
detach
();
d
->
arrivalTime
=
dt
;
d
->
expectedDepartureTime
=
dt
;
}
bool
JourneySection
::
hasExpectedDepartureTime
()
const
{
return
d
->
expectedDepartureTime
.
isValid
();
}
int
JourneySection
::
departureDelay
()
const
{
if
(
hasExpectedDepartureTime
())
{
return
d
->
scheduledDepartureTime
.
secsTo
(
d
->
expectedDepartureTime
)
/
60
;
}
return
0
;
}
QDateTime
JourneySection
::
scheduledArrivalTime
()
const
{
return
d
->
scheduledArrivalTime
;
}
void
JourneySection
::
setScheduledArrivalTime
(
const
QDateTime
&
dt
)
{
d
.
detach
();
d
->
scheduledArrivalTime
=
dt
;
}
QDateTime
JourneySection
::
expectedArrivalTime
()
const
{
return
d
->
expectedArrivalTime
;
}
void
JourneySection
::
setExpectedArrivalTime
(
const
QDateTime
&
dt
)
{
d
.
detach
();
d
->
expectedArrivalTime
=
dt
;
}
bool
JourneySection
::
hasExpectedArrivalTime
()
const
{
return
d
->
expectedArrivalTime
.
isValid
();
}
int
JourneySection
::
arrivalDelay
()
const
{
if
(
hasExpectedArrivalTime
())
{
return
d
->
scheduledArrivalTime
.
secsTo
(
d
->
expectedArrivalTime
)
/
60
;
}
return
0
;
}
}
int
JourneySection
::
duration
()
const
int
JourneySection
::
duration
()
const
{
{
return
d
->
departureTime
.
secsTo
(
d
->
a
rrivalTime
);
return
d
->
scheduledDepartureTime
.
secsTo
(
d
->
scheduledA
rrivalTime
);
}
}
Location
JourneySection
::
from
()
const
Location
JourneySection
::
from
()
const
...
@@ -143,25 +193,25 @@ QVariantList Journey::sectionsVariant() const
...
@@ -143,25 +193,25 @@ QVariantList Journey::sectionsVariant() const
return
l
;
return
l
;
}
}
QDateTime
KPublicTransport
::
Journey
::
d
epartureTime
()
const
QDateTime
Journey
::
scheduledD
epartureTime
()
const
{
{
if
(
!
d
->
sections
.
empty
())
{
if
(
!
d
->
sections
.
empty
())
{
return
d
->
sections
.
front
().
d
epartureTime
();
return
d
->
sections
.
front
().
scheduledD
epartureTime
();
}
}
return
{};
return
{};
}
}
QDateTime
Journey
::
a
rrivalTime
()
const
QDateTime
Journey
::
scheduledA
rrivalTime
()
const
{
{
if
(
!
d
->
sections
.
empty
())
{
if
(
!
d
->
sections
.
empty
())
{
return
d
->
sections
.
back
().
a
rrivalTime
();
return
d
->
sections
.
back
().
scheduledA
rrivalTime
();
}
}
return
{};
return
{};
}
}
int
Journey
::
duration
()
const
int
Journey
::
duration
()
const
{
{
return
departureTime
().
secsTo
(
a
rrivalTime
());
return
scheduledDepartureTime
().
secsTo
(
scheduledA
rrivalTime
());
}
}
#include "moc_journey.cpp"
#include "moc_journey.cpp"
src/publictransport/datatypes/journey.h
View file @
e96b5266
...
@@ -36,12 +36,32 @@ class JourneySection
...
@@ -36,12 +36,32 @@ class JourneySection
KPUBLICTRANSPORT_GADGET
(
JourneySection
)
KPUBLICTRANSPORT_GADGET
(
JourneySection
)
/** Mode of transport for this section. */
/** Mode of transport for this section. */
Q_PROPERTY
(
Mode
mode
READ
mode
WRITE
setMode
)
Q_PROPERTY
(
Mode
mode
READ
mode
WRITE
setMode
)
/** Departue time for this segment. */
Q_PROPERTY
(
QDateTime
departureTime
READ
departureTime
WRITE
setDepartureTime
)
/** Planned departure time. */
/** Arrival time for this segment. */
Q_PROPERTY
(
QDateTime
scheduledDepartureTime
READ
scheduledDepartureTime
WRITE
setScheduledDepartureTime
)
Q_PROPERTY
(
QDateTime
arrivalTime
READ
arrivalTime
WRITE
setArrivalTime
)
/** Actual departure time, if available.
* Set to invalid to indicate real-time data is not available.
*/
Q_PROPERTY
(
QDateTime
expectedDepartureTime
READ
expectedDepartureTime
WRITE
setExpectedDepartureTime
)
/** @c true if this has real-time data. */
Q_PROPERTY
(
bool
hasExpectedDepartureTime
READ
hasExpectedDepartureTime
STORED
false
)
/** Difference to schedule in minutes. */
Q_PROPERTY
(
int
departureDelay
READ
departureDelay
STORED
false
)
/** Planned arrival time. */
Q_PROPERTY
(
QDateTime
scheduledArrivalTime
READ
scheduledArrivalTime
WRITE
setScheduledArrivalTime
)
/** Actual arrival time, if available.
* Set to invalid to indicate real-time data is not available.
*/
Q_PROPERTY
(
QDateTime
expectedArrivalTime
READ
expectedArrivalTime
WRITE
setExpectedArrivalTime
)
/** @c true if this has real-time data. */
Q_PROPERTY
(
bool
hasExpectedArrivalTime
READ
hasExpectedArrivalTime
STORED
false
)
/** Difference to schedule in minutes. */
Q_PROPERTY
(
int
arrivalDelay
READ
arrivalDelay
STORED
false
)
/** Duration of the section in seconds. */
/** Duration of the section in seconds. */
Q_PROPERTY
(
int
duration
READ
duration
STORED
false
)
Q_PROPERTY
(
int
duration
READ
duration
STORED
false
)
/** Departure location of this segment. */
/** Departure location of this segment. */
Q_PROPERTY
(
KPublicTransport
::
Location
from
READ
from
WRITE
setFrom
)
Q_PROPERTY
(
KPublicTransport
::
Location
from
READ
from
WRITE
setFrom
)
/** Arrival location of this segment. */
/** Arrival location of this segment. */
...
@@ -49,7 +69,7 @@ class JourneySection
...
@@ -49,7 +69,7 @@ class JourneySection
/** Route to take on this segment. */
/** Route to take on this segment. */
Q_PROPERTY
(
KPublicTransport
::
Route
route
READ
route
WRITE
setRoute
)
Q_PROPERTY
(
KPublicTransport
::
Route
route
READ
route
WRITE
setRoute
)
// TODO: pla
nned vs. expected times?
// TODO: pla
tforms
public:
public:
/** Mode of transport. */
/** Mode of transport. */
...
@@ -63,11 +83,23 @@ public:
...
@@ -63,11 +83,23 @@ public:
Q_ENUM
(
Mode
)
Q_ENUM
(
Mode
)
Mode
mode
()
const
;
Mode
mode
()
const
;
void
setMode
(
Mode
mode
);
void
setMode
(
Mode
mode
);
QDateTime
departureTime
()
const
;
void
setDepartureTime
(
const
QDateTime
&
dt
);
QDateTime
scheduledDepartureTime
()
const
;
QDateTime
arrivalTime
()
const
;
void
setScheduledDepartureTime
(
const
QDateTime
&
dt
);
void
setArrivalTime
(
const
QDateTime
&
dt
);
QDateTime
expectedDepartureTime
()
const
;
void
setExpectedDepartureTime
(
const
QDateTime
&
dt
);
bool
hasExpectedDepartureTime
()
const
;
int
departureDelay
()
const
;
QDateTime
scheduledArrivalTime
()
const
;
void
setScheduledArrivalTime
(
const
QDateTime
&
dt
);
QDateTime
expectedArrivalTime
()
const
;
void
setExpectedArrivalTime
(
const
QDateTime
&
dt
);
bool
hasExpectedArrivalTime
()
const
;
int
arrivalDelay
()
const
;
int
duration
()
const
;
int
duration
()
const
;
Location
from
()
const
;
Location
from
()
const
;
void
setFrom
(
const
Location
&
from
);
void
setFrom
(
const
Location
&
from
);
Location
to
()
const
;
Location
to
()
const
;
...
@@ -84,10 +116,10 @@ class Journey
...
@@ -84,10 +116,10 @@ class Journey
KPUBLICTRANSPORT_GADGET
(
Journey
)
KPUBLICTRANSPORT_GADGET
(
Journey
)
/** Journey sections for consumption by QML. */
/** Journey sections for consumption by QML. */
Q_PROPERTY
(
QVariantList
sections
READ
sectionsVariant
)
Q_PROPERTY
(
QVariantList
sections
READ
sectionsVariant
)
/** Departure time of the journey. */
/** Departure time of the journey
, according to schedule
. */
Q_PROPERTY
(
QDateTime
departureTime
READ
d
epartureTime
STORED
false
)
Q_PROPERTY
(
QDateTime
scheduledDepartureTime
READ
scheduledD
epartureTime
STORED
false
)
/** Arrival time of the journey. */
/** Arrival time of the journey
, according to schedule
. */
Q_PROPERTY
(
QDateTime
arrivalTime
READ
a
rrivalTime
STORED
false
)
Q_PROPERTY
(
QDateTime
scheduledArrivalTime
READ
scheduledA
rrivalTime
STORED
false
)
/** Duration of the entire journey in seconds. */
/** Duration of the entire journey in seconds. */
Q_PROPERTY
(
int
duration
READ
duration
STORED
false
)
Q_PROPERTY
(
int
duration
READ
duration
STORED
false
)
public:
public:
...
@@ -98,8 +130,8 @@ public:
...
@@ -98,8 +130,8 @@ public:
/** Sets the journey sections. */
/** Sets the journey sections. */
void
setSections
(
std
::
vector
<
JourneySection
>
&&
sections
);
void
setSections
(
std
::
vector
<
JourneySection
>
&&
sections
);
QDateTime
d
epartureTime
()
const
;
QDateTime
scheduledD
epartureTime
()
const
;
QDateTime
a
rrivalTime
()
const
;
QDateTime
scheduledA
rrivalTime
()
const
;
int
duration
()
const
;
int
duration
()
const
;
private:
private:
QVariantList
sectionsVariant
()
const
;
QVariantList
sectionsVariant
()
const
;
...
...
src/publictransport/journeyreply.cpp
View file @
e96b5266
...
@@ -50,7 +50,7 @@ void JourneyReplyPrivate::finalizeResult()
...
@@ -50,7 +50,7 @@ void JourneyReplyPrivate::finalizeResult()
postProcessJourneys
();
postProcessJourneys
();
std
::
sort
(
journeys
.
begin
(),
journeys
.
end
(),
[](
const
auto
&
lhs
,
const
auto
&
rhs
)
{
std
::
sort
(
journeys
.
begin
(),
journeys
.
end
(),
[](
const
auto
&
lhs
,
const
auto
&
rhs
)
{
return
lhs
.
departureTime
()
<
rhs
.
d
epartureTime
();
return
lhs
.
scheduledDepartureTime
()
<
rhs
.
scheduledD
epartureTime
();
});
});
}
}
...
@@ -65,17 +65,17 @@ void JourneyReplyPrivate::postProcessJourneys()
...
@@ -65,17 +65,17 @@ void JourneyReplyPrivate::postProcessJourneys()
auto
from
=
section
.
from
();
auto
from
=
section
.
from
();
from
.
setTimeZone
(
section
.
to
().
timeZone
());
from
.
setTimeZone
(
section
.
to
().
timeZone
());
section
.
setFrom
(
from
);
section
.
setFrom
(
from
);
auto
dt
=
section
.
d
epartureTime
();
auto
dt
=
section
.
scheduledD
epartureTime
();
dt
.
setTimeZone
(
from
.
timeZone
());
dt
.
setTimeZone
(
from
.
timeZone
());
section
.
setDepartureTime
(
dt
);
section
.
set
Scheduled
DepartureTime
(
dt
);
}
}
if
(
section
.
from
().
timeZone
().
isValid
()
&&
!
section
.
to
().
timeZone
().
isValid
())
{
if
(
section
.
from
().
timeZone
().
isValid
()
&&
!
section
.
to
().
timeZone
().
isValid
())
{
auto
to
=
section
.
to
();
auto
to
=
section
.
to
();
to
.
setTimeZone
(
section
.
from
().
timeZone
());
to
.
setTimeZone
(
section
.
from
().
timeZone
());
section
.
setTo
(
to
);
section
.
setTo
(
to
);
auto
dt
=
section
.
a
rrivalTime
();
auto
dt
=
section
.
scheduledA
rrivalTime
();
dt
.
setTimeZone
(
to
.
timeZone
());
dt
.
setTimeZone
(
to
.
timeZone
());
section
.
setArrivalTime
(
dt
);
section
.
set
Scheduled
ArrivalTime
(
dt
);
}
}
}
}
}
}
...
...
tests/journeyquery.cpp
View file @
e96b5266
...
@@ -73,9 +73,9 @@ public:
...
@@ -73,9 +73,9 @@ public:
for
(
const
auto
&
journey
:
res
)
{
for
(
const
auto
&
journey
:
res
)
{
qDebug
()
<<
journey
.
sections
().
size
();
qDebug
()
<<
journey
.
sections
().
size
();
for
(
const
auto
&
section
:
journey
.
sections
())
{
for
(
const
auto
&
section
:
journey
.
sections
())
{
qDebug
()
<<
" From"
<<
section
.
from
().
name
()
<<
section
.
d
epartureTime
();
qDebug
()
<<
" From"
<<
section
.
from
().
name
()
<<
section
.
scheduledD
epartureTime
();
qDebug
()
<<
" Mode"
<<
section
.
mode
()
<<
section
.
route
().
line
().
name
()
<<
section
.
route
().
direction
()
<<
section
.
route
().
line
().
modeString
();
qDebug
()
<<
" Mode"
<<
section
.
mode
()
<<
section
.
route
().
line
().
name
()
<<
section
.
route
().
direction
()
<<
section
.
route
().
line
().
modeString
();
qDebug
()
<<
" To"
<<
section
.
to
().
name
()
<<
section
.
a
rrivalTime
();
qDebug
()
<<
" To"
<<
section
.
to
().
name
()
<<
section
.
scheduledA
rrivalTime
();
}
}
}
}
}
else
{
}
else
{
...
...
tests/journeyquery.qml
View file @
e96b5266
...
@@ -170,10 +170,16 @@ Kirigami.ApplicationWindow {
...
@@ -170,10 +170,16 @@ Kirigami.ApplicationWindow {
text
:
"
From:
"
+
modelData
.
from
.
name
text
:
"
From:
"
+
modelData
.
from
.
name
}
}
// TODO platform
// TODO platform
QQC2.Label
{
RowLayout
{
text
:
"
Departure:
"
+
modelData
.
departureTime
.
toTimeString
()
QQC2.Label
{
text
:
"
Departure:
"
+
modelData
.
scheduledDepartureTime
.
toTimeString
()
}
QQC2.Label
{
text
:
(
modelData
.
departureDelay
>=
0
?
"
+
"
:
""
)
+
modelData
.
departureDelay
color
:
modelData
.
departureDelay
>
1
?
Kirigami
.
Theme
.
negativeTextColor
:
Kirigami
.
Theme
.
positiveTextColor
visible
:
modelData
.
hasExpectedDepartureTime
}
}
}
// TODO departure delay
QQC2.Label
{
QQC2.Label
{
text
:
{
text
:
{
switch
(
modelData
.
mode
)
{
switch
(
modelData
.
mode
)
{
...
@@ -193,10 +199,16 @@ Kirigami.ApplicationWindow {
...
@@ -193,10 +199,16 @@ Kirigami.ApplicationWindow {
text
:
"
To:
"
+
modelData
.
to
.
name
text
:
"
To:
"
+
modelData
.
to
.
name
}
}
// TODO platform
// TODO platform
QQC2.Label
{
RowLayout
{
text
:
"
Arrival:
"
+
modelData
.
arrivalTime
.
toTimeString
()
QQC2.Label
{
text
:
"
Arrival:
"
+
modelData
.
scheduledArrivalTime
.
toTimeString
()
}
QQC2.Label
{
text
:
(
modelData
.
arrivalDelay
>=
0
?
"
+
"
:
""
)
+
modelData
.
arrivalDelay
color
:
modelData
.
arrivalDelay
>
1
?
Kirigami
.
Theme
.
negativeTextColor
:
Kirigami
.
Theme
.
positiveTextColor
visible
:
modelData
.
hasExpectedArrivalTime
}
}
}
// TODO arrival delay
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment