diff --git a/src/Reservation.qml b/src/Reservation.qml index c675dd9..603c94b 100644 --- a/src/Reservation.qml +++ b/src/Reservation.qml @@ -10,8 +10,7 @@ Label { required property string reservationStatus Drag.active: dragHandler.active - Drag.hotSpot.x: 0 - Drag.hotSpot.y: 0 + Drag.hotSpot.y: height / 2 elide: Text.ElideRight padding: 2 text: holder diff --git a/src/ReservationsTimeline.qml b/src/ReservationsTimeline.qml index 67c9a3b..2d8f69a 100644 --- a/src/ReservationsTimeline.qml +++ b/src/ReservationsTimeline.qml @@ -99,40 +99,26 @@ Control { id: verticalScroll } - delegate: DropArea { - property real contentWidth: ListView.view.contentWidth - required property string name + delegate: TimelineView { required property TimelineModel timeline - property real viewportWidth: ListView.view.width - property real viewportX: ListView.view.contentX + dayWidth: control.dayWidth + fromDate: control.fromDate height: control.rowHeight - width: contentWidth + model: timeline + toDate: control.toDate + viewportWidth: ListView.view.width + viewportX: ListView.view.contentX - onPositionChanged: function (drag) { - drag.source.y = y; - drag.source.x = (Math.floor(drag.x / control.dayWidth) + .5) * control.dayWidth; + delegate: Reservation { + dragParent: timelineList.contentItem } - TimelineView { - dayWidth: control.dayWidth - fromDate: control.fromDate - height: parent.height - model: parent.timeline - toDate: control.toDate - viewportWidth: parent.viewportWidth - viewportX: parent.viewportX - - delegate: Reservation { - dragParent: timelineList.contentItem - } - - Separator { - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - palette: control.palette - } + Separator { + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + palette: control.palette } } header: Rectangle { @@ -201,5 +187,16 @@ Control { } } } + + DropArea { + anchors.fill: timelineList + anchors.leftMargin: -30 * control.dayWidth + + onPositionChanged: function (drag) { + const pos = timelineList.contentItem.mapFromItem(this, drag.x, drag.y); + drag.source.y = (Math.floor(pos.y / control.rowHeight)) * control.rowHeight; + drag.source.x = (Math.floor(pos.x / control.dayWidth) + .5) * control.dayWidth; + } + } } }