fix slurs from staff n to staff n-1

This commit is contained in:
ws 2015-03-03 15:45:25 +01:00
parent cedc1f97b7
commit 75bd3ba77e
4 changed files with 19 additions and 8 deletions

View file

@ -346,14 +346,24 @@ bool ChordRest::readProperties(XmlReader& e)
if (id == 0)
id = e.intAttribute("number"); // obsolete
Spanner* spanner = e.findSpanner(id);
if (!spanner)
qDebug("ChordRest::read(): Slur id %d not found", id);
QString atype(e.attribute("type"));
if (!spanner) {
if (atype == "stop") {
SpannerValues sv;
sv.spannerId = id;
sv.track2 = e.track();
sv.tick2 = e.tick();
e.addSpannerValues(sv);
}
else if (atype == "start")
qDebug("spanner: start without spanner");
}
else {
QString atype(e.attribute("type"));
if (atype == "start") {
if (spanner->ticks() > 0 && spanner->tick() == 0) // stop has been read first
spanner->setTicks(spanner->ticks() - e.tick());
spanner->setTick(e.tick());
if (spanner->ticks() > 0) // stop has been read first, ticks is tick2 - (-1)
spanner->setTick2(spanner->ticks() - 1);
spanner->setTrack(track());
if (spanner->type() == Element::Type::SLUR)
spanner->setStartElement(this);

View file

@ -1986,7 +1986,6 @@ void Measure::read(XmlReader& e, int staffIdx)
Slur *sl = new Slur(score());
sl->setTick(e.tick());
sl->read(e);
score()->addSpanner(sl);
//
// check if we already saw "endSpanner"
//
@ -1994,7 +1993,9 @@ void Measure::read(XmlReader& e, int staffIdx)
const SpannerValues* sv = e.spannerValues(id);
if (sv) {
sl->setTick2(sv->tick2);
sl->setTrack2(sv->track2);
}
score()->addSpanner(sl);
}
else if (tag == "HairPin"
|| tag == "Pedal"

View file

@ -695,7 +695,7 @@ void Xml::writeXml(const QString& name, QString s)
// spannerValues
//---------------------------------------------------------
const SpannerValues* XmlReader::spannerValues(int id)
const SpannerValues* XmlReader::spannerValues(int id) const
{
for (const SpannerValues& v : _spannerValues) {
if (v.spannerId == id)

View file

@ -121,7 +121,7 @@ class XmlReader : public XmlStreamReader {
int spannerId(const Spanner*); // returns spanner id, allocates new one if none exists
void addSpannerValues(const SpannerValues& sv) { _spannerValues.append(sv); }
const SpannerValues* spannerValues(int id);
const SpannerValues* spannerValues(int id) const;
QList<StaffType>& staffType() { return _staffTypes; }
Interval transpose() const { return _transpose; }
void setTransposeChromatic(int v) { _transpose.chromatic = v; }