various optimizations

This commit is contained in:
Roman Pudashkin 2022-03-03 13:32:59 +02:00
parent f79ba8b9e8
commit d749518297
2 changed files with 63 additions and 4 deletions

View file

@ -121,7 +121,7 @@ bool NotationParts::staffExists(const ID& staffId) const
StaffConfig NotationParts::staffConfig(const ID& staffId) const
{
Staff* staff = this->staffModifiable(staffId);
Staff* staff = staffModifiable(staffId);
if (!staff) {
return StaffConfig();
}
@ -285,9 +285,14 @@ void NotationParts::setPartSharpFlat(const ID& partId, const SharpFlat& sharpFla
return;
}
int shartFlatInt = static_cast<int>(sharpFlat);
if (part->getProperty(Ms::Pid::PREFER_SHARP_FLAT) == shartFlatInt) {
return;
}
startEdit();
part->undoChangeProperty(Ms::Pid::PREFER_SHARP_FLAT, static_cast<int>(sharpFlat));
part->undoChangeProperty(Ms::Pid::PREFER_SHARP_FLAT, shartFlatInt);
apply();
@ -364,9 +369,19 @@ void NotationParts::setInstrumentName(const InstrumentKey& instrumentKey, const
return;
}
const Ms::Instrument* instrument = part->instrument(instrumentKey.tick);
if (!instrument) {
return;
}
QList<StaffName> newNames { StaffName(name, 0) };
if (instrument->longNames() == newNames) {
return;
}
startEdit();
score()->undo(new Ms::ChangeInstrumentLong(instrumentKey.tick, part, { StaffName(name, 0) }));
score()->undo(new Ms::ChangeInstrumentLong(instrumentKey.tick, part, newNames));
apply();
@ -382,6 +397,15 @@ void NotationParts::setInstrumentAbbreviature(const InstrumentKey& instrumentKey
return;
}
const Ms::Instrument* instrument = part->instrument(instrumentKey.tick);
if (!instrument) {
return;
}
if (instrument->abbreviature() == abbreviature) {
return;
}
startEdit();
score()->undo(new Ms::ChangeInstrumentShort(instrumentKey.tick, part, { StaffName(abbreviature, 0) }));
@ -448,13 +472,17 @@ void NotationParts::setStaffType(const ID& staffId, StaffType type)
{
TRACEFUNC;
Staff* staff = this->staffModifiable(staffId);
Staff* staff = staffModifiable(staffId);
const Ms::StaffType* staffType = Ms::StaffType::preset(type);
if (!staff || !staffType) {
return;
}
if (staff->staffType(DEFAULT_TICK) == staffType) {
return;
}
startEdit();
score()->undo(new Ms::ChangeStaffType(staff, *staffType));
@ -473,6 +501,10 @@ void NotationParts::setStaffConfig(const ID& staffId, const StaffConfig& config)
return;
}
if (staffConfig(staffId) == config) {
return;
}
startEdit();
doSetStaffConfig(staff, config);

View file

@ -449,6 +449,33 @@ struct StaffConfig
Staff::HideMode hideMode = Staff::HideMode::AUTO;
engraving::NoteHeadScheme noteheadScheme = engraving::NoteHeadScheme::HEAD_AUTO;
ClefTypeList clefTypeList;
bool operator==(const StaffConfig& conf) const
{
bool equal = visible == conf.visible;
equal &= linesCount == conf.linesCount;
equal &= RealIsEqual(lineDistance, conf.lineDistance);
equal &= linesColor == conf.linesColor;
equal &= visibleLines == conf.visibleLines;
equal &= RealIsEqual(userDistance, conf.userDistance);
equal &= RealIsEqual(scale, conf.scale);
equal &= isSmall == conf.isSmall;
equal &= cutaway == conf.cutaway;
equal &= showIfEmpty == conf.showIfEmpty;
equal &= showClef == conf.showClef;
equal &= showTimeSignature == conf.showTimeSignature;
equal &= showKeySignature == conf.showKeySignature;
equal &= showBarlines == conf.showBarlines;
equal &= showStemless == conf.showStemless;
equal &= showLedgerLinesPitched == conf.showLedgerLinesPitched;
equal &= hideSystemBarline == conf.hideSystemBarline;
equal &= mergeMatchingRests == conf.mergeMatchingRests;
equal &= hideMode == conf.hideMode;
equal &= noteheadScheme == conf.noteheadScheme;
equal &= clefTypeList == conf.clefTypeList;
return equal;
}
};
struct TransposeOptions