void StaffListItem::setStaffType(const StaffType* st) { if (!st) // if no staff type given, dault to stadard _staffTypeCombo->setCurrentIndex(0); // staff type (at combo box index 0) else { // if staff type given, look into combo box item data for a preset equal to staff type for (int i = 0; i < _staffTypeCombo->count(); ++i) { const StaffType* _st = StaffType::preset(StaffTypes(_staffTypeCombo->itemData(i).toInt())); if (*_st == *st) { _staffTypeCombo->setCurrentIndex(i); return; } } // try harder for (int i = 0; i < _staffTypeCombo->count(); ++i) { const StaffType* _st = StaffType::preset(StaffTypes(_staffTypeCombo->itemData(i).toInt())); if (_st->isSameStructure(*st)) { _staffTypeCombo->setCurrentIndex(i); return; } } qDebug("StaffListItem::setStaffType: not found\n"); _staffTypeCombo->setCurrentIndex(0); // if none found, default to standard staff type } }
const StaffType* StaffListItem::staffType() const { int typeIdx = staffTypeIdx(); Q_ASSERT(typeIdx != CUSTOM_STAFF_TYPE_IDX); if (typeIdx == CUSTOM_STAFF_TYPE_IDX) typeIdx = 0; return StaffType::preset(StaffTypes(typeIdx)); }
/* void EditStaffType::loadFromTemplateClicked() { StaffTypeTemplates stt(staffType); if (stt.exec()) { StaffType* st = stt.staffType(); staffType = *st; setValues(); updatePreview(); } } */ void EditStaffType::resetToTemplateClicked() { int idx = templateCombo->itemData(templateCombo->currentIndex()).toInt(); if (idx >= 0) { staffType = *(StaffType::preset(StaffTypes(idx))); setValues(); } }
void StaffListItem::staffTypeChanged(int idx) { // check current clef matches new staff type int staffTypeIdx = _staffTypeCombo->itemData(idx).toInt(); const StaffType* stfType = StaffType::preset(StaffTypes(staffTypeIdx)); PartListItem* pli = static_cast<PartListItem*>(QTreeWidgetItem::parent()); pli->updateClefs(); if (_staff && _staff->staffType()->name() != stfType->name()) { if (_op != ListItemOp::I_DELETE && _op != ListItemOp::ADD) _op = ListItemOp::UPDATE; } }
void StaffListItem::setStaffType(const StaffType* st) { if (!st) // if no staff type given, dault to stadard _staffTypeCombo->setCurrentIndex(0); // staff type (at combo box index 0) else { // if staff type given, look into combo box item data for a preset equal to staff type for (int i = 0; i < _staffTypeCombo->count(); ++i) { const StaffType* _st = StaffType::preset(StaffTypes(_staffTypeCombo->itemData(i).toInt())); if (*_st == *st) { _staffTypeCombo->setCurrentIndex(i); return; } } // try harder for (int i = 0; i < _staffTypeCombo->count(); ++i) { const StaffType* _st = StaffType::preset(StaffTypes(_staffTypeCombo->itemData(i).toInt())); if (_st->isSameStructure(*st)) { _staffTypeCombo->setCurrentIndex(i); return; } } int idx = 0; switch (st->group()) { case StaffGroup::STANDARD: idx = customStandardIdx; break; case StaffGroup::PERCUSSION: idx = customPercussionIdx; break; case StaffGroup::TAB: idx = customTablatureIdx; break; } _staffTypeCombo->setCurrentIndex(idx); } }
void StaffListItem::staffTypeChanged(int idx) { // check current clef matches new staff type const int typeIdx = staffTypeIdx(idx); if (typeIdx == CUSTOM_STAFF_TYPE_IDX) // consider it not changed return; const StaffType* stfType = StaffType::preset(StaffTypes(typeIdx)); PartListItem* pli = static_cast<PartListItem*>(QTreeWidgetItem::parent()); pli->updateClefs(); if (_staff && _staff->staffType(0)->name() != stfType->name()) { if (_op != ListItemOp::I_DELETE && _op != ListItemOp::ADD) _op = ListItemOp::UPDATE; } }
void PartListItem::updateClefs() { for (int i = 0; i < childCount(); ++i) { StaffListItem* sli = static_cast<StaffListItem*>(child(i)); const StaffType* stfType = StaffType::preset(StaffTypes(sli->staffTypeIdx())); ClefTypeList clefType; switch (stfType->group()) { case StaffGroup::STANDARD: clefType = sli->defaultClefType(); break; case StaffGroup::TAB: clefType = ClefTypeList(ClefType::TAB); break; case StaffGroup::PERCUSSION: clefType = ClefTypeList(ClefType::PERC); break; } sli->setClefType(clefType); } }
const StaffType* StaffListItem::staffType() const { return StaffType::preset(StaffTypes((staffTypeIdx()))); }