fix(qt): make QbzArrayModel load and render on Qt 6.8 and 6.9
The test-crates gate on Qt 6.8.3 failed to compile QbzArrayModel: DelegateModel.model has no change signal there, so onModelChanged was a non-existent property and the component, with AlbumView and the kiosk album and playlist lists, did not load. x86_64 Linux release builds use Qt 6.8.3; aarch64, macOS and Windows use 6.9.3. Assign the model from onRowsChanged instead, capturing the viewport before the swap. A probe also showed Qt 6.8.3 renders zero rows when the delegate is set on the view rather than on an external DelegateModel (6.11 forwards it), so the three hosts and the gate test now hand their delegate to the model. tst_array_model passes 6/6 on Qt 6.8.3 and 6.11.2; with Qt 6.8.3 qmllint, the six QML audits, all fifteen gate QML suites and the Node gate tests pass. cc
This commit is contained in:
5 files changed
+190
-163
No files matched your search
@@ -19,8 +19,16 @@
|
||||
// to that origin (0 = the header's top edge) before the change and restored
|
||||
// once it is laid out. A swap that replaces the page calls `scrollToTop()`.
|
||||
//
|
||||
// Probe that measured both behaviours against Qt 6.11.2:
|
||||
// Probe that measured both behaviours against Qt 6.11.2, and that must also
|
||||
// pass on the 6.8 LTS the x86_64 Linux release builds with:
|
||||
// scripts/qml-tests/tst_array_model.qml.
|
||||
//
|
||||
// `model` is ASSIGNED in onRowsChanged, never bound to `rows` with an
|
||||
// `onModelChanged` reaction: DelegateModel.model has no change signal on Qt
|
||||
// 6.8/6.9, so that handler made the whole component fail to load there
|
||||
// ("Cannot assign to non-existent property") — AlbumView and the kiosk lists
|
||||
// with it. Reacting to our own `rows` also captures the viewport before the
|
||||
// swap by construction instead of by binding order.
|
||||
|
||||
import QtQuick
|
||||
import QtQml.Models
|
||||
@@ -33,8 +41,6 @@ DelegateModel {
|
||||
/// The ListView (or GridView) this model feeds — needed for the restore.
|
||||
property Item view: null
|
||||
|
||||
model: rows
|
||||
|
||||
property bool _live: false
|
||||
property int _rowsBefore: 0
|
||||
property real _offset: 0
|
||||
@@ -42,23 +48,27 @@ DelegateModel {
|
||||
property bool _toTop: false
|
||||
|
||||
Component.onCompleted: {
|
||||
swap.model = swap.rows
|
||||
swap._live = true
|
||||
swap._rowsBefore = swap.count
|
||||
}
|
||||
|
||||
onModelChanged: {
|
||||
if (!swap._live || !swap.view)
|
||||
onRowsChanged: {
|
||||
// Before completion the first array is assigned by onCompleted.
|
||||
if (!swap._live)
|
||||
return
|
||||
var had = swap._rowsBefore
|
||||
swap._rowsBefore = swap.count
|
||||
// Nothing to keep: the page had no rows (first document, or the
|
||||
// empty document a detail publishes while the next one loads), or a
|
||||
// page replacement already asked for the top.
|
||||
if (had === 0 || swap._toTop)
|
||||
var keep = swap.view !== null && had !== 0 && !swap._toTop
|
||||
// Before the swap: how far the viewport sits below the content origin.
|
||||
if (keep)
|
||||
swap._offset = swap.view.contentY - swap.view.originY
|
||||
swap.model = swap.rows
|
||||
swap._rowsBefore = swap.count
|
||||
if (!keep)
|
||||
return
|
||||
// Before the pending remove+insert is laid out: how far the viewport
|
||||
// sits below the content origin.
|
||||
swap._offset = swap.view.contentY - swap.view.originY
|
||||
var epoch = ++swap._epoch
|
||||
Qt.callLater(function () {
|
||||
if (epoch !== swap._epoch || !swap.view)
|
||||
|
||||
@@ -74,7 +74,7 @@ Rectangle {
|
||||
// Swapped on a QbzArrayModel, never on `model:` — a fresh array there
|
||||
// makes Qt 6.11 focus delegate 0 and the header's search box loses the
|
||||
// keyboard on every keystroke (see the control's header).
|
||||
model: QbzArrayModel { id: rowsModel; view: list; rows: root.visibleTracks }
|
||||
model: QbzArrayModel { id: rowsModel; view: list; rows: root.visibleTracks; delegate: trackDelegate }
|
||||
cacheBuffer: height
|
||||
reuseItems: true
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
@@ -129,46 +129,51 @@ Rectangle {
|
||||
error:root.doc.error || ""
|
||||
}
|
||||
}
|
||||
delegate: Column {
|
||||
id: row
|
||||
required property var modelData
|
||||
required property int index
|
||||
width: list.width
|
||||
readonly property int disc: modelData.disc || 1
|
||||
readonly property bool startsDisc: index === 0 || (root.visibleTracks[index-1].disc || 1) !== disc
|
||||
Item {
|
||||
width: parent.width
|
||||
height: row.startsDisc ? 44 : 0
|
||||
visible: row.startsDisc
|
||||
Text { anchors.left: parent.left; anchors.verticalCenter: parent.verticalCenter; text: QbzSession.tr("Disc", QbzSession.trRev) + " " + row.disc; color: theme.textSecondary; font.pixelSize: 16 }
|
||||
SettingsButton {
|
||||
id: discButton
|
||||
kioskHost: true; anchors.right: parent.right
|
||||
iconName: "ellipsis"; minWidth: 44
|
||||
onClicked: discMenu.openBelowRight(discButton)
|
||||
// Handed to rowsModel: Qt 6.8/6.9 ignore a view's delegate when the
|
||||
// model is an external DelegateModel, and rendered zero rows.
|
||||
Component {
|
||||
id: trackDelegate
|
||||
Column {
|
||||
id: row
|
||||
required property var modelData
|
||||
required property int index
|
||||
width: list.width
|
||||
readonly property int disc: modelData.disc || 1
|
||||
readonly property bool startsDisc: index === 0 || (root.visibleTracks[index-1].disc || 1) !== disc
|
||||
Item {
|
||||
width: parent.width
|
||||
height: row.startsDisc ? 44 : 0
|
||||
visible: row.startsDisc
|
||||
Text { anchors.left: parent.left; anchors.verticalCenter: parent.verticalCenter; text: QbzSession.tr("Disc", QbzSession.trRev) + " " + row.disc; color: theme.textSecondary; font.pixelSize: 16 }
|
||||
SettingsButton {
|
||||
id: discButton
|
||||
kioskHost: true; anchors.right: parent.right
|
||||
iconName: "ellipsis"; minWidth: 44
|
||||
onClicked: discMenu.openBelowRight(discButton)
|
||||
}
|
||||
CardMenu {
|
||||
id: discMenu; kioskHost: true
|
||||
entries: [
|
||||
{label: QbzSession.tr("Play", QbzSession.trRev), action:"play"},
|
||||
{label: QbzSession.tr("Play next", QbzSession.trRev), action:"next"},
|
||||
{label: QbzSession.tr("Play later", QbzSession.trRev), action:"later"},
|
||||
{label: QbzSession.tr("Add to queue", QbzSession.trRev), action:"queue"}
|
||||
]
|
||||
onPicked: function(a) { QbzLocal.albumDiscAction(row.disc, a) }
|
||||
}
|
||||
}
|
||||
CardMenu {
|
||||
id: discMenu; kioskHost: true
|
||||
entries: [
|
||||
{label: QbzSession.tr("Play", QbzSession.trRev), action:"play"},
|
||||
{label: QbzSession.tr("Play next", QbzSession.trRev), action:"next"},
|
||||
{label: QbzSession.tr("Play later", QbzSession.trRev), action:"later"},
|
||||
{label: QbzSession.tr("Add to queue", QbzSession.trRev), action:"queue"}
|
||||
]
|
||||
onPicked: function(a) { QbzLocal.albumDiscAction(row.disc, a) }
|
||||
LocalTrackRow {
|
||||
width: parent.width; kioskHost: true
|
||||
item: row.modelData
|
||||
number: row.modelData.number > 0 ? row.modelData.number : row.index + 1
|
||||
showAlbum: false; showArtwork: false; zebra: true
|
||||
selectMode: root.multiSelect
|
||||
checked: root.selected[row.modelData.id] === true
|
||||
onPlayRequested: QbzLocal.albumSelectedAction("play", row.modelData.id)
|
||||
onEnqueueRequested: function(mode) { QbzLocal.enqueue("track", row.modelData.id, mode) }
|
||||
onToggleSelect: function(mods) { root.toggleSelected(row.modelData.id, mods) }
|
||||
}
|
||||
}
|
||||
LocalTrackRow {
|
||||
width: parent.width; kioskHost: true
|
||||
item: row.modelData
|
||||
number: row.modelData.number > 0 ? row.modelData.number : row.index + 1
|
||||
showAlbum: false; showArtwork: false; zebra: true
|
||||
selectMode: root.multiSelect
|
||||
checked: root.selected[row.modelData.id] === true
|
||||
onPlayRequested: QbzLocal.albumSelectedAction("play", row.modelData.id)
|
||||
onEnqueueRequested: function(mode) { QbzLocal.enqueue("track", row.modelData.id, mode) }
|
||||
onToggleSelect: function(mods) { root.toggleSelected(row.modelData.id, mods) }
|
||||
}
|
||||
}
|
||||
}
|
||||
CardMenu {
|
||||
|
||||
@@ -403,7 +403,7 @@ Rectangle {
|
||||
// Swapped on a QbzArrayModel, never on `model:` — a fresh array there
|
||||
// makes Qt 6.11 focus delegate 0, and the header's search box lost the
|
||||
// keyboard whenever a filtered document landed (see the control).
|
||||
model: QbzArrayModel { id: rowsModel; view: trackList; rows: root.tracks }
|
||||
model: QbzArrayModel { id: rowsModel; view: trackList; rows: root.tracks; delegate: trackDelegate }
|
||||
header: Column {
|
||||
width: trackList.width
|
||||
spacing: 12
|
||||
@@ -467,117 +467,122 @@ Rectangle {
|
||||
error:root.doc.error || ""
|
||||
}
|
||||
}
|
||||
delegate: TrackRow {
|
||||
kioskHost: true
|
||||
required property var modelData
|
||||
required property int index
|
||||
width: parent ? parent.width : 0
|
||||
item: modelData
|
||||
number: index + 1
|
||||
showArtwork: false
|
||||
showSource: root.isLocal || !root.online
|
||||
showAlbum: false
|
||||
artistLink: true
|
||||
showDownload: true
|
||||
// Alternating row tint, like the local album page
|
||||
// (LocalAlbumView.qml). TrackRow already owns the stripe —
|
||||
// it paints `#07ffffff` on even `number`s — so this is the
|
||||
// whole change.
|
||||
zebra: true
|
||||
selectMode: root.multiSelect
|
||||
checked: root.selected[item.id] === true
|
||||
onToggleSelect: function (mods) { root.toggleSelected(item.id, mods) }
|
||||
menuShowRemove: root.isOwner
|
||||
// Reorder chevrons (owner findings 5 + 8). `index` is the
|
||||
// index into `root.tracks`, which under `canReorder` is
|
||||
// the unfiltered document — the empty-search term of that
|
||||
// predicate is what guarantees it.
|
||||
showReorder: root.canReorder
|
||||
canMoveUp: index > 0
|
||||
canMoveDown: index < root.tracks.length - 1
|
||||
onMoveUpRequested: QbzBridge.playlistMoveRow(String(item.id), -1)
|
||||
onMoveDownRequested: QbzBridge.playlistMoveRow(String(item.id), 1)
|
||||
onPlayRequested: QbzBridge.playlistPlayTrack(item.id)
|
||||
onEnqueueRequested: function (m) { QbzBridge.playlistEnqueueTrack(item.id, m) }
|
||||
// The DISPLAY row id, as a string. For a Qobuz row it IS
|
||||
// the membership id (`playlist_qt.rs:363-364` sets both
|
||||
// from `track.id`); for a LOCAL row `playlistTrackId` is a
|
||||
// queue id — or 0 on an unresolved one — and the removal
|
||||
// has to be keyed on the id the position map knows.
|
||||
onRemoveRequested: QbzBridge.playlistRemoveTrack(String(item.id))
|
||||
// "Find available version" (contract §6.1) — the ONE
|
||||
// surface that offers it, and the gate is the reference's:
|
||||
// a QOBUZ playlist the signed-in user OWNS. Qobuz refuses
|
||||
// a write to anyone else's playlist, so offering it there
|
||||
// would be a dead action; a LOCAL playlist's rows are not
|
||||
// catalog memberships at all, and a mixed local/plex row in
|
||||
// this same view carries its own `source` word, which is
|
||||
// why the third term reads the row and not just the doc.
|
||||
routeReplaceExternally: root.isOwner && !root.isLocal
|
||||
&& (modelData.source || "") === ""
|
||||
// Everything Rust needs, in ONE JSON object (the
|
||||
// `QbzMyQbzAdd.open(JSON.stringify(...))` idiom). No row
|
||||
// INDEX is passed on purpose: `index` here is the index
|
||||
// into the DISPLAYED list, which under a search filter or a
|
||||
// non-default sort is not the playlist's own order — the
|
||||
// reposition step derives the real slot from the
|
||||
// authoritative playlist it re-fetches anyway.
|
||||
onReplaceRequested: QbzTrackReplace.open(JSON.stringify({
|
||||
"playlistId": String(root.doc.id || ""),
|
||||
"playlistTrackId": String(item.playlistTrackId || item.id),
|
||||
"trackId": String(item.id),
|
||||
"title": item.title || "",
|
||||
"artist": item.artist || "",
|
||||
"album": item.album || "",
|
||||
"isrc": item.isrc || "",
|
||||
"durationSecs": item.durationSecs || 0
|
||||
}))
|
||||
// "Add to playlist" — this view serves BOTH a Qobuz
|
||||
// playlist and a LOCAL one (`local_playlist_qt::load`
|
||||
// publishes into this same document through
|
||||
// `playlist_qt::adopt_doc`), so the row's id space is not
|
||||
// uniform here and the routing reads the row's own
|
||||
// `source` word ("" = Qobuz, "local" | "plex" = a
|
||||
// library.db / Plex ref). The local arm hands the DISPLAY
|
||||
// id to Rust, which resolves it through
|
||||
// `local_playlist_qt::local_picker_ref_for_row` — a Plex
|
||||
// row's rating key only exists in the open detail's queue
|
||||
// snapshot and QML cannot build the ref itself.
|
||||
routePlaylistAddExternally: modelData.source === "local"
|
||||
|| modelData.source === "plex"
|
||||
onPlaylistAddRequested: QbzPlaylistPicker.openForLocalRow(item.id)
|
||||
// MyQBZ "Add to mixtape" — the HOST builds the AddItem
|
||||
// array (TrackRow does not know itemType/source).
|
||||
//
|
||||
// SOURCE comes off the ROW, never a literal: a Qobuz
|
||||
// playlist's rows carry no `source` and are catalog rows,
|
||||
// while a LOCAL playlist's rows carry "local" | "plex"
|
||||
// (playlist_qt.rs PlaylistTrackRow.source). "plex" folds
|
||||
// into "local" because `AddItem.source` is
|
||||
// "qobuz" | "local" and `source_from_str`
|
||||
// (myqbz_add_qt.rs:85-90) maps anything that is not
|
||||
// "local" back to Qobuz — passing "plex" verbatim would
|
||||
// store a Plex row under a catalog id again.
|
||||
onMixtapeRequested: QbzMyQbzAdd.open(JSON.stringify([{
|
||||
"itemType": "track",
|
||||
"source": (item.source === "local" || item.source === "plex")
|
||||
? "local" : "qobuz",
|
||||
"sourceItemId": item.id, "title": item.title || "",
|
||||
"subtitle": item.artist || "", "artworkUrl": item.artUrl || "",
|
||||
"year": null, "trackCount": null
|
||||
}]))
|
||||
onBodyDragStarted: function (n) {
|
||||
// #589: report the source index BEFORE the shared drag.
|
||||
// Gated on `canReorder`, not on ownership alone: under
|
||||
// a computed sort (or an active search) this drag is
|
||||
// ONLY the add-to-a-sidebar-playlist gesture, and
|
||||
// claiming a source index would let a release inside
|
||||
// the list commit a move against an order that is not
|
||||
// the stored one.
|
||||
if (root.canReorder) {
|
||||
root.reorderFrom = index
|
||||
root.reorderOver = -1
|
||||
root.reorderDropPlaylist = ""
|
||||
// Handed to rowsModel: Qt 6.8/6.9 ignore a view's delegate when
|
||||
// the model is an external DelegateModel (zero rows).
|
||||
Component {
|
||||
id: trackDelegate
|
||||
TrackRow {
|
||||
kioskHost: true
|
||||
required property var modelData
|
||||
required property int index
|
||||
width: parent ? parent.width : 0
|
||||
item: modelData
|
||||
number: index + 1
|
||||
showArtwork: false
|
||||
showSource: root.isLocal || !root.online
|
||||
showAlbum: false
|
||||
artistLink: true
|
||||
showDownload: true
|
||||
// Alternating row tint, like the local album page
|
||||
// (LocalAlbumView.qml). TrackRow already owns the stripe —
|
||||
// it paints `#07ffffff` on even `number`s — so this is the
|
||||
// whole change.
|
||||
zebra: true
|
||||
selectMode: root.multiSelect
|
||||
checked: root.selected[item.id] === true
|
||||
onToggleSelect: function (mods) { root.toggleSelected(item.id, mods) }
|
||||
menuShowRemove: root.isOwner
|
||||
// Reorder chevrons (owner findings 5 + 8). `index` is the
|
||||
// index into `root.tracks`, which under `canReorder` is
|
||||
// the unfiltered document — the empty-search term of that
|
||||
// predicate is what guarantees it.
|
||||
showReorder: root.canReorder
|
||||
canMoveUp: index > 0
|
||||
canMoveDown: index < root.tracks.length - 1
|
||||
onMoveUpRequested: QbzBridge.playlistMoveRow(String(item.id), -1)
|
||||
onMoveDownRequested: QbzBridge.playlistMoveRow(String(item.id), 1)
|
||||
onPlayRequested: QbzBridge.playlistPlayTrack(item.id)
|
||||
onEnqueueRequested: function (m) { QbzBridge.playlistEnqueueTrack(item.id, m) }
|
||||
// The DISPLAY row id, as a string. For a Qobuz row it IS
|
||||
// the membership id (`playlist_qt.rs:363-364` sets both
|
||||
// from `track.id`); for a LOCAL row `playlistTrackId` is a
|
||||
// queue id — or 0 on an unresolved one — and the removal
|
||||
// has to be keyed on the id the position map knows.
|
||||
onRemoveRequested: QbzBridge.playlistRemoveTrack(String(item.id))
|
||||
// "Find available version" (contract §6.1) — the ONE
|
||||
// surface that offers it, and the gate is the reference's:
|
||||
// a QOBUZ playlist the signed-in user OWNS. Qobuz refuses
|
||||
// a write to anyone else's playlist, so offering it there
|
||||
// would be a dead action; a LOCAL playlist's rows are not
|
||||
// catalog memberships at all, and a mixed local/plex row in
|
||||
// this same view carries its own `source` word, which is
|
||||
// why the third term reads the row and not just the doc.
|
||||
routeReplaceExternally: root.isOwner && !root.isLocal
|
||||
&& (modelData.source || "") === ""
|
||||
// Everything Rust needs, in ONE JSON object (the
|
||||
// `QbzMyQbzAdd.open(JSON.stringify(...))` idiom). No row
|
||||
// INDEX is passed on purpose: `index` here is the index
|
||||
// into the DISPLAYED list, which under a search filter or a
|
||||
// non-default sort is not the playlist's own order — the
|
||||
// reposition step derives the real slot from the
|
||||
// authoritative playlist it re-fetches anyway.
|
||||
onReplaceRequested: QbzTrackReplace.open(JSON.stringify({
|
||||
"playlistId": String(root.doc.id || ""),
|
||||
"playlistTrackId": String(item.playlistTrackId || item.id),
|
||||
"trackId": String(item.id),
|
||||
"title": item.title || "",
|
||||
"artist": item.artist || "",
|
||||
"album": item.album || "",
|
||||
"isrc": item.isrc || "",
|
||||
"durationSecs": item.durationSecs || 0
|
||||
}))
|
||||
// "Add to playlist" — this view serves BOTH a Qobuz
|
||||
// playlist and a LOCAL one (`local_playlist_qt::load`
|
||||
// publishes into this same document through
|
||||
// `playlist_qt::adopt_doc`), so the row's id space is not
|
||||
// uniform here and the routing reads the row's own
|
||||
// `source` word ("" = Qobuz, "local" | "plex" = a
|
||||
// library.db / Plex ref). The local arm hands the DISPLAY
|
||||
// id to Rust, which resolves it through
|
||||
// `local_playlist_qt::local_picker_ref_for_row` — a Plex
|
||||
// row's rating key only exists in the open detail's queue
|
||||
// snapshot and QML cannot build the ref itself.
|
||||
routePlaylistAddExternally: modelData.source === "local"
|
||||
|| modelData.source === "plex"
|
||||
onPlaylistAddRequested: QbzPlaylistPicker.openForLocalRow(item.id)
|
||||
// MyQBZ "Add to mixtape" — the HOST builds the AddItem
|
||||
// array (TrackRow does not know itemType/source).
|
||||
//
|
||||
// SOURCE comes off the ROW, never a literal: a Qobuz
|
||||
// playlist's rows carry no `source` and are catalog rows,
|
||||
// while a LOCAL playlist's rows carry "local" | "plex"
|
||||
// (playlist_qt.rs PlaylistTrackRow.source). "plex" folds
|
||||
// into "local" because `AddItem.source` is
|
||||
// "qobuz" | "local" and `source_from_str`
|
||||
// (myqbz_add_qt.rs:85-90) maps anything that is not
|
||||
// "local" back to Qobuz — passing "plex" verbatim would
|
||||
// store a Plex row under a catalog id again.
|
||||
onMixtapeRequested: QbzMyQbzAdd.open(JSON.stringify([{
|
||||
"itemType": "track",
|
||||
"source": (item.source === "local" || item.source === "plex")
|
||||
? "local" : "qobuz",
|
||||
"sourceItemId": item.id, "title": item.title || "",
|
||||
"subtitle": item.artist || "", "artworkUrl": item.artUrl || "",
|
||||
"year": null, "trackCount": null
|
||||
}]))
|
||||
onBodyDragStarted: function (n) {
|
||||
// #589: report the source index BEFORE the shared drag.
|
||||
// Gated on `canReorder`, not on ownership alone: under
|
||||
// a computed sort (or an active search) this drag is
|
||||
// ONLY the add-to-a-sidebar-playlist gesture, and
|
||||
// claiming a source index would let a release inside
|
||||
// the list commit a move against an order that is not
|
||||
// the stored one.
|
||||
if (root.canReorder) {
|
||||
root.reorderFrom = index
|
||||
root.reorderOver = -1
|
||||
root.reorderDropPlaylist = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -852,6 +852,7 @@ Rectangle {
|
||||
id: cellsModel
|
||||
view: pageFlick
|
||||
rows: root.listCells
|
||||
delegate: cellsDelegate
|
||||
}
|
||||
reuseItems: true
|
||||
currentIndex: -1
|
||||
@@ -1782,7 +1783,10 @@ Rectangle {
|
||||
// The child paints over the inert cells reserved by buildTrackCells().
|
||||
// cacheBuffer keeps the root alive until the overflowing child is well
|
||||
// outside the viewport, and creates the next heavy row asynchronously.
|
||||
delegate: DelegateChooser {
|
||||
// Handed to cellsModel: Qt 6.8/6.9 ignore a view's delegate when the
|
||||
// model is an external DelegateModel, and rendered zero rows.
|
||||
DelegateChooser {
|
||||
id: cellsDelegate
|
||||
role: "kind"
|
||||
|
||||
DelegateChoice {
|
||||
|
||||
Reference in new issue
Block a user