diff --git a/src/View.cpp b/src/View.cpp index 5725570e..83af9c90 100644 --- a/src/View.cpp +++ b/src/View.cpp @@ -33,10 +33,9 @@ namespace KDDockWidgets { static qint64 s_nextId = 1; } -View::View(Controller *controller, Type type, QObject *thisObj) +View::View(Controller *controller, Type type) : d(new Private()) , m_controller(controller) - , m_thisObj(thisObj) , m_id(QString::number(KDDockWidgets::s_nextId++)) , m_type(type) { @@ -330,11 +329,6 @@ QScreen *View::screen() const return nullptr; } -HANDLE View::handle() const -{ - return m_thisObj; -} - void View::setAboutToBeDestroyed() { m_aboutToBeDestroyed = true; diff --git a/src/View.h b/src/View.h index 473a7d87..b4eff99c 100644 --- a/src/View.h +++ b/src/View.h @@ -17,7 +17,6 @@ #include // TODOm4 Remove Qt headers, introduce Size and Rect structs #include -#include #include @@ -58,7 +57,7 @@ using WId = quintptr; class DOCKS_EXPORT View { public: - explicit View(Controller *controller, Type, QObject *thisObj); + explicit View(Controller *controller, Type); virtual ~View(); virtual void init() {}; @@ -67,7 +66,7 @@ public: /// This value only makes sense to the frontend. For example, for QtQuick it might be a /// QQuickItem, while for QtWidgets it's a QWidget *. Can be whatever the frontend developer wants, /// as long as it uniquely identifies the GUI element. KDDW backend only uses it for comparison purposes - HANDLE handle() const; + virtual HANDLE handle() const = 0; /// @brief Returns whether the gui item represented by this view was already deleted /// Usually false, as KDDW internal gui elements inherit View, and nobody will access them after destruction. @@ -292,7 +291,6 @@ protected: free_impl(); Controller *const m_controller; - QObject *const m_thisObj; bool m_inDtor = false; private: diff --git a/src/dummy/views/View_dummy.cpp b/src/dummy/views/View_dummy.cpp index fa1b6942..b3815c8a 100644 --- a/src/dummy/views/View_dummy.cpp +++ b/src/dummy/views/View_dummy.cpp @@ -21,7 +21,7 @@ using namespace KDDockWidgets::Views; View_dummy::View_dummy(KDDockWidgets::Controller *controller, Type type, void * /*parent*/, Qt::WindowFlags) // replace void with your type - : View(controller, type, nullptr) // TODO pass parent + : View(controller, type) { } diff --git a/src/qtcommon/View_qt.cpp b/src/qtcommon/View_qt.cpp index dba73258..4fd41368 100644 --- a/src/qtcommon/View_qt.cpp +++ b/src/qtcommon/View_qt.cpp @@ -84,7 +84,7 @@ public: }; View_qt::View_qt(Controller *controller, Type type, QObject *thisObj) - : View(controller, type, thisObj) + : View(controller, type) , m_eventFilter(thisObj ? new EventFilter(this, thisObj) : nullptr) , m_thisObj(thisObj) { @@ -102,6 +102,11 @@ QObject *View_qt::thisObject() const return m_thisObj; } +KDDockWidgets::HANDLE View_qt::handle() const +{ + return m_thisObj; +} + void View_qt::setObjectName(const QString &name) { if (m_thisObj) { diff --git a/src/qtcommon/View_qt.h b/src/qtcommon/View_qt.h index 7d00f67b..ae159a81 100644 --- a/src/qtcommon/View_qt.h +++ b/src/qtcommon/View_qt.h @@ -33,6 +33,7 @@ public: QObject *thisObject() const; + HANDLE handle() const override; void setObjectName(const QString &name) override; static QObject *asQObject(View *);