adding selection model in progress to library
This commit is contained in:
parent
1421a068df
commit
891f6e395d
1 changed files with 54 additions and 33 deletions
|
@ -3,6 +3,7 @@ import QtQuick.Controls 2.15 as Controls
|
|||
import QtQuick.Layouts 1.2
|
||||
import Qt.labs.platform 1.1 as Labs
|
||||
import QtQuick.Pdf 5.15
|
||||
import QtQml.Models 2.15
|
||||
import org.kde.kirigami 2.13 as Kirigami
|
||||
import "./" as Presenter
|
||||
import org.presenter 1.0
|
||||
|
@ -120,16 +121,14 @@ Item {
|
|||
},
|
||||
|
||||
Kirigami.Action {
|
||||
displayComponent: Component {
|
||||
Kirigami.SearchField {
|
||||
id: songSearchField
|
||||
displayComponent: Kirigami.SearchField {
|
||||
id: searchField
|
||||
height: parent.height
|
||||
width: parent.width - 40
|
||||
onAccepted: songProxyModel.setFilterRegularExpression(songSearchField.text)
|
||||
onAccepted: songProxyModel.setFilterRegularExpression(searchField.text)
|
||||
}
|
||||
}
|
||||
/* visible: selectedLibrary == "songs" */
|
||||
}
|
||||
]
|
||||
|
||||
Behavior on height {
|
||||
|
@ -147,6 +146,15 @@ Item {
|
|||
Layout.alignment: Qt.AlignTop
|
||||
id: songLibraryList
|
||||
model: songProxyModel
|
||||
ItemSelectionModel {
|
||||
id: songSelectionModel
|
||||
model: songProxyModel
|
||||
onSelectionChanged: {
|
||||
showPassiveNotification("deslected: " + deselected);
|
||||
showPassiveNotification("selected: " + selected);
|
||||
console.log(selected);
|
||||
}
|
||||
}
|
||||
delegate: songDelegate
|
||||
state: "selected"
|
||||
|
||||
|
@ -184,6 +192,7 @@ Item {
|
|||
id: songListItem
|
||||
|
||||
property bool rightMenu: false
|
||||
property bool selected: songSelectionModel.isSelected(songProxyModel.idx(index))
|
||||
|
||||
implicitWidth: songLibraryList.width
|
||||
height: selectedLibrary == "songs" ? 50 : 0
|
||||
|
@ -193,20 +202,16 @@ Item {
|
|||
icon: "folder-music-symbolic"
|
||||
iconSize: Kirigami.Units.gridUnit
|
||||
supportsMouseEvents: false
|
||||
backgroundColor: {
|
||||
if (parent.ListView.isCurrentItem) {
|
||||
Kirigami.Theme.highlightColor;
|
||||
} else if (songDragHandler.containsMouse){
|
||||
Kirigami.Theme.highlightColor;
|
||||
} else {
|
||||
Kirigami.Theme.backgroundColor;
|
||||
backgroundColor: Kirigami.Theme.backgroundColor;
|
||||
Binding on backgroundColor {
|
||||
when: songDragHandler.containsMouse || (songSelectionModel.hasSelection && songSelectionModel.isSelected(songProxyModel.idx(index)))
|
||||
value: Kirigami.Theme.highlightColor
|
||||
}
|
||||
}
|
||||
textColor: {
|
||||
if (parent.ListView.isCurrentItem || songDragHandler.containsMouse)
|
||||
activeTextColor;
|
||||
else
|
||||
Kirigami.Theme.textColor;
|
||||
|
||||
textColor: Kirigami.Theme.textColor;
|
||||
Binding on textColor {
|
||||
when: songDragHandler.containsMouse || (songSelectionModel.hasSelection && songSelectionModel.isSelected(songProxyModel.idx(index)))
|
||||
value: Kirigami.Theme.highlightedTextColor
|
||||
}
|
||||
|
||||
Behavior on height {
|
||||
|
@ -268,17 +273,24 @@ Item {
|
|||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
onClicked: {
|
||||
if(mouse.button == Qt.RightButton)
|
||||
if (mouse.button === Qt.RightButton)
|
||||
rightClickSongMenu.popup()
|
||||
else{
|
||||
/* showPassiveNotification(title + id, 3000); */
|
||||
else if ((mouse.button === Qt.LeftButton) &&
|
||||
(mouse.modifiers === Qt.ShiftModifier)) {
|
||||
selectSongs(index);
|
||||
} else {
|
||||
songSelectionModel.select(songProxyModel.idx(index),
|
||||
ItemSelectionModel.ClearAndSelect);
|
||||
|
||||
}
|
||||
}
|
||||
onDoubleClicked: {
|
||||
songLibraryList.currentIndex = index;
|
||||
if (!editMode)
|
||||
editMode = true;
|
||||
editType = "song";
|
||||
editSwitch(id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -312,8 +324,8 @@ Item {
|
|||
}
|
||||
|
||||
function newSong() {
|
||||
songProxyModel.setFilterRegularExpression("");
|
||||
songProxyModel.songModel.newSong();
|
||||
songSearchField.clear();
|
||||
songLibraryList.currentIndex = songProxyModel.songModel.rowCount() - 1;
|
||||
if (!editMode)
|
||||
editMode = true;
|
||||
|
@ -422,7 +434,10 @@ Item {
|
|||
icon.name: "document-new"
|
||||
text: "New Video"
|
||||
tooltip: "Add a new video"
|
||||
onTriggered: videoLibraryList.newVideo()
|
||||
onTriggered: {
|
||||
videoProxyModel.setFilterRegularExpression("");
|
||||
videoLibraryList.newVideo();
|
||||
}
|
||||
/* visible: selectedLibrary == "videos" */
|
||||
},
|
||||
|
||||
|
@ -717,7 +732,10 @@ Item {
|
|||
icon.name: "document-new"
|
||||
text: "New Image"
|
||||
tooltip: "Add a new image"
|
||||
onTriggered: imageLibraryList.newImage()
|
||||
onTriggered: {
|
||||
imageProxyModel.setFilterRegularExpression("");
|
||||
imageLibraryList.newImage();
|
||||
}
|
||||
/* visible: selectedLibrary == "images" */
|
||||
},
|
||||
|
||||
|
@ -1011,7 +1029,7 @@ Item {
|
|||
icon.name: "document-new"
|
||||
text: "New Presentation"
|
||||
tooltip: "Add a new presentation"
|
||||
onTriggered: presentationLibraryList.newPresentation()
|
||||
onTriggered: presentationLibraryList.newPresentation();
|
||||
/* visible: selectedLibrary == "presentations" */
|
||||
},
|
||||
|
||||
|
@ -1204,6 +1222,9 @@ Item {
|
|||
active: hovered || pressed
|
||||
}
|
||||
|
||||
function newPresentation() {
|
||||
presProxyModel.setFilterRegularExpression("");
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue