[vlc-devel] [PATCH 2/3] qt: support searching in NetworkBrowseDisplay
Prince Gupta
guptaprince8832 at gmail.com
Tue Sep 29 11:11:13 CEST 2020
---
.../qt/network/qml/NetworkBrowseDisplay.qml | 33 +++++++++++++------
modules/gui/qt/network/qml/NetworkDisplay.qml | 4 +++
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
index 98774c40d8..01d9ac8edc 100644
--- a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
+++ b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
@@ -32,6 +32,7 @@ import "qrc:///style/"
Widgets.NavigableFocusScope {
id: root
+ property alias model: filterModel
property var providerModel
property var tree
onTreeChanged: providerModel.tree = tree
@@ -43,9 +44,21 @@ Widgets.NavigableFocusScope {
history.push(["mc", "network", { tree: new_tree }]);
}
+ function playSelected() {
+ providerModel.addAndPlay( filterModel.mapIndexesToSource( selectionModel.selectedIndexes ) )
+ }
+
Util.SelectableDelegateModel{
id: selectionModel
- model: providerModel
+
+ model: filterModel
+ }
+
+ SortFilterProxyModel {
+ id: filterModel
+
+ sourceModel: providerModel
+ searchRole: "name"
}
NetworkMediaContextMenu {
@@ -55,9 +68,9 @@ Widgets.NavigableFocusScope {
function resetFocus() {
var initialIndex = root.initialIndex
- if (initialIndex >= providerModel.count)
+ if (initialIndex >= filterModel.count)
initialIndex = 0
- selectionModel.select(providerModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
+ selectionModel.select(filterModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
if (view.currentItem) {
view.currentItem.currentIndex = initialIndex
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
@@ -67,14 +80,14 @@ Widgets.NavigableFocusScope {
function _actionAtIndex(index) {
if ( selectionModel.selectedIndexes.length > 1 ) {
- providerModel.addAndPlay( selectionModel.selectedIndexes )
+ playSelected()
} else {
- var data = providerModel.getDataAt(index)
+ var data = filterModel.getDataAt(index)
if (data.type === NetworkMediaModel.TYPE_DIRECTORY
|| data.type === NetworkMediaModel.TYPE_NODE) {
changeTree(data.tree)
} else {
- providerModel.addAndPlay( selectionModel.selectedIndexes )
+ providerModel.addAndPlay( filterModel.mapIndexToSource(index) )
}
}
}
@@ -86,7 +99,7 @@ Widgets.NavigableFocusScope {
id: gridView
delegateModel: selectionModel
- model: providerModel
+ model: filterModel
headerDelegate: Widgets.NavigableFocusScope {
width: view.width
@@ -148,7 +161,7 @@ Widgets.NavigableFocusScope {
if (model.type === NetworkMediaModel.TYPE_NODE || model.type === NetworkMediaModel.TYPE_DIRECTORY)
changeTree(model.tree)
else
- selectionModel.model.addAndPlay( index )
+ providerModel.addAndPlay( filterModel.mapIndexToSource(index) )
}
onContextMenuButtonClicked: {
@@ -188,12 +201,12 @@ Widgets.NavigableFocusScope {
}
property Component thumbnailColumn: NetworkThumbnailItem {
- onPlayClicked: providerModel.addAndPlay(index)
+ onPlayClicked: providerModel.addAndPlay( filterModel.mapIndexToSource(index) )
}
height: view.height
width: view.width
- model: providerModel
+ model: filterModel
selectionDelegateModel: selectionModel
focus: true
headerColor: VLCStyle.colors.bg
diff --git a/modules/gui/qt/network/qml/NetworkDisplay.qml b/modules/gui/qt/network/qml/NetworkDisplay.qml
index 574d0d2150..5184d6fbcb 100644
--- a/modules/gui/qt/network/qml/NetworkDisplay.qml
+++ b/modules/gui/qt/network/qml/NetworkDisplay.qml
@@ -35,6 +35,8 @@ Widgets.NavigableFocusScope {
onTreeChanged: loadView()
Component.onCompleted: loadView()
+ property var contentModel
+
//reset view
function loadDefaultView() {
root.tree = undefined
@@ -50,6 +52,8 @@ Widgets.NavigableFocusScope {
props = { providerModel: mediaModel, tree: root.tree }
}
view.replace(page, props)
+ if (view.currentItem.model)
+ root.contentModel = view.currentItem.model
}
NetworkMediaModel {
--
2.25.1
More information about the vlc-devel
mailing list