making newItem and deleteItem functions work

This commit is contained in:
Chris Cochrun 2023-03-02 05:56:52 -06:00
parent 5cc531f046
commit 3dbecf2301
2 changed files with 25 additions and 17 deletions

View file

@ -37,16 +37,18 @@ Item {
headerLabel: "Songs"
itemIcon: "folder-music-symbolic"
itemSubtitle: "hi"
newItemFuntion: (function() {
newItemFunction: (function() {
songProxyModel.setFilterRegularExpression("");
songProxyModel.songModel.newSong();
songLibraryList.currentIndex = songProxyModel.songModel.rowCount() - 1;
libraryList.currentIndex = songProxyModel.songModel.rowCount() - 1;
if (!editMode)
editMode = true;
editType = "song";
editSwitch(songLibraryList.currentIndex);
editSwitch(libraryList.currentIndex);
})
deleteItemFunction: (function(index) {
songProxyModel.deleteSong(index)
})
deleteItemFuntion: songProxyModel.deleteSong(index)
Component.onCompleted: selectedLibrary = "song";
}
@ -67,10 +69,10 @@ Item {
else
"file is missing"
}
newItemFuntion: (function() {
newItemFunction: (function() {
videoProxyModel.setFilterRegularExpression("");
})
deleteItemFuntion: videoProxyModel.deleteVideo(index)
deleteItemFunction: videoProxyModel.deleteVideo(index)
}
@ -90,10 +92,10 @@ Item {
else
"file is missing"
}
newItemFuntion: (function() {
newItemFunction: (function() {
imageProxyModel.setFilterRegularExpression("");
})
deleteItemFuntion: imageProxyModel.deleteImage(index)
deleteItemFunction: imageProxyModel.deleteImage(index)
}
@ -113,10 +115,10 @@ Item {
else
"file is missing"
}
newItemFuntion: (function() {
newItemFunction: (function() {
presProxyModel.setFilterRegularExpression("");
})
deleteItemFuntion: presProxyModel.deletePresentation(index)
deleteItemFunction: presProxyModel.deletePresentation(index)
}

View file

@ -17,8 +17,9 @@ ColumnLayout {
property string itemLabel
property string itemSubtitle
property string itemIcon
property var newItemFuntion
property var deleteItemFuntion
property var newItemFunction
property var deleteItemFunction
property ListView libraryList: libraryList
states: [
State {
@ -138,7 +139,7 @@ ColumnLayout {
icon.name: "document-new"
text: "New " + libraryType
tooltip: "Add a new " + libraryType
onTriggered: newItemFuntion
onTriggered: newItemFunction()
},
Kirigami.Action {
@ -216,7 +217,12 @@ ColumnLayout {
property bool rightMenu: false
property bool selected: selectionModel.isSelected(proxyModel.idx(index))
property bool fileValidation: fileHelper.validate(filePath)
property bool fileValidation: {
if (filePath)
fileHelper.validate(filePath)
else
false
}
implicitWidth: libraryList.width
height: selectedLibrary == libraryType ? 50 : 0
@ -318,7 +324,7 @@ ColumnLayout {
libraryList.selectSongs(index);
} else {
selectionModel.select(proxyModel.idx(index),
ItemselectionModel.ClearAndSelect);
ItemSelectionModel.ClearAndSelect);
}
}
@ -327,7 +333,7 @@ ColumnLayout {
if (!editMode)
editMode = true;
editType = libraryType;
editSwitch(id);
editSwitch(index);
}
}
@ -338,7 +344,7 @@ ColumnLayout {
y: clickHandler.mouseY + 10
Kirigami.Action {
text: "delete"
onTriggered: deleteItemFunction
onTriggered: root.deleteItemFunction(index)
}
}
}