De-Alpinizadas con el patrón del gate H-Qt (dinámico, wrappers zig cc/c++ en árbol de fuente, CMAKE_PREFIX_PATH=/usr para hallar qtbase sellado, examples/tests off). Deps por STEM de archivo (resolver por filename). Cadena a H-QML: qtbase(✓) → qtshadertools → qtdeclarative (+ qtsvg + qtlanguageserver). Farm desde snapshot KDE 407438750 (qtbase cache-hit). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
106 lines
4.9 KiB
Diff
106 lines
4.9 KiB
Diff
From e635da3faf6dac654b2591204162a217a6f02766 Mon Sep 17 00:00:00 2001
|
|
From: Richard Moe Gustavsen <richard.gustavsen@qt.io>
|
|
Date: Mon, 27 Apr 2026 10:23:44 +0200
|
|
Subject: [PATCH 1153/1427] QQmlTableInstanceModel: refactor QModelIndex
|
|
calculation out of QQuickTableView
|
|
|
|
The QQmlTableInstanceModel can derive the QModelIndex itself from the
|
|
flat index, so there is no need for a separate object(QModelIndex)
|
|
overload.
|
|
|
|
Amends de4b7283c978ca384f6c8bf9f27387158804b601
|
|
|
|
Pick-to: 6.11
|
|
Change-Id: I9dfff8026ef0acca660f1211b0e453c46562985f
|
|
Reviewed-by: SanthoshKumar Selvaraj <santhosh.kumar.selvaraj@qt.io>
|
|
---
|
|
src/qmlmodels/qqmltableinstancemodel.cpp | 31 ++++++++++--------------
|
|
src/qmlmodels/qqmltableinstancemodel_p.h | 1 -
|
|
src/quick/items/qquicktableview.cpp | 10 +-------
|
|
3 files changed, 14 insertions(+), 28 deletions(-)
|
|
|
|
diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp
|
|
index dc73a17b78..5bc35a1190 100644
|
|
--- a/src/qmlmodels/qqmltableinstancemodel.cpp
|
|
+++ b/src/qmlmodels/qqmltableinstancemodel.cpp
|
|
@@ -165,26 +165,21 @@ QObject *QQmlTableInstanceModel::object(int index, QQmlIncubator::IncubationMode
|
|
{
|
|
Q_ASSERT(m_delegate);
|
|
|
|
- QQmlDelegateModelItem *modelItem = resolveModelItem(index, QModelIndex());
|
|
- if (!modelItem)
|
|
- return nullptr;
|
|
-
|
|
- // Return the incubated object, or start an async incubation task and return nullptr for now
|
|
- return incubateModelItemIfNeeded(modelItem, incubationMode);
|
|
-}
|
|
-
|
|
-QObject *QQmlTableInstanceModel::object(const QModelIndex &modelIndex, QQmlIncubator::IncubationMode incubationMode)
|
|
-{
|
|
- Q_ASSERT(m_delegate);
|
|
- Q_ASSERT(m_adaptorModel.adaptsAim());
|
|
+ QModelIndex modelIndex;
|
|
+ if (const QAbstractItemModel *aim = abstractItemModel()) {
|
|
+ // A valid QModelIndex is needed for resolveModelItem() to match
|
|
+ // items in the release cache rather than just delegate type alone.
|
|
+ const int row = m_adaptorModel.rowAt(index);
|
|
+ const int column = m_adaptorModel.columnAt(index);
|
|
+ modelIndex = aim->index(row, column);
|
|
+ }
|
|
|
|
- const int flatIndex = m_adaptorModel.indexAt(modelIndex.row(), modelIndex.column());
|
|
- QQmlDelegateModelItem *modelItem = resolveModelItem(flatIndex, modelIndex);
|
|
- if (!modelItem)
|
|
- return nullptr;
|
|
+ if (QQmlDelegateModelItem *modelItem = resolveModelItem(index, modelIndex)) {
|
|
+ // Return the incubated object, or start an async incubation task and return nullptr for now
|
|
+ return incubateModelItemIfNeeded(modelItem, incubationMode);
|
|
+ }
|
|
|
|
- // Return the incubated object, or start an async incubation task and return nullptr for now
|
|
- return incubateModelItemIfNeeded(modelItem, incubationMode);
|
|
+ return nullptr;
|
|
}
|
|
|
|
QObject *QQmlTableInstanceModel::incubateModelItemIfNeeded(QQmlDelegateModelItem *modelItem, QQmlIncubator::IncubationMode incubationMode)
|
|
diff --git a/src/qmlmodels/qqmltableinstancemodel_p.h b/src/qmlmodels/qqmltableinstancemodel_p.h
|
|
index 23b6ef1597..a890b16a43 100644
|
|
--- a/src/qmlmodels/qqmltableinstancemodel_p.h
|
|
+++ b/src/qmlmodels/qqmltableinstancemodel_p.h
|
|
@@ -86,7 +86,6 @@ public:
|
|
const QAbstractItemModel *abstractItemModel() const override;
|
|
|
|
QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override;
|
|
- QObject *object(const QModelIndex &index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested);
|
|
QObject *incubateModelItemIfNeeded(QQmlDelegateModelItem *modelItem, QQmlIncubator::IncubationMode incubationMode);
|
|
void restoreFromReleasedItemsCache(QQmlDelegateModelItem *item, int newFlatIndex);
|
|
void commitReleasedItems();
|
|
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
|
|
index 729d95e5f7..8e1666c4d9 100644
|
|
--- a/src/quick/items/qquicktableview.cpp
|
|
+++ b/src/quick/items/qquicktableview.cpp
|
|
@@ -2826,19 +2826,11 @@ FxTableItem *QQuickTableViewPrivate::createFxTableItem(const QPoint &cell, QQmlI
|
|
Q_Q(QQuickTableView);
|
|
|
|
bool ownItem = false;
|
|
- QObject* object = nullptr;
|
|
- const QAbstractItemModel *aim = model->abstractItemModel();
|
|
const int modelRow = isTransposed ? logicalColumnIndex(cell.y()) : logicalRowIndex(cell.y());
|
|
const int modelColumn = isTransposed ? logicalRowIndex(cell.x()) : logicalColumnIndex(cell.x());
|
|
const int modelIndex = modelIndexAtCell(QPoint(modelColumn, modelRow));
|
|
|
|
- if (tableModel && aim) {
|
|
- // Prefer loading via QModelIndex so that QQmlTableInstanceModel can also
|
|
- // match recently released items by model index, not just by delegate type.
|
|
- object = tableModel->object(aim->index(modelRow, modelColumn), incubationMode);
|
|
- } else {
|
|
- object = model->object(modelIndex, incubationMode);
|
|
- }
|
|
+ QObject *object = model->object(modelIndex, incubationMode);
|
|
|
|
if (!object) {
|
|
if (model->incubationStatus(modelIndex) == QQmlIncubator::Loading) {
|
|
--
|
|
2.54.0
|
|
|