From bde99fd4fbb9c100ec2ef47f78550ed7624e8f94 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Fri, 16 Oct 2026 00:57:14 +0200 Subject: [PATCH 1/2] Fix qmltyperegistrar "used as base type but cannot be found" warnings qmltyperegistrar only knows the metatypes of the libraries a QML module links against, so modules deriving from types in muse_uicomponents_qml must link it, not just import it. SelectableItemListModel::Item could not be found at all, because moc does not support Q_OBJECT in nested classes; it is now the top-level SelectableItem. Co-Authored-By: Claude Opus 5.5 --- .../qml/Muse/Extensions/CMakeLists.txt | 2 ++ .../UiComponents/selectableitemlistmodel.cpp | 2 +- .../Muse/UiComponents/selectableitemlistmodel.h | 17 +++++++++-------- .../workspace/qml/Muse/Workspace/CMakeLists.txt | 2 ++ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/framework/extensions/qml/Muse/Extensions/CMakeLists.txt b/framework/extensions/qml/Muse/Extensions/CMakeLists.txt index 0c8bee4562..0799f5fbf0 100644 --- a/framework/extensions/qml/Muse/Extensions/CMakeLists.txt +++ b/framework/extensions/qml/Muse/Extensions/CMakeLists.txt @@ -56,5 +56,7 @@ qt_add_qml_module(muse_extensions_qml fixup_qml_module_dependencies(muse_extensions_qml) +target_link_libraries(muse_extensions_qml PRIVATE muse::uicomponents_qml) + # Necessary for the auto-generated sources target_include_directories(muse_extensions_qml PRIVATE devtools) diff --git a/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.cpp b/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.cpp index f2d9d32d44..f65dce8fd9 100644 --- a/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.cpp +++ b/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.cpp @@ -26,7 +26,7 @@ using namespace muse::uicomponents; -SelectableItemListModel::Item::Item(QObject* parent) +SelectableItem::SelectableItem(QObject* parent) : QObject(parent) { } diff --git a/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.h b/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.h index bfab473825..74dfb8efad 100644 --- a/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.h +++ b/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.h @@ -28,6 +28,14 @@ #include "itemmultiselectionmodel.h" namespace muse::uicomponents { +class SelectableItem : public QObject +{ + Q_OBJECT + +public: + explicit SelectableItem(QObject* parent = nullptr); +}; + class SelectableItemListModel : public QAbstractListModel { Q_OBJECT @@ -42,14 +50,7 @@ class SelectableItemListModel : public QAbstractListModel Q_PROPERTY(bool hasSelection READ hasSelection NOTIFY selectionChanged) public: - class Item : public QObject - { - public: - virtual ~Item() = default; - - explicit Item(QObject* parent = nullptr); - }; - + using Item = SelectableItem; using ItemList = QList; explicit SelectableItemListModel(QObject* parent = nullptr); diff --git a/framework/workspace/qml/Muse/Workspace/CMakeLists.txt b/framework/workspace/qml/Muse/Workspace/CMakeLists.txt index 1386759f4d..31bc4411e3 100644 --- a/framework/workspace/qml/Muse/Workspace/CMakeLists.txt +++ b/framework/workspace/qml/Muse/Workspace/CMakeLists.txt @@ -21,3 +21,5 @@ qt_add_qml_module(muse_workspace_qml ) fixup_qml_module_dependencies(muse_workspace_qml) + +target_link_libraries(muse_workspace_qml PRIVATE muse::uicomponents_qml) From fc873c7d5cd70232844d178155b2a85f1d10f014 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Fri, 16 Oct 2026 01:09:00 +0200 Subject: [PATCH 2/2] SelectableItemListModel: hold plain QObjects SelectableItem added nothing over QObject: the model only stores the items, and subclasses cast them to their own type anyway. Co-Authored-By: Claude Opus 5.5 --- .../Muse/UiComponents/selectableitemlistmodel.cpp | 9 ++------- .../Muse/UiComponents/selectableitemlistmodel.h | 15 +++------------ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.cpp b/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.cpp index f65dce8fd9..5422e6c3fe 100644 --- a/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.cpp +++ b/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.cpp @@ -26,11 +26,6 @@ using namespace muse::uicomponents; -SelectableItem::SelectableItem(QObject* parent) - : QObject(parent) -{ -} - SelectableItemListModel::SelectableItemListModel(QObject* parent) : QAbstractListModel(parent), m_selection(new ItemMultiSelectionModel(this)) { @@ -238,7 +233,7 @@ const SelectableItemListModel::ItemList& SelectableItemListModel::items() const return m_items; } -SelectableItemListModel::Item* SelectableItemListModel::item(const QModelIndex& index) const +QObject* SelectableItemListModel::item(const QModelIndex& index) const { int row = index.row(); @@ -263,7 +258,7 @@ void SelectableItemListModel::setItems(const ItemList& items) emit countChanged(); } -void SelectableItemListModel::insertItem(int row, Item* item) +void SelectableItemListModel::insertItem(int row, QObject* item) { TRACEFUNC; diff --git a/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.h b/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.h index 74dfb8efad..6c57a21c94 100644 --- a/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.h +++ b/framework/uicomponents/qml/Muse/UiComponents/selectableitemlistmodel.h @@ -28,14 +28,6 @@ #include "itemmultiselectionmodel.h" namespace muse::uicomponents { -class SelectableItem : public QObject -{ - Q_OBJECT - -public: - explicit SelectableItem(QObject* parent = nullptr); -}; - class SelectableItemListModel : public QAbstractListModel { Q_OBJECT @@ -50,8 +42,7 @@ class SelectableItemListModel : public QAbstractListModel Q_PROPERTY(bool hasSelection READ hasSelection NOTIFY selectionChanged) public: - using Item = SelectableItem; - using ItemList = QList; + using ItemList = QList; explicit SelectableItemListModel(QObject* parent = nullptr); @@ -90,10 +81,10 @@ class SelectableItemListModel : public QAbstractListModel virtual void onRowsRemoved(); const ItemList& items() const; - Item* item(const QModelIndex& index) const; + QObject* item(const QModelIndex& index) const; void setItems(const ItemList& items); - void insertItem(int row, Item* item); + void insertItem(int row, QObject* item); void setIsMovingUpAvailable(bool isMovingUpAvailable); void setIsMovingDownAvailable(bool isMovingDownAvailable);