Commit db3f0865 authored by Nicolas Fella's avatar Nicolas Fella

Add departure query mode

parent 76e159a3
......@@ -20,6 +20,8 @@
#include "formatter.h"
#include <QDateTime>
QString Formatter::formatDuration(int seconds)
{
const int minutes = seconds / 60;
......@@ -31,3 +33,8 @@ QString Formatter::formatDuration(int seconds)
return QString::number(hours) + QStringLiteral(":") + minutesString;
}
QString Formatter::formatTime(const QDateTime& time)
{
return time.toString(QStringLiteral("hh:mm"));
}
......@@ -29,5 +29,6 @@ class Formatter : public QObject
public:
Q_INVOKABLE QString formatDuration(int seconds);
Q_INVOKABLE QString formatTime(const QDateTime &time);
};
......@@ -22,7 +22,6 @@ import QtQuick 2.2
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.4
import org.kde.kirigami 2.4 as Kirigami
import org.kde.ktrip 0.1
import org.kde.kpublictransport 1.0
Kirigami.Page
......
......@@ -22,7 +22,6 @@ import QtQuick 2.2
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.4
import org.kde.kirigami 2.4 as Kirigami
import org.kde.ktrip 0.1
import org.kde.kpublictransport 1.0 as KPT
Kirigami.Page
......
......@@ -22,7 +22,6 @@ import QtQuick 2.2
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.4
import org.kde.kirigami 2.8 as Kirigami
import org.kde.ktrip 0.1
import org.kde.kpublictransport 1.0 as KPT
Kirigami.Page
......
......@@ -27,5 +27,19 @@ Kirigami.ApplicationWindow
width: 480
height: 720
pageStack.initialPage: Qt.resolvedUrl("StartPage.qml")
pageStack.initialPage: Qt.resolvedUrl("JourneyQueryPage.qml")
globalDrawer: Kirigami.GlobalDrawer {
actions: [
Kirigami.Action {
text: i18n("Journey")
onTriggered: pageStack.initialPage = Qt.resolvedUrl("JourneyQueryPage.qml")
},
Kirigami.Action {
text: i18n("Departures")
onTriggered: pageStack.initialPage = Qt.resolvedUrl("DepartureQueryPage.qml")
}
]
}
k
}
......@@ -101,3 +101,12 @@ KPublicTransport::LocationRequest QueryController::createLocationRequest(const Q
return req;
}
KPublicTransport::DepartureRequest QueryController::createDepartureRequest()
{
KPublicTransport::DepartureRequest req;
req.setStop(m_start);
QDateTime depTime = QDateTime::fromString(m_departureDate + QStringLiteral("T") + m_departureTime, Qt::ISODate);
req.setDateTime(depTime);
return req;
}
......@@ -26,6 +26,7 @@
#include <KPublicTransport/Location>
#include <KPublicTransport/LocationRequest>
#include <KPublicTransport/JourneyRequest>
#include <KPublicTransport/DepartureRequest>
class QueryController : public QObject
{
......@@ -53,6 +54,7 @@ public:
Q_INVOKABLE KPublicTransport::JourneyRequest createJourneyRequest();
Q_INVOKABLE KPublicTransport::LocationRequest createLocationRequest(const QString name);
Q_INVOKABLE KPublicTransport::DepartureRequest createDepartureRequest();
Q_SIGNALS:
void startChanged();
......
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>qml/main.qml</file>
<file>qml/StartPage.qml</file>
<file>qml/JourneyQueryPage.qml</file>
<file>qml/ConnectionsPage.qml</file>
<file>qml/LocationQueryPage.qml</file>
<file>qml/ConnectionDetailsPage.qml</file>
<file>qml/DatePickerButton.qml</file>
<file>qml/TimePickerButton.qml</file>
<file>qml/DepartureQueryPage.qml</file>
<file>qml/DeparturesPage.qml</file>
<file>qtquickcontrols2.conf</file>
</qresource>
</RCC>
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