changed all serviceItemModel to singleton ServiceItemModel

This commit is contained in:
Chris Cochrun 2023-01-20 07:06:25 -06:00
parent f503622287
commit 453c67f237
5 changed files with 38 additions and 34 deletions

View file

@ -53,7 +53,7 @@ ColumnLayout {
onEntered: (drag) => { onEntered: (drag) => {
if (drag.keys[0] === "library") { if (drag.keys[0] === "library") {
dropHighlightLine.visible = true; dropHighlightLine.visible = true;
var lastItem = serviceItemList.itemAtIndex(serviceItemModel.rowCount() - 1); var lastItem = serviceItemList.itemAtIndex(ServiceItemModel.rowCount() - 1);
dropHighlightLine.y = lastItem.y + lastItem.height; dropHighlightLine.y = lastItem.y + lastItem.height;
} }
} }
@ -63,7 +63,7 @@ ColumnLayout {
ListView { ListView {
id: serviceItemList id: serviceItemList
anchors.fill: parent anchors.fill: parent
/* model: serviceItemModel */ /* model: ServiceItemModel */
/* delegate: Kirigami.DelegateRecycler { */ /* delegate: Kirigami.DelegateRecycler { */
/* width: serviceItemList.width */ /* width: serviceItemList.width */
/* sourceComponent: itemDelegate */ /* sourceComponent: itemDelegate */
@ -95,7 +95,7 @@ ColumnLayout {
model: DelegateModel { model: DelegateModel {
id: visualModel id: visualModel
model: serviceItemModel model: ServiceItemModel
delegate: DropArea { delegate: DropArea {
id: serviceDrop id: serviceDrop
@ -125,7 +125,7 @@ ColumnLayout {
dragItemText, dragItemText,
dragItemIndex); dragItemIndex);
} else if (drag.keys[0] === "serviceitem") { } else if (drag.keys[0] === "serviceitem") {
serviceItemModel.move(serviceItemList.indexDragged, ServiceItemModel.move(serviceItemList.indexDragged,
serviceItemList.moveToIndex); serviceItemList.moveToIndex);
serviceItemList.currentIndex = moveToIndex; serviceItemList.currentIndex = moveToIndex;
} }
@ -374,7 +374,7 @@ ColumnLayout {
} }
function removeItem(index) { function removeItem(index) {
serviceItemModel.removeItem(index); ServiceItemModel.removeItem(index);
totalServiceItems--; totalServiceItems--;
} }
@ -382,7 +382,7 @@ ColumnLayout {
background, backgroundType, text, itemID) { background, backgroundType, text, itemID) {
const newtext = songsqlmodel.getLyricList(itemID); const newtext = songsqlmodel.getLyricList(itemID);
console.log("adding: " + name + " of type " + type); console.log("adding: " + name + " of type " + type);
serviceItemModel.insertItem(index, name, ServiceItemModel.insertItem(index, name,
type, background, type, background,
backgroundType, newtext); backgroundType, newtext);
totalServiceItems++; totalServiceItems++;
@ -400,7 +400,7 @@ ColumnLayout {
console.log(background); console.log(background);
console.log(backgroundType); console.log(backgroundType);
serviceItemModel.addItem(name, type, background, ServiceItemModel.addItem(name, type, background,
backgroundType, lyrics); backgroundType, lyrics);
totalServiceItems++; totalServiceItems++;
} }

View file

@ -37,7 +37,7 @@ Controls.Page {
property var song property var song
property var draggedLibraryItem property var draggedLibraryItem
property var serviceItems: serviceItemModel property var serviceItems: ServiceItemModel
property bool songDragged: false property bool songDragged: false
@ -50,7 +50,7 @@ Controls.Page {
Component.onCompleted: { Component.onCompleted: {
changeServiceItem(0); changeServiceItem(0);
presentation.forceActiveFocus(); presentation.forceActiveFocus();
/* const loaded = serviceItemModel.loadLastSaved(); */ /* const loaded = ServiceItemModel.loadLastSaved(); */
/* if (!loaded) */ /* if (!loaded) */
/* showPassiveNotification("Failed loading last file"); */ /* showPassiveNotification("Failed loading last file"); */
} }
@ -146,16 +146,12 @@ Controls.Page {
id: pressqlmodel id: pressqlmodel
} }
ServiceItemModel {
id: serviceItemModel
}
ServiceThing { ServiceThing {
id: serviceThing id: serviceThing
} }
function changeServiceItem(index) { function changeServiceItem(index) {
const item = serviceItemModel.getItem(index); const item = ServiceItemModel.getItem(index);
currentServiceItem = index; currentServiceItem = index;
console.log("index grabbed: " + index); console.log("index grabbed: " + index);
console.log(item); console.log(item);
@ -165,7 +161,7 @@ Controls.Page {
/* presentation.itemType = item.type; */ /* presentation.itemType = item.type; */
console.log("Time to start changing"); console.log("Time to start changing");
serviceItemModel.activate(index); ServiceItemModel.activate(index);
SlideObject.changeSlide(item); SlideObject.changeSlide(item);
/* if (item.backgroundType === "video") */ /* if (item.backgroundType === "video") */
@ -174,7 +170,7 @@ Controls.Page {
/* } */ /* } */
presentation.textIndex = 0; presentation.textIndex = 0;
/* serviceItemModel.select(index); */ /* ServiceItemModel.select(index); */
/* presentation.changeSlide(); */ /* presentation.changeSlide(); */
console.log("Slide changed to: " + item.name); console.log("Slide changed to: " + item.name);

View file

@ -187,7 +187,7 @@ FocusScope {
spacing: Kirigami.Units.smallSpacing * 2 spacing: Kirigami.Units.smallSpacing * 2
cacheBuffer: 900 cacheBuffer: 900
reuseItems: true reuseItems: true
model: serviceItemModel model: ServiceItemModel
delegate: Presenter.PreviewSlideListDelegate {} delegate: Presenter.PreviewSlideListDelegate {}
Kirigami.WheelHandler { Kirigami.WheelHandler {
@ -280,7 +280,7 @@ FocusScope {
keyHandler.forceActiveFocus(); keyHandler.forceActiveFocus();
console.log(currentServiceItem); console.log(currentServiceItem);
const nextServiceItemIndex = currentServiceItem + 1; const nextServiceItemIndex = currentServiceItem + 1;
const nextItem = serviceItemModel.getItem(nextServiceItemIndex); const nextItem = ServiceItemModel.getItem(nextServiceItemIndex);
console.log("currentServiceItem " + currentServiceItem); console.log("currentServiceItem " + currentServiceItem);
console.log("nextServiceItem " + nextServiceItemIndex); console.log("nextServiceItem " + nextServiceItemIndex);
console.log(nextItem.name); console.log(nextItem.name);
@ -304,7 +304,7 @@ FocusScope {
function previousSlideAction() { function previousSlideAction() {
keyHandler.forceActiveFocus(); keyHandler.forceActiveFocus();
const prevServiceItemIndex = currentServiceItem - 1; const prevServiceItemIndex = currentServiceItem - 1;
const prevItem = serviceItemModel.getItem(prevServiceItemIndex); const prevItem = ServiceItemModel.getItem(prevServiceItemIndex);
console.log("currentServiceItem " + currentServiceItem); console.log("currentServiceItem " + currentServiceItem);
console.log("prevServiceItem " + prevServiceItemIndex); console.log("prevServiceItem " + prevServiceItemIndex);
console.log(prevItem.name); console.log(prevItem.name);

View file

@ -93,7 +93,7 @@ Item {
Connections { Connections {
target: serviceItemModel target: ServiceItemModel
onDataChanged: if (active) onDataChanged: if (active)
previewSlidesList.positionViewAtIndex(index, ListView.Contain) previewSlidesList.positionViewAtIndex(index, ListView.Contain)
} }

View file

@ -78,7 +78,7 @@ Item {
onEntered: (drag) => { onEntered: (drag) => {
if (drag.keys[0] === "library") { if (drag.keys[0] === "library") {
dropHighlightLine.visible = true; dropHighlightLine.visible = true;
var lastItem = serviceItemList.itemAtIndex(serviceItemModel.rowCount() - 1); var lastItem = serviceItemList.itemAtIndex(ServiceItemModel.rowCount() - 1);
dropHighlightLine.y = lastItem.y + lastItem.height; dropHighlightLine.y = lastItem.y + lastItem.height;
} }
} }
@ -120,7 +120,7 @@ Item {
dragItemFontSize, dragItemFontSize,
dragItemIndex); dragItemIndex);
} else if (drag.keys[0] === "serviceitem") { } else if (drag.keys[0] === "serviceitem") {
/* serviceItemModel.moveRows(serviceItemList.indexDragged, */ /* ServiceItemModel.moveRows(serviceItemList.indexDragged, */
/* serviceItemList.moveToIndex, 1); */ /* serviceItemList.moveToIndex, 1); */
/* serviceItemList.currentIndex = moveToIndex; */ /* serviceItemList.currentIndex = moveToIndex; */
} }
@ -242,7 +242,7 @@ Item {
rightClickMenu.popup(mouse); rightClickMenu.popup(mouse);
else { else {
serviceItemList.currentIndex = index; serviceItemList.currentIndex = index;
serviceItemModel.select(index); ServiceItemModel.select(index);
} }
} }
@ -264,7 +264,7 @@ Item {
/* width: 20 */ /* width: 20 */
listItem: serviceListItem listItem: serviceListItem
listView: serviceItemList listView: serviceItemList
onMoveRequested: serviceItemModel.moveRows(oldIndex, onMoveRequested: ServiceItemModel.moveRows(oldIndex,
newIndex, newIndex,
1) 1)
} }
@ -315,7 +315,7 @@ Item {
NumberAnimation {properties: "x, y"; duration: 100} NumberAnimation {properties: "x, y"; duration: 100}
} }
model: serviceItemModel model: ServiceItemModel
delegate: Kirigami.DelegateRecycler { delegate: Kirigami.DelegateRecycler {
width: serviceItemList.width width: serviceItemList.width
@ -348,7 +348,7 @@ Item {
/* function moveRequested(oldIndex, newIndex) { */ /* function moveRequested(oldIndex, newIndex) { */
/* console.log("moveRequested: ", oldIndex, newIndex); */ /* console.log("moveRequested: ", oldIndex, newIndex); */
/* serviceItemModel.moveRows(oldIndex, newIndex, 1); */ /* ServiceItemModel.moveRows(oldIndex, newIndex, 1); */
/* indexDragged = newIndex; */ /* indexDragged = newIndex; */
/* serviceItemList.currentIndex = newIndex; */ /* serviceItemList.currentIndex = newIndex; */
/* } */ /* } */
@ -446,7 +446,7 @@ Item {
const newid = serviceItemList.currentIndex - 1; const newid = serviceItemList.currentIndex - 1;
showPassiveNotification(oldid + " " + newid); showPassiveNotification(oldid + " " + newid);
showPassiveNotification("Up"); showPassiveNotification("Up");
const ans = serviceItemModel.moveRows(oldid, newid, 1); const ans = ServiceItemModel.moveRows(oldid, newid, 1);
if (ans) if (ans)
{ {
serviceItemList.currentIndex = newid; serviceItemList.currentIndex = newid;
@ -468,7 +468,7 @@ Item {
return; return;
}; };
showPassiveNotification("moving ", id, " down"); showPassiveNotification("moving ", id, " down");
const ans = serviceItemModel.moveDown(id); const ans = ServiceItemModel.moveDown(id);
if (ans) if (ans)
{ {
serviceItemList.currentIndex = id + 1; serviceItemList.currentIndex = id + 1;
@ -487,6 +487,14 @@ Item {
showPassiveNotification("remove"); showPassiveNotification("remove");
removeItem(serviceItemList.currentIndex); removeItem(serviceItemList.currentIndex);
} }
},
Kirigami.Action {
text: "Clear"
icon.name: "recycle"
onTriggered: {
showPassiveNotification("clearing all items");
ServiceItemModel.clearAll();
}
} }
] ]
} }
@ -499,7 +507,7 @@ Item {
} }
function removeItem(index) { function removeItem(index) {
serviceItemModel.removeItem(index); ServiceItemModel.removeItem(index);
totalServiceItems--; totalServiceItems--;
} }
@ -509,7 +517,7 @@ Item {
if (type === "song") { if (type === "song") {
const newtext = songsqlmodel.getLyricList(itemID); const newtext = songsqlmodel.getLyricList(itemID);
console.log("adding: " + name + " of type " + type + " with " + newtext.length + " slides"); console.log("adding: " + name + " of type " + type + " with " + newtext.length + " slides");
serviceItemModel.insertItem(index, name, ServiceItemModel.insertItem(index, name,
type, background, type, background,
backgroundType, newtext, backgroundType, newtext,
audio, font, fontSize, newtext.length); audio, font, fontSize, newtext.length);
@ -518,7 +526,7 @@ Item {
} }
if (type === "presentation") { if (type === "presentation") {
console.log("adding: " + name + " of type " + type + " with " + dragItemSlideNumber + " slides"); console.log("adding: " + name + " of type " + type + " with " + dragItemSlideNumber + " slides");
serviceItemModel.insertItem(index, name, ServiceItemModel.insertItem(index, name,
type, background, type, background,
backgroundType, "", backgroundType, "",
"", "", 0, dragItemSlideNumber); "", "", 0, dragItemSlideNumber);
@ -526,7 +534,7 @@ Item {
return; return;
} }
console.log("adding: " + name + " of type " + type); console.log("adding: " + name + " of type " + type);
serviceItemModel.insertItem(index, name, ServiceItemModel.insertItem(index, name,
type, background, type, background,
backgroundType); backgroundType);
totalServiceItems++; totalServiceItems++;
@ -541,7 +549,7 @@ Item {
console.log(itemID); console.log(itemID);
lyrics = songsqlmodel.getLyricList(itemID); lyrics = songsqlmodel.getLyricList(itemID);
console.log(lyrics); console.log(lyrics);
serviceItemModel.addItem(name, type, background, ServiceItemModel.addItem(name, type, background,
backgroundType, lyrics, backgroundType, lyrics,
audio, font, fontSize); audio, font, fontSize);
totalServiceItems++; totalServiceItems++;
@ -551,7 +559,7 @@ Item {
console.log(background); console.log(background);
console.log(backgroundType); console.log(backgroundType);
serviceItemModel.addItem(name, type, background, ServiceItemModel.addItem(name, type, background,
backgroundType); backgroundType);
totalServiceItems++; totalServiceItems++;
} }