Skip to content

Commit

Permalink
Update system objects in LayoutPanelTreeModel::updateSystemobjectLayers
Browse files Browse the repository at this point in the history
even for the already existing ones
  • Loading branch information
mike-spa committed Feb 20, 2025
1 parent e611748 commit 427ab3b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/instrumentsscene/view/layoutpaneltreemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,17 +969,17 @@ void LayoutPanelTreeModel::updateSystemObjectLayers()

// Remove old system object layers
std::vector<const PartTreeItem*> partItems;
std::vector<const SystemObjectsLayerTreeItem*> existingSystemObjectLayers;
std::vector<SystemObjectsLayerTreeItem*> existingSystemObjectLayers;

for (const AbstractLayoutPanelTreeItem* item : children) {
for (AbstractLayoutPanelTreeItem* item : children) {
if (item->type() != LayoutPanelItemType::SYSTEM_OBJECTS_LAYER) {
if (item->type() == LayoutPanelItemType::PART) {
partItems.push_back(static_cast<const PartTreeItem*>(item));
}
continue;
}

auto layerItem = static_cast<const SystemObjectsLayerTreeItem*>(item);
auto layerItem = static_cast<SystemObjectsLayerTreeItem*>(item);
if (muse::remove(newSystemObjectStaves, const_cast<Staff*>(layerItem->staff()))) {
existingSystemObjectLayers.push_back(layerItem);
continue;
Expand All @@ -992,7 +992,7 @@ void LayoutPanelTreeModel::updateSystemObjectLayers()
}

// Update position of existing layers if changed
for (const SystemObjectsLayerTreeItem* layerItem : existingSystemObjectLayers) {
for (SystemObjectsLayerTreeItem* layerItem : existingSystemObjectLayers) {
const PartTreeItem* partItem = findPartItemByStaff(layerItem->staff());
IF_ASSERT_FAILED(partItem) {
continue;
Expand All @@ -1006,6 +1006,8 @@ void LayoutPanelTreeModel::updateSystemObjectLayers()
m_rootItem->moveChildren(layerRow, 1, m_rootItem, partRow, false /*updateNotation*/);
endMoveRows();
}

layerItem->updateSystemObjects();
}

if (newSystemObjectStaves.empty()) {
Expand Down
7 changes: 6 additions & 1 deletion src/instrumentsscene/view/systemobjectslayertreeitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ void SystemObjectsLayerTreeItem::setStaff(const Staff* staff)
}
}

void SystemObjectsLayerTreeItem::updateSystemObjects()
{
m_systemObjectGroups = collectSystemObjectGroups(m_staff);
updateState();
}

QString SystemObjectsLayerTreeItem::staffId() const
{
const Staff* s = staff();
Expand Down Expand Up @@ -178,7 +184,6 @@ void SystemObjectsLayerTreeItem::onUndoStackChanged(const mu::engraving::ScoreCh
}

if (shouldUpdateState) {
m_systemObjectGroups = collectSystemObjectGroups(m_staff);
updateState();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/instrumentsscene/view/systemobjectslayertreeitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class SystemObjectsLayerTreeItem : public AbstractLayoutPanelTreeItem, public mu

const mu::engraving::Staff* staff() const;
void setStaff(const mu::engraving::Staff* staff);
void updateSystemObjects();

Q_INVOKABLE QString staffId() const;
Q_INVOKABLE bool canAcceptDrop(const QVariant& item) const override;
Expand Down

0 comments on commit 427ab3b

Please sign in to comment.