[vlc-commits] [Git][videolan/vlc][master] qml: do not navigate to invisible or disabled delegate instance in `ListViewExt`

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Mon Jun 8 09:56:19 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
706bcb2d by Fatih Uzunoglu at 2026-06-08T11:38:33+02:00
qml: do not navigate to invisible or disabled delegate instance in `ListViewExt`

If the delegate instance is invisible or disabled, key navigation should not
apply to them.

This change helps extending `ListView` to support tree models.

- - - - -


1 changed file:

- modules/gui/qt/widgets/qml/ListViewExt.qml


Changes:

=====================================
modules/gui/qt/widgets/qml/ListViewExt.qml
=====================================
@@ -498,42 +498,59 @@ ListView {
     }
 
     Keys.onPressed: (event) => {
-        let newIndex = -1
-
-        if (orientation === ListView.Vertical)
-        {
-            if ( KeyHelper.matchDown(event) ) {
-                if (currentIndex !== count - 1 )
-                    newIndex = currentIndex + 1
-                else if ( root.keyNavigationWraps )
-                    newIndex = 0
-            } else if ( KeyHelper.matchPageDown(event) ) {
-                newIndex = Math.min(count - 1, currentIndex + 10)
-            } else if ( KeyHelper.matchUp(event) ) {
-                if ( currentIndex !== 0 )
-                    newIndex = currentIndex - 1
-                else if ( root.keyNavigationWraps )
-                    newIndex = count - 1
-            } else if ( KeyHelper.matchPageUp(event) ) {
-                newIndex = Math.max(0, currentIndex - 10)
-            }
-        }else{
-            if ( KeyHelper.matchRight(event) ) {
-                if (currentIndex !== count - 1 )
-                    newIndex = currentIndex + 1
-                else if ( root.keyNavigationWraps )
-                    newIndex = 0
+        let newIndex = currentIndex
+
+        let target = undefined
+        let suppressPageModifier = false
+
+        while (target === undefined || !target.visible || !target.enabled) {
+            if (orientation === ListView.Vertical) {
+                if ( suppressPageModifier || KeyHelper.matchDown(event) ) {
+                    if (currentIndex !== count - 1 )
+                        newIndex += 1
+                    else if ( root.keyNavigationWraps )
+                        newIndex = 0
+                } else if ( !suppressPageModifier && KeyHelper.matchPageDown(event) ) {
+                    newIndex = Math.min(count - 1, newIndex + 10)
+                } else if ( suppressPageModifier || KeyHelper.matchUp(event) ) {
+                    if ( newIndex !== 0 )
+                        newIndex -= 1
+                    else if ( root.keyNavigationWraps )
+                        newIndex = count - 1
+                } else if ( !suppressPageModifier && KeyHelper.matchPageUp(event) ) {
+                    newIndex = Math.max(0, newIndex - 10)
+                }
+            } else {
+                if ( suppressPageModifier || KeyHelper.matchRight(event) ) {
+                    if (newIndex !== count - 1 )
+                        newIndex += 1
+                    else if ( root.keyNavigationWraps )
+                        newIndex = 0
+                }
+                else if ( !suppressPageModifier && KeyHelper.matchPageDown(event) ) {
+                    newIndex = Math.min(count - 1, newIndex + 10)
+                } else if ( suppressPageModifier || KeyHelper.matchLeft(event) ) {
+                    if ( newIndex !== 0 )
+                        newIndex -= 1
+                    else if ( root.keyNavigationWraps )
+                        newIndex = count - 1
+                } else if ( !suppressPageModifier && KeyHelper.matchPageUp(event) ) {
+                    newIndex = Math.max(0, newIndex - 10)
+                }
             }
-            else if ( KeyHelper.matchPageDown(event) ) {
-                newIndex = Math.min(count - 1, currentIndex + 10)
-            } else if ( KeyHelper.matchLeft(event) ) {
-                if ( currentIndex !== 0 )
-                    newIndex = currentIndex - 1
-                else if ( root.keyNavigationWraps )
-                    newIndex = count - 1
-            } else if ( KeyHelper.matchPageUp(event) ) {
-                newIndex = Math.max(0, currentIndex - 10)
+
+            const newTarget = root.itemAtIndex(newIndex)
+
+            if (newTarget === null || newTarget === target) {
+                root.Navigation.defaultKeyAction(event)
+                return
+            } else if (!newTarget.visible || !newTarget.enabled) {
+                if (KeyHelper.matchPageDown(event) || KeyHelper.matchPageUp(event)) {
+                    suppressPageModifier = true
+                }
             }
+
+            target = newTarget
         }
 
         if (event.matches(StandardKey.SelectAll)) {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/706bcb2d8f10cd9b8de2893621ea03483991077d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/706bcb2d8f10cd9b8de2893621ea03483991077d
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list