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