preparing for some refactoring

This commit is contained in:
Chris Cochrun 2025-08-06 09:13:48 -05:00
parent 8de473519b
commit 84b31caf6b
4 changed files with 89 additions and 63 deletions

View file

@ -102,26 +102,31 @@ Item {
anchors.fill: parent
onEntered: (drag) => {
console.log("here");
if (drag.keys[0] === "library") {
dropHighlightLine.visible = true;
dropHighlightLine.y = serviceDrop.mapToItem(
serviceItemList,0,0).y - 2;
} else {
console.log("here");
let from = drag.source.DelegateModel.itemsIndex;
let to = serviceListItem.DelegateModel.itemsIndex;
console.log("from = " + from);
console.log("to = " + to);
if (from != to && to > -1 && to <= ServiceItemModel.count - 1)
ServiceItemModel.moveRows(from, to, 1);
}
}
onDropped: (drag) => {
loadingItem.visible = true;
console.log("DROPPED IN ITEM AREA: " + drag.keys);
console.log(dragItemIndex + " " + index);
const hlIndex = serviceItemList.currentIndex;
if (drag.keys[0] === "library") {
loadingItem.visible = true;
console.log("DROPPED IN ITEM AREA: " + drag.keys);
console.log(dragItemIndex + " " + index);
const hlIndex = serviceItemList.currentIndex;
addItem(index,
dragItemType,
dragItemIndex);
} else if (drag.keys[0] === "serviceitem") {
/* ServiceItemModel.moveRows(serviceItemList.indexDragged, */
/* serviceItemList.moveToIndex, 1); */
/* serviceItemList.currentIndex = moveToIndex; */
}
dropHighlightLine.visible = false;
loadingItem.visible = false;
@ -150,12 +155,12 @@ Item {
Controls.Label {
id: label
anchors.left: dragHandle.right
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 5
text: name
text: (index + 1) + ": " + name
elide: Text.ElideRight
width: parent.width - trailing.width - dragHandle.width - 25
width: parent.width - trailing.width - 25
color: {
if (selected ||
mouseHandler.containsMouse || active)
@ -211,10 +216,10 @@ Item {
]
/* Drag.dragType: Drag.Automatic */
/* Drag.active: mouseHandler.drag.active */
/* Drag.hotSpot.x: width / 2 */
/* Drag.hotSpot.y: height / 2 */
/* Drag.keys: ["serviceitem"] */
Drag.active: mouseHandler.drag.active
Drag.hotSpot.x: width / 2
Drag.hotSpot.y: height / 2
Drag.keys: ["serviceitem"]
MouseArea {
id: mouseHandler
@ -222,19 +227,17 @@ Item {
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
/* drag { */
/* target: visServiceItem */
/* axis: Drag.YAxis */
/* /\* minimumY: root.y *\/ */
/* /\* maximumY: serviceItemList.height - serviceDrop.height *\/ */
/* smoothed: false */
/* } */
drag {
target: visServiceItem
axis: Drag.YAxis
/* minimumY: root.y */
/* maximumY: serviceItemList.height - serviceDrop.height */
smoothed: false
onActiveChanged: {
serviceItemList.indexDragged = index;
}
}
/* drag.onActiveChanged: { */
/* if (mouseHandler.drag.active) { */
/* serviceItemList.indexDragged = index; */
/* } */
/* } */
/* onPositionChanged: { */
/* if (!pressed) { */
@ -243,9 +246,9 @@ Item {
/* mouseArea.arrangeItem(); */
/* } */
onPressed: {
serviceItemList.interactive = false;
}
/* onPressAndHold: { */
/* serviceItemList.interactive = false; */
/* } */
onClicked: {
if (mouse.button === Qt.RightButton) {
@ -275,20 +278,21 @@ Item {
}
}
Presenter.DragHandle {
id: dragHandle
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 5
/* width: 20 */
listItem: serviceListItem
listView: serviceItemList
onMoveRequested: (oldIndex, newIndex) => {
ServiceItemModel.moveRows(oldIndex,
newIndex,
1)
}
}
/* Kirigami.ListItemDragHandle { */
/* id: dragHandle */
/* anchors.left: parent.left */
/* anchors.verticalCenter: parent.verticalCenter */
/* anchors.leftMargin: 5 */
/* incrementalMoves: true */
/* /\* width: 20 *\/ */
/* listItem: serviceListItem */
/* listView: serviceItemList */
/* onMoveRequested: (oldIndex, newIndex) => { */
/* ServiceItemModel.moveRows(oldIndex, */
/* newIndex, */
/* 1) */
/* } */
/* } */
}
Controls.Menu {