Commit de906d7a authored by Volker Krause's avatar Volker Krause

Also use the multi-traveler selector to select the right pkpass instance

parent feb3279f
......@@ -27,8 +27,10 @@ Kirigami.ScrollablePage {
id: root
/** The reservation batch identifier (@see ReservationManager). */
property var batchId
/** Currently selected reservation of the batch. */
property var currentReservationId: batchId
/** @deprecated */
readonly property var reservation: _reservationManager.reservation(batchId);
readonly property var reservation: _reservationManager.reservation(currentReservationId);
/** Reservation::reservationFor, unique for all travelers on a multi-traveler reservation set */
readonly property var reservationFor: reservation.reservationFor
property var editor
......
......@@ -48,6 +48,7 @@ App.DetailsPage {
App.TicketTokenDelegate {
Kirigami.FormData.isSection: true
resIds: _reservationManager.reservationsForBatch(root.batchId)
onCurrentReservationIdChanged: root.currentReservationId = currentReservationId
}
// flight details
......
......@@ -28,6 +28,7 @@ ColumnLayout {
id: root
property var resIds
readonly property var currentReservationId: ticketModel.reservationIdAt(travelerBox.currentIndex)
readonly property var currentTicket: ticketModel.reservationAt(travelerBox.currentIndex).reservedTicket
Layout.fillWidth: true
......
......@@ -60,23 +60,32 @@ void TicketTokenModel::setReservationIds(const QStringList& resIds)
beginResetModel();
for (const auto &resId : resIds) {
const auto res = m_resMgr->reservation(resId);
if (!JsonLd::canConvert<Reservation>(res))
const auto v = m_resMgr->reservation(resId);
if (!JsonLd::canConvert<Reservation>(v))
continue;
const auto ticket = JsonLd::convert<Reservation>(res).reservedTicket().value<Ticket>();
if (!ticket.ticketToken().isEmpty())
const auto res = JsonLd::convert<Reservation>(v);
const auto ticket = res.reservedTicket().value<Ticket>();
if (!ticket.ticketToken().isEmpty() || !res.pkpassPassTypeIdentifier().isEmpty()) {
m_resIds.push_back(resId);
}
}
endResetModel();
}
QVariant TicketTokenModel::reservationAt(int row) const
{
if (!m_resMgr || row >= m_resIds.size())
if (!m_resMgr || row >= m_resIds.size() || row < 0)
return {};
return m_resMgr->reservation(m_resIds.at(row));
}
QString TicketTokenModel::reservationIdAt(int row) const
{
if (!m_resMgr || row >= m_resIds.size() || row < 0)
return {};
return m_resIds.at(row);
}
int TicketTokenModel::rowCount(const QModelIndex& parent) const
{
if (parent.isValid())
......
......@@ -44,6 +44,7 @@ public:
void setReservationIds(const QStringList &resIds);
Q_INVOKABLE QVariant reservationAt(int row) const;
Q_INVOKABLE QString reservationIdAt(int row) const;
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
......
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