sergio/takana
> Una distribución Linux construida con un laboratorio funcional y hermético en el > sótano, y una terminal mutable, clásica y anárquica en el piso de arriba — diseñada > desde el suelo para que una IA programadora entienda, modifique y co…
⎇ main
recipes/incoming-kde/0001-QQmlTableInstanceModel-refactor-QModelIndex-calculat.patch
Historia
crudo
kde/H-QML: recetas Capa 1 qtshadertools/qtsvg/qtlanguageserver/qtdeclarative
1From e635da3faf6dac654b2591204162a217a6f02766 Mon Sep 17 00:00:00 2001
2From: Richard Moe Gustavsen <richard.gustavsen@qt.io>
3Date: Mon, 27 Apr 2026 10:23:44 +0200
4Subject: [PATCH 1153/1427] QQmlTableInstanceModel: refactor QModelIndex
5 calculation out of QQuickTableView
6
7The QQmlTableInstanceModel can derive the QModelIndex itself from the
8flat index, so there is no need for a separate object(QModelIndex)
9overload.
10
11Amends de4b7283c978ca384f6c8bf9f27387158804b601
12
13Pick-to: 6.11
14Change-Id: I9dfff8026ef0acca660f1211b0e453c46562985f
15Reviewed-by: SanthoshKumar Selvaraj <santhosh.kumar.selvaraj@qt.io>
16---
17 src/qmlmodels/qqmltableinstancemodel.cpp | 31 ++++++++++--------------
18 src/qmlmodels/qqmltableinstancemodel_p.h | 1 -
19 src/quick/items/qquicktableview.cpp | 10 +-------
20 3 files changed, 14 insertions(+), 28 deletions(-)
21
22diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp
23index dc73a17b78..5bc35a1190 100644
24--- a/src/qmlmodels/qqmltableinstancemodel.cpp
25+++ b/src/qmlmodels/qqmltableinstancemodel.cpp
26@@ -165,26 +165,21 @@ QObject *QQmlTableInstanceModel::object(int index, QQmlIncubator::IncubationMode
27 {
28 Q_ASSERT(m_delegate);
29
30- QQmlDelegateModelItem *modelItem = resolveModelItem(index, QModelIndex());
31- if (!modelItem)
32- return nullptr;
33-
34- // Return the incubated object, or start an async incubation task and return nullptr for now
35- return incubateModelItemIfNeeded(modelItem, incubationMode);
36-}
37-
38-QObject *QQmlTableInstanceModel::object(const QModelIndex &modelIndex, QQmlIncubator::IncubationMode incubationMode)
39-{
40- Q_ASSERT(m_delegate);
41- Q_ASSERT(m_adaptorModel.adaptsAim());
42+ QModelIndex modelIndex;
43+ if (const QAbstractItemModel *aim = abstractItemModel()) {
44+ // A valid QModelIndex is needed for resolveModelItem() to match
45+ // items in the release cache rather than just delegate type alone.
46+ const int row = m_adaptorModel.rowAt(index);
47+ const int column = m_adaptorModel.columnAt(index);
48+ modelIndex = aim->index(row, column);
49+ }
50
51- const int flatIndex = m_adaptorModel.indexAt(modelIndex.row(), modelIndex.column());
52- QQmlDelegateModelItem *modelItem = resolveModelItem(flatIndex, modelIndex);
53- if (!modelItem)
54- return nullptr;
55+ if (QQmlDelegateModelItem *modelItem = resolveModelItem(index, modelIndex)) {
56+ // Return the incubated object, or start an async incubation task and return nullptr for now
57+ return incubateModelItemIfNeeded(modelItem, incubationMode);
58+ }
59
60- // Return the incubated object, or start an async incubation task and return nullptr for now
61- return incubateModelItemIfNeeded(modelItem, incubationMode);
62+ return nullptr;
63 }
64
65 QObject *QQmlTableInstanceModel::incubateModelItemIfNeeded(QQmlDelegateModelItem *modelItem, QQmlIncubator::IncubationMode incubationMode)
66diff --git a/src/qmlmodels/qqmltableinstancemodel_p.h b/src/qmlmodels/qqmltableinstancemodel_p.h
67index 23b6ef1597..a890b16a43 100644
68--- a/src/qmlmodels/qqmltableinstancemodel_p.h
69+++ b/src/qmlmodels/qqmltableinstancemodel_p.h
70@@ -86,7 +86,6 @@ public:
71 const QAbstractItemModel *abstractItemModel() const override;
72
73 QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override;
74- QObject *object(const QModelIndex &index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested);
75 QObject *incubateModelItemIfNeeded(QQmlDelegateModelItem *modelItem, QQmlIncubator::IncubationMode incubationMode);
76 void restoreFromReleasedItemsCache(QQmlDelegateModelItem *item, int newFlatIndex);
77 void commitReleasedItems();
78diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
79index 729d95e5f7..8e1666c4d9 100644
80--- a/src/quick/items/qquicktableview.cpp
81+++ b/src/quick/items/qquicktableview.cpp
82@@ -2826,19 +2826,11 @@ FxTableItem *QQuickTableViewPrivate::createFxTableItem(const QPoint &cell, QQmlI
83 Q_Q(QQuickTableView);
84
85 bool ownItem = false;
86- QObject* object = nullptr;
87- const QAbstractItemModel *aim = model->abstractItemModel();
88 const int modelRow = isTransposed ? logicalColumnIndex(cell.y()) : logicalRowIndex(cell.y());
89 const int modelColumn = isTransposed ? logicalRowIndex(cell.x()) : logicalColumnIndex(cell.x());
90 const int modelIndex = modelIndexAtCell(QPoint(modelColumn, modelRow));
91
92- if (tableModel && aim) {
93- // Prefer loading via QModelIndex so that QQmlTableInstanceModel can also
94- // match recently released items by model index, not just by delegate type.
95- object = tableModel->object(aim->index(modelRow, modelColumn), incubationMode);
96- } else {
97- object = model->object(modelIndex, incubationMode);
98- }
99+ QObject *object = model->object(modelIndex, incubationMode);
100
101 if (!object) {
102 if (model->incubationStatus(modelIndex) == QQmlIncubator::Loading) {
103--
1042.54.0
105