Commit 9d14738b authored by Volker Krause's avatar Volker Krause
Browse files

Split the alternative connection specifics out of JourneyQueryPage

This should enable reuse of JourneyQueryPage for adding new timeline
elements from arbitrary journey queries.
parent 46534891
/*
SPDX-FileCopyrightText: 2019-2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami 2.17 as Kirigami
import org.kde.kpublictransport 1.0
import org.kde.itinerary 1.0
import "." as App
App.JourneyQueryPage {
id: root
property QtObject controller;
title: i18n("Alternative Connections")
journeyRequest: controller.journeyRequest
onJourneyChanged: replaceWarningSheet.sheetOpen = true
Kirigami.OverlaySheet {
id: replaceWarningSheet
header: Kirigami.Heading {
text: i18n("Replace Journey")
}
QQC2.Label {
text: i18n("Do you really want to replace your existing reservation with the newly selected journey?")
wrapMode: Text.WordWrap
}
footer: RowLayout {
QQC2.Button {
Layout.alignment: Qt.AlignHCenter
text: i18n("Replace")
icon.name: "document-save"
onClicked: {
controller.applyJourney(root.journey);
applicationWindow().pageStack.pop();
}
}
}
}
}
......@@ -18,7 +18,7 @@ App.DetailsPage {
Component {
id: alternativePage
App.JourneyQueryPage {
App.AlternativeJourneyPage {
controller: root.controller
publicTransportManager: LiveDataManager.publicTransportManager
}
......
/*
SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
SPDX-FileCopyrightText: 2019-2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami 2.17 as Kirigami
import org.kde.kpublictransport 1.0
import org.kde.itinerary 1.0
import "." as App
Kirigami.ScrollablePage {
property QtObject controller;
id: root
/** The journey selected by the user on this page. */
property var journey
/** The journey to query for. */
property alias journeyRequest: journeyModel.request
property alias publicTransportManager: journeyModel.manager
id: root
title: i18n("Alternative Connections")
contextualActions: [
Kirigami.Action {
text: i18n("Earlier")
......@@ -36,7 +39,6 @@ Kirigami.ScrollablePage {
JourneyQueryModel {
id: journeyModel
request: controller.journeyRequest
}
SortFilterProxyModel {
......@@ -74,13 +76,10 @@ Kirigami.ScrollablePage {
width: parent.width
}
QQC2.Button {
text: i18n("Save")
text: i18n("Select")
icon.name: "document-save";
visible: journeyView.currentIndex == index
onClicked: {
replaceWarningSheet.journey = journey
replaceWarningSheet.sheetOpen = true
}
onClicked: root.journey = journey
}
}
......@@ -90,28 +89,6 @@ Kirigami.ScrollablePage {
}
}
Kirigami.OverlaySheet {
id: replaceWarningSheet
property var journey
QQC2.Label {
text: i18n("Do you really want to replace your existing reservation with the newly selected journey?")
wrapMode: Text.WordWrap
}
footer: RowLayout {
QQC2.Button {
Layout.alignment: Qt.AlignHCenter
text: i18n("Replace")
icon.name: "edit-save"
onClicked: {
controller.applyJourney(replaceWarningSheet.journey);
applicationWindow().pageStack.pop();
}
}
}
}
Kirigami.CardsListView {
id: journeyView
anchors.fill: parent
......
......@@ -33,7 +33,7 @@ App.DetailsPage {
Component {
id: alternativePage
App.JourneyQueryPage {
App.AlternativeJourneyPage {
controller: root.controller
publicTransportManager: LiveDataManager.publicTransportManager
}
......
......@@ -8,6 +8,7 @@
<file>main.qml</file>
<file>AboutPage.qml</file>
<file>AlternativeJourneyPage.qml</file>
<file>BarcodeScanModeController.qml</file>
<file>BoardingPass.qml</file>
<file>BusDelegate.qml</file>
......
......@@ -25,11 +25,6 @@ Kirigami.ApplicationWindow {
allowInsecureBackends: true
}
QtObject {
id: dummyController
property var journeyRequest: _request
}
Component {
id: journeySectionPage
App.JourneySectionPage {}
......@@ -42,7 +37,8 @@ Kirigami.ApplicationWindow {
Component {
id: jnyQueryPage
App.JourneyQueryPage {
controller: dummyController
title: "Journey Query"
journeyRequest: _request
publicTransportManager: ptMgr
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment