AccidentalType Accidental::name2subtype(const QString& tag) { int n = sizeof(accList)/sizeof(*accList); for (int i = 0; i < n; ++i) { if (accList[i].tag == tag) return AccidentalType(i); } return ACC_NONE; }
AccidentalType Accidental::name2subtype(const QString& tag) { int i = 0; for (const Acc& acc : accList) { if (acc.tag == tag) return AccidentalType(i); ++i; } return AccidentalType::NONE; }
void Accidental::setSubtype(const QString& tag) { int n = sizeof(accList)/sizeof(*accList); for (int i = 0; i < n; ++i) { if (accList[i].tag == tag) { setAccidentalType(AccidentalType(i)); return; } } setAccidentalType(ACC_NONE); }
Palette* MuseScore::newAccidentalsPalette(bool basic) { Palette* sp = new Palette; sp->setName(QT_TRANSLATE_NOOP("Palette", "Accidentals")); sp->setGrid(33, 36); sp->setDrawGrid(true); if (basic) { static AccidentalType types[] = { AccidentalType::NONE, AccidentalType::SHARP, AccidentalType::FLAT, AccidentalType::SHARP2, AccidentalType::FLAT2, AccidentalType::NATURAL }; for (auto i : types) { Accidental* s = new Accidental(gscore); s->setAccidentalType(AccidentalType(i)); sp->append(s, qApp->translate("accidental", s->subtypeUserName())); } } else { for (int i = int(AccidentalType::SHARP); i < int(AccidentalType::END); ++i) { Accidental* s = new Accidental(gscore); s->setAccidentalType(AccidentalType(i)); if (s->symbol() != SymId::noSym) sp->append(s, qApp->translate("accidental", s->subtypeUserName())); else delete s; } } Icon* ik = new Icon(gscore); ik->setIconType(IconType::BRACKETS); const Shortcut* s = Shortcut::getShortcut("add-brackets"); QAction* action = s->action(); QIcon icon(action->icon()); ik->setAction("add-brackets", icon); sp->append(ik, s->help()); return sp; }
Palette* MuseScore::newAccidentalsPalette() { Palette* sp = new Palette; sp->setName(qApp->translate("accidental", "Accidentals")); sp->setGrid(33, 36); sp->setDrawGrid(true); for (int i = ACC_SHARP; i < ACC_END; ++i) { Accidental* s = new Accidental(gscore); s->setSubtype(AccidentalType(i)); sp->append(s, qApp->translate("accidental", s->subtypeUserName())); } AccidentalBracket* ab = new AccidentalBracket(gscore); sp->append(ab, qApp->translate("accidental", "round bracket")); return sp; }
void Accidental::read(XmlReader& e) { while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "bracket") { int i = e.readInt(); if (i == 0 || i == 1) _hasBracket = i; } else if (tag == "subtype") { QString text(e.readElementText()); bool isInt; int i = text.toInt(&isInt); if (isInt) { _hasBracket = i & 0x8000; i &= ~0x8000; switch(i) { case 0: i = ACC_NONE; break; case 1: case 11: i = ACC_SHARP; break; case 2: case 12: i = ACC_FLAT; break; case 3: case 13: i = ACC_SHARP2; break; case 4: case 14: i = ACC_FLAT2; break; case 5: case 15: i = ACC_NATURAL; break; case 6: i = ACC_SHARP; _hasBracket = true; break; case 7: i = ACC_FLAT; _hasBracket = true; break; case 8: i = ACC_SHARP2; _hasBracket = true; break; case 9: i = ACC_FLAT2; _hasBracket = true; break; case 10: i = ACC_NATURAL; _hasBracket = true; break; case 16: i = ACC_FLAT_SLASH; break; case 17: i = ACC_FLAT_SLASH2; break; case 18: i = ACC_MIRRORED_FLAT2; break; case 19: i = ACC_MIRRORED_FLAT; break; case 20: i = ACC_MIRRIRED_FLAT_SLASH; break; case 21: i = ACC_FLAT_FLAT_SLASH; break; case 22: i = ACC_SHARP_SLASH; break; case 23: i = ACC_SHARP_SLASH2; break; case 24: i = ACC_SHARP_SLASH3; break; case 25: i = ACC_SHARP_SLASH4; break; case 26: i = ACC_SHARP_ARROW_UP; break; case 27: i = ACC_SHARP_ARROW_DOWN; break; case 28: i = ACC_SHARP_ARROW_BOTH; break; case 29: i = ACC_FLAT_ARROW_UP; break; case 30: i = ACC_FLAT_ARROW_DOWN; break; case 31: i = ACC_FLAT_ARROW_BOTH; break; case 32: i = ACC_NATURAL_ARROW_UP; break; case 33: i = ACC_NATURAL_ARROW_DOWN; break; case 34: i = ACC_NATURAL_ARROW_BOTH; break; default: i = 0; break; } setAccidentalType(AccidentalType(i)); } else setSubtype(text); } else if (tag == "role") { int i = e.readInt(); if (i == ACC_AUTO || i == ACC_USER) _role = AccidentalRole(i); } else if (tag == "small") _small = e.readInt(); else if (Element::readProperties(e)) ; else e.unknown(); } }
void Accidental::read(const QDomElement& de) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); bool isInt; int i = e.text().toInt(&isInt); if (tag == "bracket") { if (i == 0 || i == 1) _hasBracket = i; } else if (tag == "subtype") { if (isInt) { _hasBracket = i & 0x8000; i &= ~0x8000; switch(i) { case 0: i = ACC_NONE; break; case 1: case 11: i = ACC_SHARP; break; case 2: case 12: i = ACC_FLAT; break; case 3: case 13: i = ACC_SHARP2; break; case 4: case 14: i = ACC_FLAT2; break; case 5: case 15: i = ACC_NATURAL; break; case 6: i = ACC_SHARP; _hasBracket = true; break; case 7: i = ACC_FLAT; _hasBracket = true; break; case 8: i = ACC_SHARP2; _hasBracket = true; break; case 9: i = ACC_FLAT2; _hasBracket = true; break; case 10: i = ACC_NATURAL; _hasBracket = true; break; case 16: i = ACC_FLAT_SLASH; break; case 17: i = ACC_FLAT_SLASH2; break; case 18: i = ACC_MIRRORED_FLAT2; break; case 19: i = ACC_MIRRORED_FLAT; break; case 20: i = ACC_MIRRIRED_FLAT_SLASH; break; case 21: i = ACC_FLAT_FLAT_SLASH; break; case 22: i = ACC_SHARP_SLASH; break; case 23: i = ACC_SHARP_SLASH2; break; case 24: i = ACC_SHARP_SLASH3; break; case 25: i = ACC_SHARP_SLASH4; break; case 26: i = ACC_SHARP_ARROW_UP; break; case 27: i = ACC_SHARP_ARROW_DOWN; break; case 28: i = ACC_SHARP_ARROW_BOTH; break; case 29: i = ACC_FLAT_ARROW_UP; break; case 30: i = ACC_FLAT_ARROW_DOWN; break; case 31: i = ACC_FLAT_ARROW_BOTH; break; case 32: i = ACC_NATURAL_ARROW_UP; break; case 33: i = ACC_NATURAL_ARROW_DOWN; break; case 34: i = ACC_NATURAL_ARROW_BOTH; break; default: i = 0; break; } setSubtype(AccidentalType(i)); } else setSubtype(e.text()); } else if (tag == "role") { if (i == ACC_AUTO || i == ACC_USER) _role = AccidentalRole(i); } else if (tag == "small") _small = i; else if (Element::readProperties(e)) ; else domError(e); } }