library is showing items and searching is working again

This commit is contained in:
Chris Cochrun 2024-09-13 14:01:06 -05:00
parent b61e05a423
commit f197099346
4 changed files with 106 additions and 43 deletions

View file

@ -155,7 +155,9 @@ ColumnLayout {
id: searchField
height: parent.height
width: parent.width - 40
onAccepted: proxyModel.setFilterRegularExpression(searchField.text)
onAccepted: {
innerModel.search(text);
}
background: Presenter.TextBackground {
control: searchField
}
@ -177,11 +179,11 @@ ColumnLayout {
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
id: libraryList
model: proxyModel
model: innerModel
clip: true
ItemSelectionModel {
id: selectionModel
model: proxyModel
model: innerModel
onSelectionChanged: {
/* showPassiveNotification("deslected: " + deselected); */
/* showPassiveNotification("selected: " + selected); */
@ -222,18 +224,30 @@ ColumnLayout {
Item {
implicitWidth: ListView.view.width
height: selectedLibrary == libraryType ? 50 : 0
property bool rightMenu: false
property bool selected: selectionModel.hasSelection && selectionModel.currentIndex == innerModel.index(index, 0)
property bool fileValidation: {
if (filePath)
fileHelper.validate(filePath)
else
false
}
Rectangle {
id: itemBackground
color: Kirigami.Theme.backgroundColor
anchors.fill: parent
Binding on color {
when: dragHandler.containsMouse || selected
value: Kirigami.Theme.highlightColor
}
}
Controls.ItemDelegate {
id: listItem
property bool rightMenu: false
property bool selected: selectionModel.isSelected(proxyModel.idx(index))
property bool fileValidation: {
if (filePath)
fileHelper.validate(filePath)
else
false
}
implicitWidth: libraryList.width
height: selectedLibrary == libraryType ? 50 : 0
text: title
@ -251,17 +265,6 @@ ColumnLayout {
icon.width: Kirigami.Units.gridUnit
icon.height: Kirigami.Units.gridUnit
/* supportsMouseEvents: false */
/* background: Rectangle { */
/* color: Kirigami.Theme.backgroundColor */
/* fill: parent */
/* } */
/* Binding on backgroundColor { */
/* when: dragHandler.containsMouse || */
/* (selectionModel.hasSelection && */
/* selectionModel.isSelected(proxyModel.idx(index))) */
/* value: Kirigami.Theme.highlightColor */
/* } */
/* textColor: { */
/* if (selectedLibrary == "song") */
/* Kirigami.Theme.textColor; */
@ -348,7 +351,7 @@ ColumnLayout {
onClicked: {
if (mouse.button === Qt.RightButton) {
if(selectionModel.selectedIndexes.length <= 1)
selectionModel.select(proxyModel.idx(index),
selectionModel.select(innerModel.index(index),
ItemSelectionModel.ClearAndSelect);
rightClickMenu.popup()
}
@ -356,19 +359,19 @@ ColumnLayout {
(mouse.modifiers === Qt.ShiftModifier)) {
if (libraryList.currentIndex < index) {
for (let i = libraryList.currentIndex; i <= index; i++) {
selectionModel.select(proxyModel.idx(i),
selectionModel.select(innerModel.index(i),
ItemSelectionModel.Select);
}
}
else {
for (let i = index; i <= libraryList.currentIndex; i++) {
selectionModel.select(proxyModel.idx(i),
selectionModel.select(innerModel.index(i),
ItemSelectionModel.Select);
}
}
console.log(selectionModel.selectedIndexes);
} else {
selectionModel.select(proxyModel.idx(index),
selectionModel.select(innerModel.index(index),
ItemSelectionModel.ClearAndSelect);
libraryList.currentIndex = index;
}
@ -420,13 +423,13 @@ ColumnLayout {
if (row > currentRow) {
for (var i = currentRow; i <= row; i++) {
let idx = proxyModel.idx(i);
let idx = innerModel.idx(i);
selectionModel.select(idx, ItemSelectionModel.Select);
}
}
else {
for (var i = row; i <= currentRow; i++) {
let idx = proxyModel.idx(i);
let idx = innerModel.idx(i);
selectionModel.select(idx, ItemSelectionModel.Select);
}
}