fixing serviceListItem:
Need to remember that list delegates need a component not a real item, so the wrapper is necessary
This commit is contained in:
parent
146f2df0c3
commit
c2a56cd24b
1 changed files with 172 additions and 187 deletions
|
@ -77,222 +77,207 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Component {
|
||||||
id: serviceListItem
|
id: serviceListItem
|
||||||
implicitWidth: serviceItemList.width
|
Item {
|
||||||
height: Kirigami.Units.gridUnit * 2
|
implicitWidth: serviceItemList.width
|
||||||
Component.onCompleted: Utils.dbg("HELLLLLOOOOOO: " + ServiceItemModel.getItem(0).name)
|
height: Kirigami.Units.gridUnit * 2
|
||||||
|
Component.onCompleted: Utils.dbg("HELLLLLOOOOOO: " + ServiceItemModel.getItem(0).name)
|
||||||
|
|
||||||
property var selectedItems
|
property var selectedItems
|
||||||
|
|
||||||
DropArea {
|
DropArea {
|
||||||
id: serviceDrop
|
id: serviceDrop
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
onEntered: (drag) => {
|
onEntered: (drag) => {
|
||||||
if (drag.keys[0] === "library") {
|
if (drag.keys[0] === "library") {
|
||||||
dropHighlightLine.visible = true;
|
dropHighlightLine.visible = true;
|
||||||
dropHighlightLine.y = serviceDrop.mapToItem(
|
dropHighlightLine.y = serviceDrop.mapToItem(
|
||||||
serviceItemList,0,0).y - 2;
|
serviceItemList,0,0).y - 2;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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") {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
keys: ["library","serviceitem"]
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: visServiceItem
|
|
||||||
width: serviceDrop.width
|
|
||||||
height: serviceDrop.height
|
|
||||||
anchors {
|
|
||||||
horizontalCenter: parent.horizontalCenter
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
color: {
|
|
||||||
if (active)
|
|
||||||
Kirigami.Theme.highlightColor;
|
|
||||||
else if (selected)
|
|
||||||
Kirigami.Theme.focusColor;
|
|
||||||
else if (mouseHandler.containsMouse)
|
|
||||||
Kirigami.Theme.hoverColor;
|
|
||||||
else
|
|
||||||
Kirigami.Theme.backgroundColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.Label {
|
|
||||||
id: label
|
|
||||||
anchors.left: dragHandle.right
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.leftMargin: 5
|
|
||||||
text: name
|
|
||||||
elide: Text.ElideRight
|
|
||||||
width: parent.width - trailing.width - dragHandle.width - 25
|
|
||||||
color: {
|
|
||||||
if (selected ||
|
|
||||||
mouseHandler.containsMouse || active)
|
|
||||||
Kirigami.Theme.highlightedTextColor;
|
|
||||||
else
|
|
||||||
Kirigami.Theme.textColor;
|
|
||||||
}
|
}
|
||||||
Component.onCompleted: Utils.dbg("SERVICEMODEL: " + name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Kirigami.Icon {
|
onDropped: (drag) => {
|
||||||
id: trailing
|
loadingItem.visible = true;
|
||||||
anchors.right: parent.right
|
console.log("DROPPED IN ITEM AREA: " + drag.keys);
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
console.log(dragItemIndex + " " + index);
|
||||||
anchors.rightMargin: 5
|
const hlIndex = serviceItemList.currentIndex;
|
||||||
implicitWidth: Kirigami.Units.gridUnit
|
if (drag.keys[0] === "library") {
|
||||||
source: {
|
addItem(index,
|
||||||
switch (ty) {
|
dragItemType,
|
||||||
case 'image': return "folder-pictures-symbolic";
|
dragItemIndex);
|
||||||
case 'video': return "folder-videos-symbolic";
|
} else if (drag.keys[0] === "serviceitem") {
|
||||||
case 'song': return "folder-music-symbolic";
|
/* ServiceItemModel.moveRows(serviceItemList.indexDragged, */
|
||||||
case 'presentation': return "x-office-presentation-symbolic";
|
/* serviceItemList.moveToIndex, 1); */
|
||||||
default: return "slideshow-plugin";
|
/* serviceItemList.currentIndex = moveToIndex; */
|
||||||
}
|
}
|
||||||
|
dropHighlightLine.visible = false;
|
||||||
|
loadingItem.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
keys: ["library","serviceitem"]
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: visServiceItem
|
||||||
|
width: serviceDrop.width
|
||||||
|
height: serviceDrop.height
|
||||||
|
anchors {
|
||||||
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
color: {
|
color: {
|
||||||
if (selected ||
|
if (active)
|
||||||
mouseHandler.containsMouse || active)
|
Kirigami.Theme.highlightColor;
|
||||||
Kirigami.Theme.highlightedTextColor;
|
else if (selected)
|
||||||
|
Kirigami.Theme.focusColor;
|
||||||
|
else if (mouseHandler.containsMouse)
|
||||||
|
Kirigami.Theme.hoverColor;
|
||||||
else
|
else
|
||||||
Kirigami.Theme.textColor;
|
Kirigami.Theme.backgroundColor;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* onYChanged: serviceItemList.updateDrag(Math.round(y)); */
|
Controls.Label {
|
||||||
|
id: label
|
||||||
states: [
|
anchors.left: dragHandle.right
|
||||||
State {
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
when: mouseHandler.drag.active
|
anchors.leftMargin: 5
|
||||||
ParentChange {
|
text: name
|
||||||
target: visServiceItem
|
elide: Text.ElideRight
|
||||||
parent: serviceItemList
|
width: parent.width - trailing.width - dragHandle.width - 25
|
||||||
|
color: {
|
||||||
|
if (selected ||
|
||||||
|
mouseHandler.containsMouse || active)
|
||||||
|
Kirigami.Theme.highlightedTextColor;
|
||||||
|
else
|
||||||
|
Kirigami.Theme.textColor;
|
||||||
}
|
}
|
||||||
|
Component.onCompleted: Utils.dbg("SERVICEMODEL: " + name)
|
||||||
|
}
|
||||||
|
|
||||||
PropertyChanges {
|
Kirigami.Icon {
|
||||||
target: visServiceItem
|
id: trailing
|
||||||
/* backgroundColor: Kirigami.Theme.backgroundColor */
|
anchors.right: parent.right
|
||||||
/* textColor: Kirigami.Theme.textColor */
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.verticalCenter: undefined
|
anchors.rightMargin: 5
|
||||||
anchors.horizontalCenter: undefined
|
implicitWidth: Kirigami.Units.gridUnit
|
||||||
|
source: {
|
||||||
|
switch (ty) {
|
||||||
|
case 'image': return "folder-pictures-symbolic";
|
||||||
|
case 'video': return "folder-videos-symbolic";
|
||||||
|
case 'song': return "folder-music-symbolic";
|
||||||
|
case 'presentation': return "x-office-presentation-symbolic";
|
||||||
|
default: return "slideshow-plugin";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
color: {
|
||||||
|
if (selected ||
|
||||||
|
mouseHandler.containsMouse || active)
|
||||||
|
Kirigami.Theme.highlightedTextColor;
|
||||||
|
else
|
||||||
|
Kirigami.Theme.textColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
|
|
||||||
/* Drag.dragType: Drag.Automatic */
|
/* onYChanged: serviceItemList.updateDrag(Math.round(y)); */
|
||||||
/* Drag.active: mouseHandler.drag.active */
|
|
||||||
/* Drag.hotSpot.x: width / 2 */
|
|
||||||
/* Drag.hotSpot.y: height / 2 */
|
|
||||||
/* Drag.keys: ["serviceitem"] */
|
|
||||||
|
|
||||||
MouseArea {
|
states: [
|
||||||
id: mouseHandler
|
State {
|
||||||
anchors.fill: parent
|
when: mouseHandler.drag.active
|
||||||
hoverEnabled: true
|
ParentChange {
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
target: visServiceItem
|
||||||
|
parent: serviceItemList
|
||||||
|
}
|
||||||
|
|
||||||
/* drag { */
|
PropertyChanges {
|
||||||
/* target: visServiceItem */
|
target: visServiceItem
|
||||||
/* axis: Drag.YAxis */
|
/* backgroundColor: Kirigami.Theme.backgroundColor */
|
||||||
/* /\* minimumY: root.y *\/ */
|
/* textColor: Kirigami.Theme.textColor */
|
||||||
/* /\* maximumY: serviceItemList.height - serviceDrop.height *\/ */
|
anchors.verticalCenter: undefined
|
||||||
/* smoothed: false */
|
anchors.horizontalCenter: undefined
|
||||||
/* } */
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
/* drag.onActiveChanged: { */
|
/* Drag.dragType: Drag.Automatic */
|
||||||
/* if (mouseHandler.drag.active) { */
|
/* Drag.active: mouseHandler.drag.active */
|
||||||
/* serviceItemList.indexDragged = index; */
|
/* Drag.hotSpot.x: width / 2 */
|
||||||
/* } */
|
/* Drag.hotSpot.y: height / 2 */
|
||||||
/* } */
|
/* Drag.keys: ["serviceitem"] */
|
||||||
|
|
||||||
/* onPositionChanged: { */
|
MouseArea {
|
||||||
/* if (!pressed) { */
|
id: mouseHandler
|
||||||
/* return; */
|
anchors.fill: parent
|
||||||
/* } */
|
hoverEnabled: true
|
||||||
/* mouseArea.arrangeItem(); */
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
/* } */
|
|
||||||
|
|
||||||
onPressed: {
|
/* drag { */
|
||||||
serviceItemList.interactive = false;
|
/* target: visServiceItem */
|
||||||
}
|
/* axis: Drag.YAxis */
|
||||||
|
/* /\* minimumY: root.y *\/ */
|
||||||
|
/* /\* maximumY: serviceItemList.height - serviceDrop.height *\/ */
|
||||||
|
/* smoothed: false */
|
||||||
|
/* } */
|
||||||
|
|
||||||
onClicked: {
|
/* drag.onActiveChanged: { */
|
||||||
if (mouse.button === Qt.RightButton) {
|
/* if (mouseHandler.drag.active) { */
|
||||||
if (!selected) {
|
/* serviceItemList.indexDragged = index; */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* onPositionChanged: { */
|
||||||
|
/* if (!pressed) { */
|
||||||
|
/* return; */
|
||||||
|
/* } */
|
||||||
|
/* mouseArea.arrangeItem(); */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
onPressed: {
|
||||||
|
serviceItemList.interactive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (mouse.button === Qt.RightButton) {
|
||||||
|
if (!selected) {
|
||||||
|
serviceItemList.currentIndex = index;
|
||||||
|
ServiceItemModel.select(index);
|
||||||
|
}
|
||||||
|
rightClickMenu.popup(mouse);
|
||||||
|
}
|
||||||
|
else if ((mouse.button === Qt.LeftButton) &&
|
||||||
|
(mouse.modifiers === Qt.ShiftModifier)) {
|
||||||
|
ServiceItemModel.selectItems(index);
|
||||||
|
} else {
|
||||||
serviceItemList.currentIndex = index;
|
serviceItemList.currentIndex = index;
|
||||||
ServiceItemModel.select(index);
|
ServiceItemModel.select(index);
|
||||||
}
|
}
|
||||||
rightClickMenu.popup(mouse);
|
refocusPresentation();
|
||||||
}
|
}
|
||||||
else if ((mouse.button === Qt.LeftButton) &&
|
|
||||||
(mouse.modifiers === Qt.ShiftModifier)) {
|
onDoubleClicked: {
|
||||||
ServiceItemModel.selectItems(index);
|
changeServiceItem(index);
|
||||||
} else {
|
}
|
||||||
serviceItemList.currentIndex = index;
|
|
||||||
ServiceItemModel.select(index);
|
onReleased: {
|
||||||
|
console.log("should drop");
|
||||||
|
visServiceItem.Drag.drop();
|
||||||
}
|
}
|
||||||
refocusPresentation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onDoubleClicked: {
|
Presenter.DragHandle {
|
||||||
changeServiceItem(index);
|
id: dragHandle
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.leftMargin: 5
|
||||||
|
/* width: 20 */
|
||||||
|
listItem: serviceListItem
|
||||||
|
listView: serviceItemList
|
||||||
|
onMoveRequested: ServiceItemModel.moveRows(oldIndex,
|
||||||
|
newIndex,
|
||||||
|
1)
|
||||||
}
|
}
|
||||||
|
|
||||||
onReleased: {
|
|
||||||
console.log("should drop");
|
|
||||||
visServiceItem.Drag.drop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Presenter.DragHandle {
|
|
||||||
id: dragHandle
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.leftMargin: 5
|
|
||||||
/* width: 20 */
|
|
||||||
listItem: serviceListItem
|
|
||||||
listView: serviceItemList
|
|
||||||
onMoveRequested: ServiceItemModel.moveRows(oldIndex,
|
|
||||||
newIndex,
|
|
||||||
1)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Controls.Menu {
|
|
||||||
id: rightClickMenu
|
|
||||||
Kirigami.Action {
|
|
||||||
text: "Copy"
|
|
||||||
}
|
|
||||||
Kirigami.Action {
|
|
||||||
text: "Paste"
|
|
||||||
}
|
|
||||||
Kirigami.Action {
|
|
||||||
text: "Delete"
|
|
||||||
onTriggered: removeItem(index)
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.MenuSeparator {}
|
|
||||||
|
|
||||||
|
|
||||||
Controls.Menu {
|
Controls.Menu {
|
||||||
id: rightClickMenu
|
id: rightClickMenu
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
|
@ -303,7 +288,7 @@ Item {
|
||||||
}
|
}
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: "Delete"
|
text: "Delete"
|
||||||
onTriggered: removeItems()
|
onTriggered: removeItem(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls.MenuSeparator {}
|
Controls.MenuSeparator {}
|
||||||
|
@ -322,15 +307,15 @@ Item {
|
||||||
ObsModel.setScene(modelData);
|
ObsModel.setScene(modelData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onObjectAdded: obsMenu.insertAction(index, object)
|
||||||
|
onObjectRemoved: obsMenu.removeAction(object)
|
||||||
}
|
}
|
||||||
onObjectAdded: obsMenu.insertAction(index, object)
|
|
||||||
onObjectRemoved: obsMenu.removeAction(object)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
ListView {
|
ListView {
|
||||||
id: serviceItemList
|
id: serviceItemList
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue