[vlc-devel] [PATCH 01/16] qml: provide hasSelection property in SelectableDelegateModel
Pierre Lamot
pierre at videolabs.io
Wed May 27 17:06:42 CEST 2020
---
modules/gui/qt/medialibrary/qml/MusicAlbums.qml | 2 +-
modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml | 2 +-
modules/gui/qt/medialibrary/qml/MusicGenres.qml | 4 ++--
modules/gui/qt/medialibrary/qml/VideoDisplay.qml | 4 ++--
modules/gui/qt/network/qml/NetworkBrowseDisplay.qml | 2 +-
modules/gui/qt/util/qml/SelectableDelegateModel.qml | 3 ++-
modules/gui/qt/widgets/qml/KeyNavigableTableView.qml | 2 +-
7 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
index 8779ba9a05..a6f6785414 100644
--- a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
@@ -110,7 +110,7 @@ Widgets.NavigableFocusScope {
}
onCountChanged: {
- if (delegateModelId.items.count > 0 && delegateModelId.selectedGroup.count === 0) {
+ if (delegateModelId.items.count > 0 && !delegateModelId.hasSelection) {
root.resetFocus()
}
}
diff --git a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
index d4e35e4286..e6164c6e20 100644
--- a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
@@ -68,7 +68,7 @@ Widgets.NavigableFocusScope {
}
onCountChanged: {
- if (delegateModel.items.count > 0 && delegateModel.selectedGroup.count === 0) {
+ if (delegateModel.items.count > 0 && !delegateModel.hasSelection) {
var initialIndex = root.initialIndex
if (initialIndex >= delegateModel.items.count)
initialIndex = 0
diff --git a/modules/gui/qt/medialibrary/qml/MusicGenres.qml b/modules/gui/qt/medialibrary/qml/MusicGenres.qml
index 3722616dfd..49f0bd493b 100644
--- a/modules/gui/qt/medialibrary/qml/MusicGenres.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicGenres.qml
@@ -126,7 +126,7 @@ Widgets.NavigableFocusScope {
}
onCountChanged: {
- if (delegateModelId.items.count > 0 && delegateModelId.selectedGroup.count === 0) {
+ if (delegateModelId.items.count > 0 && !delegateModelId.hasSelection) {
root.resetFocus()
}
}
@@ -149,7 +149,7 @@ Widgets.NavigableFocusScope {
* selectedGroup update itself after this event
*/
onActiveFocusChanged: {
- if (activeFocus && delegateModelId.items.count > 0 && delegateModelId.selectedGroup.count === 0) {
+ if (activeFocus && delegateModelId.items.count > 0 && !delegateModelId.hasSelection) {
var initialIndex = 0
if (view.currentItem.currentIndex !== -1)
initialIndex = view.currentItem.currentIndex
diff --git a/modules/gui/qt/medialibrary/qml/VideoDisplay.qml b/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
index f9cdd2e773..23c370b7ea 100644
--- a/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
@@ -125,7 +125,7 @@ Widgets.NavigableFocusScope {
}
onCountChanged: {
- if (videosDelegate.items.count > 0 && videosDelegate.selectedGroup.count === 0) {
+ if (videosDelegate.items.count > 0 && !videosDelegate.hasSelection) {
root.resetFocus()
}
}
@@ -195,7 +195,7 @@ Widgets.NavigableFocusScope {
* selectedGroup update itself after this event
*/
onActiveFocusChanged: {
- if (activeFocus && videosDelegate.items.count > 0 && videosDelegate.selectedGroup.count === 0) {
+ if (activeFocus && videosDelegate.items.count > 0 && !videosDelegate.hasSelection) {
videosDelegate.items.get(0).inSelected = true
}
}
diff --git a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
index 209e270c9d..305fed3307 100644
--- a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
+++ b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
@@ -45,7 +45,7 @@ Widgets.NavigableFocusScope {
}
function resetFocus() {
- if (delegateModelId.items.count > 0 && delegateModelId.selectedGroup.count === 0) {
+ if (providerModel.count > 0 && !delegateModelId.hasSelection) {
var initialIndex = 0
if (delegateModelId.currentIndex !== -1)
initialIndex = delegateModelId.currentIndex
diff --git a/modules/gui/qt/util/qml/SelectableDelegateModel.qml b/modules/gui/qt/util/qml/SelectableDelegateModel.qml
index 445d278a56..6a18d39611 100644
--- a/modules/gui/qt/util/qml/SelectableDelegateModel.qml
+++ b/modules/gui/qt/util/qml/SelectableDelegateModel.qml
@@ -23,6 +23,7 @@ DelegateModel {
property int shiftIndex: -1
property alias selectedGroup: selectedGroup
+ readonly property bool hasSelection: selectedGroup.count > 0
groups: [
DelegateModelGroup { id: selectedGroup; name: "selected"; includeByDefault: false }
@@ -40,7 +41,7 @@ DelegateModel {
}
function selectNone() {
- if (selectedGroup.count > 0)
+ if (hasSelection)
selectedGroup.remove(0,selectedGroup.count)
}
diff --git a/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml b/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
index ad59f7ff8e..c96013f719 100644
--- a/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
+++ b/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
@@ -224,7 +224,7 @@ NavigableFocusScope {
* selectedGroup update itself after this event
*/
onActiveFocusChanged: {
- if (activeFocus && delegateModel.items.count > 0 && delegateModel.selectedGroup.count === 0) {
+ if (activeFocus && view.count > 0 && !delegateModel.hasSelection) {
var initialIndex = 0
if (view.currentIndex !== -1)
initialIndex = view.currentIndex
--
2.25.1
More information about the vlc-devel
mailing list