Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Libraries
KPublicTransport
Commits
4212069e
Commit
4212069e
authored
Jun 09, 2021
by
Volker Krause
Browse files
Also allow to save the results in the location query example
Useful for debugging.
parent
af66c29c
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/lib/models/locationquerymodel.cpp
View file @
4212069e
...
...
@@ -162,4 +162,10 @@ QHash<int, QByteArray> LocationQueryModel::roleNames() const
return
r
;
}
const
std
::
vector
<
Location
>&
LocationQueryModel
::
locations
()
const
{
Q_D
(
const
LocationQueryModel
);
return
d
->
m_locations
;
}
#include "moc_locationquerymodel.moc"
src/lib/models/locationquerymodel.h
View file @
4212069e
...
...
@@ -43,6 +43,9 @@ public:
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
override
;
QHash
<
int
,
QByteArray
>
roleNames
()
const
override
;
/** The current model content. */
const
std
::
vector
<
Location
>&
locations
()
const
;
Q_SIGNALS:
void
requestChanged
();
...
...
tests/exampleutil.h
View file @
4212069e
...
...
@@ -10,6 +10,7 @@
#include <KPublicTransport/Journey>
#include <KPublicTransport/JourneyQueryModel>
#include <KPublicTransport/Location>
#include <KPublicTransport/LocationQueryModel>
#include <KPublicTransport/Stopover>
#include <KPublicTransport/StopoverQueryModel>
...
...
@@ -38,6 +39,8 @@ public:
f
.
write
(
QJsonDocument
(
Journey
::
toJson
(
qobject_cast
<
JourneyQueryModel
*>
(
model
)
->
journeys
())).
toJson
());
}
else
if
(
qobject_cast
<
StopoverQueryModel
*>
(
model
))
{
f
.
write
(
QJsonDocument
(
Stopover
::
toJson
(
qobject_cast
<
StopoverQueryModel
*>
(
model
)
->
departures
())).
toJson
());
}
else
if
(
qobject_cast
<
LocationQueryModel
*>
(
model
))
{
f
.
write
(
QJsonDocument
(
Location
::
toJson
(
qobject_cast
<
LocationQueryModel
*>
(
model
)
->
locations
())).
toJson
());
}
}
...
...
tests/locationquery.qml
View file @
4212069e
...
...
@@ -7,6 +7,7 @@
import
QtQuick
2.5
import
QtQuick
.
Layouts
1.1
import
QtQuick
.
Controls
2.1
as
QQC2
import
Qt
.
labs
.
platform
1.0
as
Platform
import
Qt
.
labs
.
settings
1.0
import
org
.
kde
.
kirigami
2.12
as
Kirigami
import
org
.
kde
.
kpublictransport
1.0
...
...
@@ -44,6 +45,11 @@ Kirigami.ApplicationWindow {
globalDrawer
:
Kirigami.GlobalDrawer
{
actions
:
[
Kirigami.Action
{
text
:
"
Save...
"
iconName
:
"
document-save
"
onTriggered
:
fileDialog
.
open
();
},
Kirigami.Action
{
iconName
:
"
help-about-symbolic
"
text
:
"
Data Sources
"
...
...
@@ -58,6 +64,14 @@ Kirigami.ApplicationWindow {
]
}
Platform.FileDialog
{
id
:
fileDialog
title
:
"
Save Departure Data
"
fileMode
:
Platform
.
FileDialog
.
SaveFile
nameFilters
:
[
"
JSON files (*.json)
"
]
onAccepted
:
ExampleUtil
.
saveTo
(
locationModel
,
fileDialog
.
file
);
}
function
vehicleTypeIcon
(
type
)
{
switch
(
type
)
{
...
...
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