Skip to content

Commit

Permalink
Don't allow adding more system object layer if full
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-spa committed Feb 21, 2025
1 parent ea9ffc0 commit 3bac6e8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/instrumentsscene/view/layoutpaneltreemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ LayoutPanelTreeModel::LayoutPanelTreeModel(QObject* parent)
updateRearrangementAvailability();
updateRemovingAvailability();
updateSelectedItemsType();
emit isAddingSystemMarkingsAvailableChanged(isAddingSystemMarkingsAvailable());
});

connect(this, &LayoutPanelTreeModel::rowsInserted, this, [this]() {
Expand Down Expand Up @@ -428,6 +429,8 @@ void LayoutPanelTreeModel::addSystemMarkings()
if (const Staff* staff = resolveNewSystemObjectStaff()) {
m_masterNotation->parts()->addSystemObjects({ staff->id() });
}

emit isAddingSystemMarkingsAvailableChanged(isAddingSystemMarkingsAvailable());
}

void LayoutPanelTreeModel::moveSelectedRowsUp()
Expand Down Expand Up @@ -705,7 +708,18 @@ bool LayoutPanelTreeModel::isAddingAvailable() const

bool LayoutPanelTreeModel::isAddingSystemMarkingsAvailable() const
{
return isAddingAvailable() && m_notation->isMaster();
if (!isAddingAvailable() || !m_notation->isMaster()) {
return false;
}

int systemLayerCount = 0;
for (const AbstractLayoutPanelTreeItem* item : m_rootItem->childItems()) {
if (item->type() == LayoutPanelItemType::SYSTEM_OBJECTS_LAYER) {
++systemLayerCount;
}
}

return systemLayerCount < 0.5 * m_rootItem->childCount();
}

bool LayoutPanelTreeModel::isEmpty() const
Expand Down

0 comments on commit 3bac6e8

Please sign in to comment.