fix(qt): Shift and Ctrl work on every select-mode click target, not only the row body

Excel-style selection (750c59034) read the modifiers only where a row BODY
took the click. Every other target a select-mode surface draws dropped them,
so a Shift-click there was a plain toggle:

  - the track row's checkbox disc passed Qt.NoModifier;
  - QbzCheckbox and SelectCheck emitted toggled() with no argument, so the
    Library album rows, the local album rows and the folder rows, which
    already expected `function (mods)`, received undefined;
  - AlbumCard emitted selectToggled() with no argument, and the paged local
    albums grid (299dcde5b) spelled the drop out as Qt.NoModifier.

Some targets were never selection targets at all: in select mode the artist
and album names on a track row, the artist and label on a Library album row
and the artist line of an album card still navigated, leaving the page and
the selection mid-gesture. The row links stand down in select mode so the
click reaches the row body with its modifiers, and the card's artist line
toggles like its artwork and title. A hover-only tooltip on the pulled but
cached glyph no longer eats the row's click.

Reproduced on the release binary in a nested KWin with injected input: in
Local Library Tracks, the checkbox discs of rows 1, Shift 4 and Ctrl 6
selected 3 rows; the same clicks on the row bodies selected 5. No list
view, Flickable or wheel code changes; tst_wheel passes unchanged.

tst_multi_select clicks each of these targets through the real TrackRow,
AlbumListRow, AlbumCard, QbzCheckbox and SelectCheck.

cc
This commit is contained in:
vicrodh committed 2026-09-14 10:30:34 -06:00
1 parent 7d1a144c89
commit 7c9bf8043f
12 files changed
+360 -23

No files matched your search

