diff --git a/src/ReservationsPage.qml b/src/ReservationsPage.qml index 771c471..619015a 100644 --- a/src/ReservationsPage.qml +++ b/src/ReservationsPage.qml @@ -80,9 +80,19 @@ Page { viewportX: ListView.view.contentX delegate: Rectangle { + id: booking + + required property string holder + border.color: "black" border.width: 1 - color: "blue" + color: "lightblue" + + Label { + anchors.fill: parent + elide: Text.ElideRight + text: booking.holder + } } } header: Pane { diff --git a/src/timelineview.cpp b/src/timelineview.cpp index 9df9052..9b5f41d 100644 --- a/src/timelineview.cpp +++ b/src/timelineview.cpp @@ -167,16 +167,26 @@ void TimelineView::componentComplete() populate(); } -TimelineView::Item *TimelineView::createItem(qint64 day, qint64 len) +TimelineView::Item *TimelineView::createItem(qint64 day, const TimelineModel::Item &modelItem) { - QQuickItem *item = m_reusableItems.isEmpty() ? qobject_cast(m_delegate->create( - m_delegate->creationContext())) - : m_reusableItems.takeLast(); - if (!item) { - qmlWarning(m_delegate) << TimelineView::tr("Delegate must be of Item type"); - return nullptr; + QQuickItem *item; + + if (m_reusableItems.isEmpty()) { + QVariantMap initialProperties{ + {"holder", modelItem.holder}, + }; + item = qobject_cast( + m_delegate->createWithInitialProperties(initialProperties, + m_delegate->creationContext())); + if (!item) { + qmlWarning(m_delegate) << TimelineView::tr("Delegate must be of Item type"); + return nullptr; + } + } else { + item = m_reusableItems.takeLast(); + item->setProperty("holder", modelItem.holder); } - auto *viewItem = new TimelineView::Item(day, len, *item, *this); + auto *viewItem = new TimelineView::Item(day, modelItem.nights, *item, *this); return viewItem; } @@ -235,7 +245,7 @@ void TimelineView::populate() if (!m_items.isEmpty() && m_items.first()->day <= day) { continue; } - TimelineView::Item *viewItem = createItem(day, item->nights); + TimelineView::Item *viewItem = createItem(day, *item); if (!viewItem) { break; } @@ -263,7 +273,7 @@ void TimelineView::populate() if (!m_items.isEmpty() && m_items.last()->day >= day) { continue; } - TimelineView::Item *viewItem = createItem(day, item->nights); + TimelineView::Item *viewItem = createItem(day, *item); if (!viewItem) { break; } diff --git a/src/timelineview.h b/src/timelineview.h index c462cd5..c11da37 100644 --- a/src/timelineview.h +++ b/src/timelineview.h @@ -61,7 +61,7 @@ private: struct Item; - Item *createItem(qint64 day, qint64 len); + Item *createItem(qint64 day, const TimelineModel::Item &modelItem); void releaseItem(Item *item); void drainItems();