Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Utilities
KTrip
Commits
65d1935d
Commit
65d1935d
authored
Jul 28, 2019
by
Nicolas Fella
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add version information to cache
parent
a144293d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
src/locationcache.cpp
src/locationcache.cpp
+6
-2
No files found.
src/locationcache.cpp
View file @
65d1935d
...
...
@@ -58,7 +58,11 @@ void LocationCache::addCachedLocation(const KPublicTransport::Location location)
m_cachedLocations
.
append
(
QVariant
::
fromValue
(
location
));
m_cachedLocationsJson
.
append
(
KPublicTransport
::
Location
::
toJson
(
location
));
QJsonDocument
doc
(
m_cachedLocationsJson
);
QJsonObject
obj
;
obj
[
QStringLiteral
(
"version"
)]
=
1
;
obj
[
QStringLiteral
(
"locations"
)]
=
m_cachedLocationsJson
;
QJsonDocument
doc
(
obj
);
m_locationCacheFile
.
resize
(
0
);
m_locationCacheFile
.
write
(
doc
.
toJson
());
...
...
@@ -67,7 +71,7 @@ void LocationCache::addCachedLocation(const KPublicTransport::Location location)
void
LocationCache
::
loadLocationsFromCache
()
{
m_cachedLocationsJson
=
QJsonDocument
::
fromJson
(
m_locationCacheFile
.
readAll
()).
a
rray
();
m_cachedLocationsJson
=
QJsonDocument
::
fromJson
(
m_locationCacheFile
.
readAll
()).
object
()[
QStringLiteral
(
"locations"
)].
toA
rray
();
for
(
const
QJsonValue
&
val
:
qAsConst
(
m_cachedLocationsJson
))
{
m_cachedLocations
.
append
(
QVariant
::
fromValue
(
KPublicTransport
::
Location
::
fromJson
(
val
.
toObject
())));
...
...
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