@@ -0,0 +1,7 @@
pragma Singleton
import QtQuick
QtObject {
property var opened: []
function openAlbum(id) { opened = opened.concat([String(id)]) }
function openAlbumFrom(id, title, artist) { opened = opened.concat([String(id)]) }
}
@@ -0,0 +1,6 @@
pragma Singleton
import QtQuick
QtObject {
property var opened: []
function openArtist(id) { opened = opened.concat([String(id)]) }
}
@@ -0,0 +1,6 @@
pragma Singleton
import QtQuick
QtObject {
property var labels: []
function openLabel(id) { labels = labels.concat([String(id)]) }
}
@@ -0,0 +1,6 @@
pragma Singleton
import QtQuick
QtObject {
property var submitted: []
function searchSubmit(text) { submitted = submitted.concat([String(text)]) }
}
@@ -9,3 +9,7 @@ singleton QbzPurchases 1.0 QbzPurchases.qml
singleton QbzOrbit 1.0 QbzOrbit.qml
singleton QbzAbout 1.0 QbzAbout.qml
singleton QbzArtist 1.0 QbzArtist.qml
singleton QbzAlbum 1.0 QbzAlbum.qml
singleton QbzSearch 1.0 QbzSearch.qml
singleton QbzHome 1.0 QbzHome.qml
+267
View File
@@ -8,11 +8,278 @@ import QtQuick
import QtTest
import com.blitzfc.qbz
import "../../crates/qbz-qt/qml/controls"
import "../../crates/qbz-qt/qml/rows"
import "../../crates/qbz-qt/qml/cards"
import "../../crates/qbz-qt/qml/views" as Views
import "../../crates/qbz-qt/qml/views/local" as Local
Item {
id: root
width: 1200; height: 1400
function track(i) {
return { "id": "t" + i, "title": "Track " + i, "artist": "Artist " + i,
"artistId": "a" + i, "album": "Album " + i, "albumId": "al" + i,
"duration": "3:00", "qualityTier": "", "qualityDetail": "" }
}
function album(i) {
return { "id": "b" + i, "title": "Record " + i, "artist": "Band " + i,
"artistId": "band" + i, "label": "Label " + i, "labelId": "l" + i,
"year": "2001", "qualityTier": "", "qualityDetail": "" }
}
function range(n, make) {
var out = []
for (var i = 0; i < n; i++)
out.push(make(i))
return out
}
// ---- the track list (AlbumView / PlaylistView wiring) -------------------
property var tracks: range(8, track)
property var trackSelected: ({})
SelectionModel { id: trackSel }
function toggleTrack(id, mods) {
root.trackSelected = trackSel.next(root.trackSelected, id, root.tracks,
mods === undefined ? Qt.NoModifier : mods)
}
Column {
id: trackColumn
width: 1000
Repeater {
id: trackRepeater
model: root.tracks
delegate: TrackRow {
required property var modelData
required property int index
width: 1000
item: modelData
number: index + 1
artistLink: true
showAlbum: true
selectMode: true
checked: root.trackSelected[modelData.id] === true
onToggleSelect: function (mods) { root.toggleTrack(modelData.id, mods) }
}
}
}
// ---- the album list (Library albums list wiring) ------------------------
property var albums: range(6, album)
property var albumSelected: ({})
SelectionModel { id: albumSel }
function toggleAlbum(id, mods) {
root.albumSelected = albumSel.next(root.albumSelected, id, root.albums,
mods === undefined ? Qt.NoModifier : mods)
}
Column {
id: albumColumn
y: 420
width: 1000
Repeater {
id: albumRepeater
model: root.albums
delegate: Views.AlbumListRow {
required property var modelData
required property int index
width: 1000
item: modelData
rowIndex: index
selectMode: true
checked: root.albumSelected[modelData.id] === true
onToggleSelect: function (mods) { root.toggleAlbum(modelData.id, mods) }
}
}
}
// ---- one album card and the two checkbox controls ------------------------
property var cardMods: []
AlbumCard {
id: card
x: 1000; y: 0
albumId: "card"
title: "Card title"
artist: "Card artist"
artistId: "card-artist"
selectMode: true
onSelectToggled: function (mods) { root.cardMods = root.cardMods.concat([mods]) }
}
property var checkboxMods: []
QbzCheckbox {
id: checkbox
x: 1000; y: 320
onToggled: function (mods) { root.checkboxMods = root.checkboxMods.concat([mods]) }
}
property var selectCheckMods: []
Local.SelectCheck {
id: selectCheck
x: 1040; y: 320
onToggled: function (mods) { root.selectCheckMods = root.selectCheckMods.concat([mods]) }
}
TestCase {
name: "MultiSelect"
when: windowShown
function find(item, pred) {
if (!item)
return null
if (pred(item))
return item
var kids = item.children || []
for (var i = 0; i < kids.length; i++) {
var hit = find(kids[i], pred)
if (hit)
return hit
}
return null
}
function shown(item) {
for (var it = item; it; it = it.parent)
if (!it.visible)
return false
return true
}
function textItem(host, text) {
var t = find(host, function (it) {
return it.text === text && it.contentWidth !== undefined && shown(it)
})
verify(t !== null, "text '" + text + "' is drawn")
return t
}
// Clicks go through the window at the item's position, so whichever
// MouseArea really sits on top there receives them — the point of
// using the real components.
function clickOn(item, x, y, mods) {
var p = item.mapToItem(root, x, y)
mouseClick(root, p.x, p.y, Qt.LeftButton, mods === undefined ? Qt.NoModifier : mods)
wait(20)
}
function selectedIds(map) {
return Object.keys(map).sort().join(",")
}
function trackRow(i) { return trackRepeater.itemAt(i) }
function albumRow(i) { return albumRepeater.itemAt(i) }
function disc(row) {
var d = find(row, function (it) {
return it.width === 14 && it.height === 14 && it.hoverEnabled !== undefined
&& it.cursorShape !== undefined && shown(it)
})
verify(d !== null, "the select-mode disc is drawn")
return d
}
function init() {
root.trackSelected = ({})
trackSel.anchorId = ""
root.albumSelected = ({})
albumSel.anchorId = ""
root.cardMods = []
root.checkboxMods = []
root.selectCheckMods = []
QbzArtist.opened = []
QbzAlbum.opened = []
QbzHome.labels = []
}
// A point of the row with nothing drawn over it but the body: the
// duration cell.
function bodyPoint(row) {
var duration = textItem(row, "3:00")
return duration.mapToItem(row, duration.width / 2, duration.height / 2)
}
function clickBody(row, mods) {
var p = bodyPoint(row)
clickOn(row, p.x, p.y, mods)
}
function test_row_body_shift_and_ctrl() {
clickBody(trackRow(1))
clickBody(trackRow(4), Qt.ShiftModifier)
compare(selectedIds(root.trackSelected), "t1,t2,t3,t4")
clickBody(trackRow(6), Qt.ControlModifier)
compare(selectedIds(root.trackSelected), "t1,t2,t3,t4,t6")
}
function test_checkbox_disc_shift_and_ctrl() {
clickOn(disc(trackRow(0)), 7, 7)
clickOn(disc(trackRow(3)), 7, 7, Qt.ShiftModifier)
compare(selectedIds(root.trackSelected), "t0,t1,t2,t3",
"Shift on the disc selects the range")
clickOn(disc(trackRow(5)), 7, 7, Qt.ControlModifier)
clickOn(disc(trackRow(7)), 7, 7, Qt.ControlModifier | Qt.ShiftModifier)
compare(selectedIds(root.trackSelected), "t0,t1,t2,t3,t5,t6,t7",
"Ctrl adds a row and Ctrl+Shift adds a second group")
}
function test_artist_link_selects_in_select_mode() {
clickBody(trackRow(2))
var name = textItem(trackRow(5), "Artist 5")
clickOn(name, 10, name.height / 2, Qt.ShiftModifier)
compare(QbzArtist.opened.length, 0, "no artist page opens in select mode")
compare(selectedIds(root.trackSelected), "t2,t3,t4,t5")
}
function test_album_link_selects_in_select_mode() {
var name = textItem(trackRow(6), "Album 6")
clickOn(name, 10, name.height / 2)
compare(QbzAlbum.opened.length, 0, "no album page opens in select mode")
compare(selectedIds(root.trackSelected), "t6")
}
function test_album_row_checkbox_shift_range() {
var first = find(albumRow(0), function (it) {
return it.checked !== undefined && it.width === 18 && it.height === 18 && shown(it)
})
var fourth = find(albumRow(3), function (it) {
return it.checked !== undefined && it.width === 18 && it.height === 18 && shown(it)
})
verify(first !== null && fourth !== null, "the album row checkboxes are drawn")
clickOn(first, 9, 9)
clickOn(fourth, 9, 9, Qt.ShiftModifier)
compare(selectedIds(root.albumSelected), "b0,b1,b2,b3")
}
function test_album_row_links_select_in_select_mode() {
clickOn(albumRow(1), 600, 32)
var band = textItem(albumRow(4), "Band 4")
clickOn(band, 10, band.height / 2, Qt.ShiftModifier)
compare(QbzArtist.opened.length, 0, "no artist page opens in select mode")
var label = textItem(albumRow(5), "Label 5")
clickOn(label, 10, label.height / 2, Qt.ControlModifier)
compare(QbzHome.labels.length, 0, "no label page opens in select mode")
compare(selectedIds(root.albumSelected), "b1,b2,b3,b4,b5")
}
function test_album_card_forwards_modifiers() {
clickOn(card, 100, 100, Qt.ShiftModifier)
var title = textItem(card, "Card title")
clickOn(title, 10, title.height / 2, Qt.ControlModifier)
var artist = textItem(card, "Card artist")
clickOn(artist, 10, artist.height / 2, Qt.ShiftModifier)
compare(QbzArtist.opened.length, 0, "no artist page opens in select mode")
compare(root.cardMods.length, 3)
verify((root.cardMods[0] & Qt.ShiftModifier) !== 0, "artwork carries Shift")
verify((root.cardMods[1] & Qt.ControlModifier) !== 0, "title carries Ctrl")
verify((root.cardMods[2] & Qt.ShiftModifier) !== 0, "artist line carries Shift")
}
function test_checkbox_controls_forward_modifiers() {
clickOn(checkbox, 9, 9, Qt.ShiftModifier)
clickOn(selectCheck, 6, 6, Qt.ControlModifier)
compare(root.checkboxMods.length, 1)
verify((root.checkboxMods[0] & Qt.ShiftModifier) !== 0, "QbzCheckbox carries Shift")
compare(root.selectCheckMods.length, 1)
verify((root.selectCheckMods[0] & Qt.ControlModifier) !== 0, "SelectCheck carries Ctrl")
checkbox.forceActiveFocus()
keyClick(Qt.Key_Space)
compare(root.checkboxMods.length, 2)
compare(root.checkboxMods[1] & Qt.ShiftModifier, 0, "the keyboard toggle is a plain toggle")
}
}
// ---- the selection rule itself ---------------------------------------------
SelectionModel { id: rule }
SelectionModel { id: keyedRule; idKey: "trackId" }