Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
Itinerary
Commits
514138ac
Commit
514138ac
authored
Dec 25, 2018
by
Volker Krause
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add de/serialization methods for Departure
parent
4e45b010
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
src/publictransport/datatypes/departure.cpp
src/publictransport/datatypes/departure.cpp
+17
-0
src/publictransport/datatypes/departure.h
src/publictransport/datatypes/departure.h
+7
-2
No files found.
src/publictransport/datatypes/departure.cpp
View file @
514138ac
...
...
@@ -17,6 +17,7 @@
#include "departure.h"
#include "datatypes_p.h"
#include "json.h"
#include <QDateTime>
...
...
@@ -193,4 +194,20 @@ Departure Departure::merge(const Departure &lhs, const Departure &rhs)
return
dep
;
}
QJsonObject
Departure
::
toJson
(
const
Departure
&
dep
)
{
auto
obj
=
Json
::
toJson
(
dep
);
// obj.insert(QLatin1String("route"), Route::toJson(dep.route());
obj
.
insert
(
QLatin1String
(
"stopPoint"
),
Location
::
toJson
(
dep
.
stopPoint
()));
return
obj
;
}
Departure
Departure
::
fromJson
(
const
QJsonObject
&
obj
)
{
auto
dep
=
Json
::
fromJson
<
Departure
>
(
obj
);
// dep.setRoute(Route::fromJson(obj.value(QLatin1String("route")).toObject()));
dep
.
setStopPoint
(
Location
::
fromJson
(
obj
.
value
(
QLatin1String
(
"stopPoint"
)).
toObject
()));
return
dep
;
}
#include "moc_departure.cpp"
src/publictransport/datatypes/departure.h
View file @
514138ac
...
...
@@ -42,7 +42,7 @@ class Departure
/** @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
)
Q_PROPERTY
(
int
arrivalDelay
READ
arrivalDelay
STORED
false
)
/** Planned departure time. */
Q_PROPERTY
(
QDateTime
scheduledDepartureTime
READ
scheduledDepartureTime
WRITE
setScheduledDepartureTime
)
...
...
@@ -53,7 +53,7 @@ class Departure
/** @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
)
Q_PROPERTY
(
int
departureDelay
READ
departureDelay
STORED
false
)
/** Planned departure platform. */
Q_PROPERTY
(
QString
scheduledPlatform
READ
scheduledPlatform
WRITE
setScheduledPlatform
)
...
...
@@ -101,6 +101,11 @@ public:
* This assumes isSame(lhs, rhs) and tries to preserve the most detailed information.
*/
static
Departure
merge
(
const
Departure
&
lhs
,
const
Departure
&
rhs
);
/** Serializes one object to JSON. */
static
QJsonObject
toJson
(
const
Departure
&
dep
);
/** Deserialize an object from JSON. */
static
Departure
fromJson
(
const
QJsonObject
&
obj
);
};
}
...
...
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