void Articulation::read(QDomElement e) { setSubtype(0); // default for (e = e.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { QString tag(e.tagName()); QString val(e.text()); if (tag == "idx") // obsolete setSubtype(val.toInt()); else if (tag == "channel") _channelName = e.attribute("name"); else if (tag == "anchor") _anchor = ArticulationAnchor(val.toInt()); else if (tag == "direction") { Direction dir = AUTO; if (val == "up") dir = UP; else if (val == "down") dir = DOWN; else if (val == "auto") dir = AUTO; else domError(e); // printf("setDirection %s %d\n", qPrintable(val), int(dir)); setDirection(dir); } else if (!Element::readProperties(e)) domError(e); } /* if (subtype() == Articulation_Schleifer) { printf("Schleifer %f %f\n", readPos().x(), readPos().y()); setReadPos(QPointF()); } */ }
void Articulation::read(const QDomElement& de) { setSubtype(Articulation_Fermata); // default // backward compatibility (no type = ufermata in 1.2) for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "subtype") setSubtype(val); else if (tag == "channel") _channelName = e.attribute("name"); else if (tag == "anchor") _anchor = ArticulationAnchor(val.toInt()); else if (tag == "direction") { MScore::Direction dir = MScore::AUTO; if (val == "up") dir = MScore::UP; else if (val == "down") dir = MScore::DOWN; else if (val == "auto") dir = MScore::AUTO; else domError(e); setDirection(dir); } else if (!Element::readProperties(e)) domError(e); } }
void SyntiState::read(QDomElement e) { for (e = e.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { QString tag(e.tagName()); QString name = e.attribute("name"); if (tag == "f") { double val = e.attribute("val").toDouble(); append(SyntiParameter(name, val)); } else if (tag == "s") append(SyntiParameter(name, e.attribute("val"))); else if (tag == "Synth") { // obsolete for (QDomElement ee = e.firstChildElement(); !ee.isNull(); ee = ee.nextSiblingElement()) { QString tag(ee.tagName()); if (tag == "f") { double val = ee.attribute("val").toDouble(); append(SyntiParameter(name, val)); } else if (tag == "s") append(SyntiParameter(name, ee.attribute("val"))); else domError(ee); } } else domError(e); } }
void Articulation::read(const QDomElement& de) { setSubtype(Articulation_Staccato); // default for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "subtype") setSubtype(val); else if (tag == "channel") _channelName = e.attribute("name"); else if (tag == "anchor") _anchor = ArticulationAnchor(val.toInt()); else if (tag == "direction") { Direction dir = AUTO; if (val == "up") dir = UP; else if (val == "down") dir = DOWN; else if (val == "auto") dir = AUTO; else domError(e); setDirection(dir); } else if (!Element::readProperties(e)) domError(e); } }
void ChordLine::read(const QDomElement& de) { path = QPainterPath(); for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { QString tag(e.tagName()); if (tag == "Path") { path = QPainterPath(); QPointF curveTo; QPointF p1; int state = 0; for (QDomElement ee = e.firstChildElement(); !ee.isNull(); ee = ee.nextSiblingElement()) { QString tag(ee.tagName()); if (tag == "Element") { int type = ee.attribute("type").toInt(); qreal x = ee.attribute("x").toDouble(); qreal y = ee.attribute("y").toDouble(); switch(QPainterPath::ElementType(type)) { case QPainterPath::MoveToElement: path.moveTo(x, y); break; case QPainterPath::LineToElement: path.lineTo(x, y); break; case QPainterPath::CurveToElement: curveTo.rx() = x; curveTo.ry() = y; state = 1; break; case QPainterPath::CurveToDataElement: if (state == 1) { p1.rx() = x; p1.ry() = y; state = 2; } else if (state == 2) { path.cubicTo(curveTo, p1, QPointF(x, y)); state = 0; } break; } } else domError(ee); } modified = true; setSubtype(ChordLineType(0)); } else if (tag == "subtype") setSubtype(ChordLineType(e.text().toInt())); else if (!Element::readProperties(e)) domError(e); } }
void Shortcut::load() { QFile f(dataPath + "/shortcuts.xml"); if (!f.exists()) f.setFileName(":/data/shortcuts.xml"); if (!f.open(QIODevice::ReadOnly)) { printf("cannot open shortcuts\n"); return; } QDomDocument doc; int line, column; QString err; if (!doc.setContent(&f, false, &err, &line, &column)) { printf("error reading shortcuts.xml at line %d column %d: %s\n", line, column, qPrintable(err)); return; } f.close(); QString key; for (QDomElement e = doc.documentElement(); !e.isNull(); e = e.nextSiblingElement()) { if (e.tagName() == "Shortcuts") { for (QDomElement ee = e.firstChildElement(); !ee.isNull(); ee = ee.nextSiblingElement()) { if (ee.tagName() == "SC") { Shortcut* sc = 0; for (QDomElement eee = ee.firstChildElement(); !eee.isNull(); eee = eee.nextSiblingElement()) { const QString& tag(eee.tagName()); const QString& val(eee.text()); if (tag == "key") { sc = getShortcut(val.toAscii().data()); if (!sc) { printf("cannot find shortcut <%s>\n", qPrintable(val)); break; } sc->clear(); } else if (tag == "std") sc->_standardKey = QKeySequence::StandardKey(val.toInt()); else if (tag == "seq") sc->_keys.append(QKeySequence::fromString(val, QKeySequence::PortableText)); else domError(eee); } } else domError(ee); } } else domError(e); } dirty = false; }
int SigEvent::read(const QDomElement& de, int fileDivision) { int tick = de.attribute("tick", "0").toInt(); tick = tick * MScore::division / fileDivision; int numerator = 1; int denominator = 1; int denominator2 = -1; int numerator2 = -1; for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); int i = e.text().toInt(); if (tag == "nom") numerator = i; else if (tag == "denom") denominator = i; else if (tag == "nom2") numerator2 = i; else if (tag == "denom2") denominator2 = i; else domError(e); } if ((numerator2 == -1) || (denominator2 == -1)) { numerator2 = numerator; denominator2 = denominator; } _timesig = Fraction(numerator, denominator); _nominal = Fraction(numerator2, denominator2); return tick; }
void StaffTypeTablature::read(const QDomElement& de) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "durations") setGenDurations(val.toInt() != 0); else if (tag == "durationFontName") setDurationFontName(e.text()); else if (tag == "durationFontSize") setDurationFontSize(val.toDouble()); else if (tag == "durationFontY") setDurationFontUserY(val.toDouble()); else if (tag == "fretFontName") setFretFontName(e.text()); else if (tag == "fretFontSize") setFretFontSize(val.toDouble()); else if (tag == "fretFontY") setFretFontUserY(val.toDouble()); else if (tag == "linesThrough") setLinesThrough(val.toInt() != 0); else if (tag == "onLines") setOnLines(val.toInt() != 0); else if (tag == "timesig") setGenTimesig(val.toInt() != 0); else if (tag == "upsideDown") setUpsideDown(val.toInt() != 0); else if (tag == "useNumbers") setUseNumbers(val.toInt() != 0); else if(!StaffType::readProperties(e)) domError(e); } }
void Text::read(const QDomElement& de) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (!readProperties(e)) domError(e); } }
void Breath::read(QDomElement e) { for (e = e.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (!Element::readProperties(e)) domError(e); } }
void Marker::read(const QDomElement& de) { MarkerType mt = MARKER_SEGNO; for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); if (tag == "label") { setLabel(e.text()); mt = markerType(e.text()); } else if (!Text::readProperties(e)) domError(e); } switch (mt) { case MARKER_SEGNO: case MARKER_VARSEGNO: case MARKER_CODA: case MARKER_VARCODA: case MARKER_CODETTA: setTextStyleType(TEXT_STYLE_REPEAT_LEFT); break; case MARKER_FINE: case MARKER_TOCODA: setTextStyleType(TEXT_STYLE_REPEAT_RIGHT); break; case MARKER_USER: setTextStyleType(TEXT_STYLE_REPEAT); break; } setMarkerType(mt); }
void Drumset::load(const QDomElement& de) { int pitch = de.attribute("pitch", "-1").toInt(); if (pitch < 0 || pitch > 127) { qDebug("load drumset: invalid pitch %d\n", pitch); return; } for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { QString tag(e.tagName()); QString val(e.text()); bool isNum; int i = val.toInt(&isNum); if (tag == "head") _drum[pitch].notehead = Note::NoteHeadGroup(i); else if (tag == "line") _drum[pitch].line = i; else if (tag == "voice") _drum[pitch].voice = i; else if (tag == "name") _drum[pitch].name = val; else if (tag == "stem") _drum[pitch].stemDirection = MScore::Direction(i); else if (tag == "shortcut") _drum[pitch].shortcut = isNum ? i : toupper(val[0].toLatin1()); else domError(e); } }
void Image::read(const QDomElement& de) { if (score()->mscVersion() <= 123) _sizeIsSpatium = false; for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); if (tag == "autoScale") setProperty(P_AUTOSCALE, ::getProperty(P_AUTOSCALE, e)); else if (tag == "size") setProperty(P_SIZE, ::getProperty(P_SIZE, e)); else if (tag == "lockAspectRatio") setProperty(P_LOCK_ASPECT_RATIO, ::getProperty(P_LOCK_ASPECT_RATIO, e)); else if (tag == "sizeIsSpatium") setProperty(P_SIZE_IS_SPATIUM, ::getProperty(P_SIZE_IS_SPATIUM, e)); else if (tag == "path") _storePath = e.text(); else if(tag == "linkPath") _linkPath = e.text(); else if (!Element::readProperties(e)) domError(e); } // once all paths are read, load img or retrieve it from store // loading from file is tried first to update the stored image, if necessary if(_linkPath.isEmpty() || !load(_linkPath)) { // if could not load img from _linkPath, retrieve from store _storeItem = imageStore.getImage(_storePath); if (_storeItem) _storeItem->reference(this); // if not in store, try to load from _storePath for backward compatibility else load(_storePath); } }
static QList<Shortcut1*> loadDefaultShortcuts() { QList<Shortcut1*> list; QFile f(":/data/shortcuts.xml"); if (!f.open(QIODevice::ReadOnly)) { printf("cannot open shortcuts\n"); return list; } QDomDocument doc; int line, column; QString err; if (!doc.setContent(&f, false, &err, &line, &column)) { printf("error reading shortcuts.xml at line %d column %d: %s\n", line, column, qPrintable(err)); return list; } f.close(); QString key; for (QDomElement e = doc.documentElement(); !e.isNull(); e = e.nextSiblingElement()) { if (e.tagName() == "Shortcuts") { for (QDomElement ee = e.firstChildElement(); !ee.isNull(); ee = ee.nextSiblingElement()) { if (ee.tagName() == "SC") { Shortcut1* sc = new Shortcut1; sc->key = 0; for (QDomElement eee = ee.firstChildElement(); !eee.isNull(); eee = eee.nextSiblingElement()) { const QString& tag(eee.tagName()); const QString& val(eee.text()); if (tag == "key") sc->key = strdup(val.toAscii().data()); else if (tag == "std") sc->standardKey = QKeySequence::StandardKey(val.toInt()); else if (tag == "seq") sc->keys.append(QKeySequence::fromString(val, QKeySequence::PortableText)); else domError(eee); } } else domError(ee); } } else domError(e); } return list; }
static bool extractRootfile(QFile* qf, QByteArray& data) { MQZipReader f(qf->fileName()); data = f.fileData("META-INF/container.xml"); QDomDocument container; int line, column; QString err; if (!container.setContent(data, false, &err, &line, &column)) { MScore::lastError = QObject::tr("Error reading container.xml at line %1 column %2: %3\n").arg(line).arg(column).arg(err); return false; } // extract first rootfile QString rootfile = ""; for (QDomElement e = container.documentElement(); !e.isNull(); e = e.nextSiblingElement()) { if (e.tagName() == "container") { for (QDomElement ee = e.firstChildElement(); !ee.isNull(); ee = ee.nextSiblingElement()) { if (ee.tagName() == "rootfiles") { for (QDomElement eee = ee.firstChildElement(); !eee.isNull(); eee = eee.nextSiblingElement()) { if (eee.tagName() == "rootfile") { if (rootfile == "") rootfile = eee.attribute(QString("full-path")); } else domError(eee); } } else domError(ee); } } else domError(e); } if (rootfile == "") { qDebug("can't find rootfile in: %s", qPrintable(qf->fileName())); MScore::lastError = QObject::tr("Can't find rootfile\n%1").arg(qf->fileName()); return false; } // read the rootfile data = f.fileData(rootfile); return true; }
void NoteDot::read(const QDomElement& de) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (e.tagName() == "name") // obsolete ; else if (!Element::readProperties(e)) domError(e); } }
void Rest::read(const QDomElement& de, QList<Tuplet*>* tuplets, QList<Spanner*>* spanner) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (!ChordRest::readProperties(e, tuplets, spanner)) domError(e); } QPointF off(userOff()); setUserOffset(off.x(), off.y()); }
void BarLine::read(const QDomElement& de) { // if bar line belongs to a staff, span values default to staff values if(staff()) { _span = staff()->barLineSpan(); _spanFrom = staff()->barLineFrom(); _spanTo = staff()->barLineTo(); } for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "subtype") { bool ok; int i = val.toInt(&ok); if (!ok) setSubtype(val); else { BarLineType ct = NORMAL_BAR; switch (i) { default: case 0: ct = NORMAL_BAR; break; case 1: ct = DOUBLE_BAR; break; case 2: ct = START_REPEAT; break; case 3: ct = END_REPEAT; break; case 4: ct = BROKEN_BAR; break; case 5: ct = END_BAR; break; case 6: ct = END_START_REPEAT; break; case 7: ct = DOTTED_BAR; break; } setSubtype(ct); } if(parent() && parent()->type() == SEGMENT) { Measure* m = static_cast<Segment*>(parent())->measure(); if(subtype() != m->endBarLineType()) setCustomSubtype(true); } } else if (tag == "customSubtype") setCustomSubtype(val.toInt() != 0); else if (tag == "span") { _span = val.toInt(); _spanFrom = e.attribute("from", QString::number(_spanFrom)).toInt(); _spanTo = e.attribute("to", QString::number(_spanTo)).toInt(); // WARNING: following statements assume staff and staff bar line spans are correctly set if(staff() && (_span != staff()->barLineSpan() || _spanFrom != staff()->barLineFrom() || _spanTo != staff()->barLineTo())) _customSpan = true; } else if (tag == "Articulation") { Articulation* a = new Articulation(score()); a->read(e); add(a); } else if (!Element::readProperties(e)) domError(e); } }
void Tremolo::read(const QDomElement& de) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (e.tagName() == "subtype") setSubtype(e.text()); else if (!Element::readProperties(e)) domError(e); } }
void Rest::read(QDomElement e, const QList<Tuplet*>& tuplets, QList<Slur*>* slurs) { for (e = e.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (!ChordRest::readProperties(e, tuplets, slurs)) domError(e); } QPointF off(userOff()); setUserOffset(off.x(), off.y()); }
void FiguredBass::read(const QDomElement& de) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); if (tag == "no") _no = e.text().toInt(); else if (!Lyrics::readProperties(e)) domError(e); } }
void Spacer::read(const QDomElement& de) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (e.tagName() == "space") _gap = e.text().toDouble() * spatium(); else if (!Element::readProperties(e)) domError(e); } layout0(); }
void Stem::read(QDomElement e) { for (e = e.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { QString tag(e.tagName()); if (tag == "userLen") _userLen = Spatium(e.text().toDouble()); else if (!Element::readProperties(e)) domError(e); } }
void Audio::read(const QDomElement& ee) { for (QDomElement e = ee.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "path") _path = val; else domError(e); } }
void TextLine::read(const QDomElement& de) { foreach(SpannerSegment* seg, spannerSegments()) delete seg; spannerSegments().clear(); setId(de.attribute("id", "-1").toInt()); for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (!readProperties(e)) domError(e); } }
void Stem::read(const QDomElement& de) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (e.tagName() == "userLen") _userLen = e.text().toDouble() * spatium(); else if (e.tagName() == "subtype") // obsolete ; else if (!Element::readProperties(e)) domError(e); } }
void Icon::read(const QDomElement& de) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); if (tag == "action") _action = strdup(e.text().toAscii().data()); else if (tag == "subtype") _subtype = e.text().toInt(); else domError(e); } }
void Glissando::read(QDomElement e) { _showText = false; for (e = e.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { QString tag(e.tagName()); if (tag == "text") { _showText = true; _text = e.text(); } else if (!Element::readProperties(e)) domError(e); } }
bool TablatureDurationFont::read(const QDomElement &de) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); const QString& txt(e.text()); if(txt.size() < 1) return false; QChar chr = txt[0]; if (tag == "family") family = txt; else if(tag == "displayName") displayName = txt; else if(tag == "defaultPitch") defPitch = txt.toDouble(); else if(tag == "duration") { QString val = e.attribute("value"); if(val.size() < 1) return false; if(val == "longa") displayValue[TAB_VAL_LONGA] = chr; else if(val == "brevis") displayValue[TAB_VAL_BREVIS] = chr; else if(val == "semibrevis") displayValue[TAB_VAL_SEMIBREVIS] = chr; else if(val == "minima") displayValue[TAB_VAL_MINIMA] = chr; else if(val == "semiminima") displayValue[TAB_VAL_SEMIMINIMA] = chr; else if(val == "fusa") displayValue[TAB_VAL_FUSA] = chr; else if(val == "semifusa") displayValue[TAB_VAL_SEMIFUSA] = chr; else if(val == "32") displayValue[TAB_VAL_32] = chr; else if(val == "64") displayValue[TAB_VAL_64] = chr; else if(val == "128") displayValue[TAB_VAL_128] = chr; else if(val == "256") displayValue[TAB_VAL_256] = chr; else if(val == "dot") displayDot = chr; } else { domError(e); return false; } } return true; }
void Glissando::read(const QDomElement& de) { _showText = false; for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (e.tagName() == "text") { _showText = true; _text = e.text(); } else if (e.tagName() == "subtype") _subtype = e.text().toInt(); else if (!Element::readProperties(e)) domError(e); } }