From 3cfe15a9c3db0993d8b8fef5d148625840e5a75c Mon Sep 17 00:00:00 2001
From: Sine Striker <trueful@163.com>
Date: 周二, 05 12月 2023 15:43:39 +0800
Subject: [PATCH] Add host interface

---
 src/quick/quickitemdelegate.cpp |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/quick/quickitemdelegate.cpp b/src/quick/quickitemdelegate.cpp
index 0483f44..aa85204 100644
--- a/src/quick/quickitemdelegate.cpp
+++ b/src/quick/quickitemdelegate.cpp
@@ -11,15 +11,34 @@
     QuickItemDelegate::~QuickItemDelegate() = default;
 
     QWindow *QuickItemDelegate::window(QObject *obj) const {
-        return qobject_cast<QQuickItem *>(obj)->window();
+        return static_cast<QQuickItem *>(obj)->window();
     }
 
     bool QuickItemDelegate::isEnabled(QObject *obj) const {
-        return qobject_cast<QQuickItem *>(obj)->isEnabled();
+        return static_cast<QQuickItem *>(obj)->isEnabled();
     }
 
     bool QuickItemDelegate::isVisible(QObject *obj) const {
-        return qobject_cast<QQuickItem *>(obj)->isVisible();
+        return static_cast<QQuickItem *>(obj)->isVisible();
+    }
+
+    QRect QuickItemDelegate::mapGeometryToScene(const QObject *obj) const {
+        auto item = static_cast<const QQuickItem *>(obj);
+        const QPointF originPoint = item->mapToScene(QPointF(0.0, 0.0));
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
+        const QSizeF size = item->size();
+#else
+        const QSizeF size = {item->width(), item->height()};
+#endif
+        return QRectF(originPoint, size).toRect();
+    }
+
+    QWindow *QuickItemDelegate::hostWindow(QObject *host) const {
+        return static_cast<QQuickWindow *>(host);
+    }
+
+    bool QuickItemDelegate::isHostSizeFixed(QObject *host) const {
+        return false;
     }
 
 }
\ No newline at end of file

--
Gitblit v1.9.1