diff --git a/src/inspector/models/abstractinspectormodel.cpp b/src/inspector/models/abstractinspectormodel.cpp index f98dea1293f3..a932e5519d59 100644 --- a/src/inspector/models/abstractinspectormodel.cpp +++ b/src/inspector/models/abstractinspectormodel.cpp @@ -121,19 +121,14 @@ AbstractInspectorModel::AbstractInspectorModel(QObject* parent, IElementReposito return; } - setupCurrentNotationChangedConnection(); - connect(m_repository->getQObject(), SIGNAL(elementsUpdated(const QList&)), this, SLOT(updateProperties())); connect(this, &AbstractInspectorModel::requestReloadPropertyItems, this, &AbstractInspectorModel::updateProperties); } -void AbstractInspectorModel::setupCurrentNotationChangedConnection() +void AbstractInspectorModel::init() { onCurrentNotationChanged(); - currentNotationChanged().onNotify(this, [this]() { - onCurrentNotationChanged(); - }); } void AbstractInspectorModel::onCurrentNotationChanged() diff --git a/src/inspector/models/abstractinspectormodel.h b/src/inspector/models/abstractinspectormodel.h index 40a291be85ea..db84b42de487 100644 --- a/src/inspector/models/abstractinspectormodel.h +++ b/src/inspector/models/abstractinspectormodel.h @@ -131,6 +131,8 @@ class AbstractInspectorModel : public QObject, public async::Asyncable explicit AbstractInspectorModel(QObject* parent, IElementRepositoryService* repository = nullptr, mu::engraving::ElementType elementType = mu::engraving::ElementType::INVALID); + void init(); + Q_INVOKABLE virtual void requestResetToDefaults(); QString title() const; @@ -151,6 +153,8 @@ class AbstractInspectorModel : public QObject, public async::Asyncable virtual void requestElements(); + virtual void onCurrentNotationChanged(); + public slots: void setTitle(QString title); void setIcon(ui::IconCode::Code icon); @@ -201,7 +205,6 @@ public slots: notation::INotationSelectionPtr selection() const; - virtual void onCurrentNotationChanged(); virtual void onNotationChanged(const mu::engraving::PropertyIdSet& changedPropertyIdSet, const mu::engraving::StyleIdSet& changedStyleIdSet); @@ -215,8 +218,6 @@ protected slots: void updateProperties(); private: - void setupCurrentNotationChangedConnection(); - void initPropertyItem(PropertyItem* propertyItem, std::function onPropertyChangedCallBack = nullptr, std::function emit modelsChanged(); } +void AbstractInspectorProxyModel::onCurrentNotationChanged() +{ + for (AbstractInspectorModel* model : modelList()) { + model->onCurrentNotationChanged(); + } + + AbstractInspectorModel::onCurrentNotationChanged(); +} + void AbstractInspectorProxyModel::updateModels(const ElementKeySet& newElementKeySet) { QList models; diff --git a/src/inspector/models/abstractinspectorproxymodel.h b/src/inspector/models/abstractinspectorproxymodel.h index 967a38819165..edd0bc66b2c4 100644 --- a/src/inspector/models/abstractinspectorproxymodel.h +++ b/src/inspector/models/abstractinspectorproxymodel.h @@ -74,6 +74,8 @@ public slots: void setModels(const QList& models); private: + void onCurrentNotationChanged() override; + QHash m_modelsHash; InspectorModelType m_defaultSubModelType = InspectorModelType::TYPE_UNDEFINED; }; diff --git a/src/inspector/models/inspectorlistmodel.cpp b/src/inspector/models/inspectorlistmodel.cpp index 4a35cf5ad777..ca22348a491a 100644 --- a/src/inspector/models/inspectorlistmodel.cpp +++ b/src/inspector/models/inspectorlistmodel.cpp @@ -44,6 +44,8 @@ InspectorListModel::InspectorListModel(QObject* parent) listenSelectionChanged(); context()->currentNotationChanged().onNotify(this, [this]() { listenSelectionChanged(); + + notifyModelsAboutNotationChanged(); }); } @@ -157,29 +159,36 @@ void InspectorListModel::createModelsBySectionType(const QListinit(); + m_modelList << newModel; + } + endInsertRows(); } } @@ -272,6 +281,15 @@ AbstractInspectorModel* InspectorListModel::modelBySectionType(InspectorSectionT return nullptr; } +void InspectorListModel::notifyModelsAboutNotationChanged() +{ + TRACEFUNC; + + for (AbstractInspectorModel* model : m_modelList) { + model->onCurrentNotationChanged(); + } +} + void InspectorListModel::listenSelectionChanged() { auto updateElementList = [this]() { diff --git a/src/inspector/models/inspectorlistmodel.h b/src/inspector/models/inspectorlistmodel.h index 8e5942987292..d63d76b977ed 100644 --- a/src/inspector/models/inspectorlistmodel.h +++ b/src/inspector/models/inspectorlistmodel.h @@ -72,6 +72,8 @@ class InspectorListModel : public QAbstractListModel, public mu::async::Asyncabl AbstractInspectorModel* modelBySectionType(InspectorSectionType sectionType) const; + void notifyModelsAboutNotationChanged(); + QList m_modelList; IElementRepositoryService* m_repository = nullptr;