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

@ -34,8 +34,8 @@ Item {
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
Layout.preferredHeight: parent.height - 280
proxyModel: songProxyModel
innerModel: songProxyModel.songModel
proxyModel: songModel
innerModel: songModel
libraryType: "song"
headerLabel: "Songs"
itemIcon: "folder-music-symbolic"
@ -53,7 +53,10 @@ Item {
songProxyModel.deleteSongs(rows)
})
Component.onCompleted: selectedLibrary = "song";
Component.onCompleted: {
selectedLibrary = "song";
console.log("PRINTER SONGS: " + songModel.count);
}
}
Presenter.LibraryItem {
@ -61,8 +64,8 @@ Item {
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
Layout.preferredHeight: parent.height - 280
proxyModel: videoProxyModel
innerModel: videoProxyModel.videoModel
proxyModel: videoModel
innerModel: videoModel
libraryType: "video"
headerLabel: "Videos"
itemIcon: "folder-videos-symbolic"
@ -87,8 +90,8 @@ Item {
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
Layout.preferredHeight: parent.height - 280
proxyModel: imageProxyModel
innerModel: imageProxyModel.imageModel
proxyModel: imageModel
innerModel: imageModel
libraryType: "image"
headerLabel: "Images"
itemIcon: "folder-pictures-symbolic"
@ -108,8 +111,8 @@ Item {
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
Layout.preferredHeight: parent.height - 280
proxyModel: presProxyModel
innerModel: presProxyModel.presentationModel
proxyModel: presentationModel
innerModel: presentationModel
libraryType: "presentation"
headerLabel: "Presentations"
itemIcon: "x-office-presentation-symbolic"

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);
}
}

View file

@ -179,10 +179,22 @@ Controls.Page {
/* ImageProxyModel { id: imageProxyModel } */
/* PresentationProxyModel { id: presProxyModel } */
/* VideoProxyModel { id: videoProxyModel } */
SongModel { id: songModel }
VideoModel { id: videoModel }
PresentationModel { id: presentationModel }
ImageModel { id: imageModel }
SongModel {
id: songModel
Component.onCompleted: setup();
}
VideoModel {
id: videoModel
Component.onCompleted: setup();
}
PresentationModel {
id: presentationModel
Component.onCompleted: setup();
}
ImageModel {
id: imageModel
Component.onCompleted: setup();
}
ServiceThing { id: serviceThing }
FileHelper { id: fileHelper }
/* SlideHelper { id: slideHelper } */