fix regressions

This commit is contained in:
ws 2018-03-22 13:17:22 +01:00
parent 56f64d5edf
commit ee0b1b889d
9 changed files with 30 additions and 36 deletions

View file

@ -677,6 +677,8 @@ bool HBox::setProperty(P_ID propertyId, const QVariant& v)
QVariant HBox::propertyDefault(P_ID id) const
{
switch(id) {
case P_ID::SUB_STYLE:
return int(SubStyleId::BOX);
case P_ID::CREATE_SYSTEM_HEADER:
return true;
default:

View file

@ -164,17 +164,17 @@ Element::Element(const Element& e)
: ScoreElement(e)
{
_parent = e._parent;
_z = e._z;
_placement = e._placement;
_flags = e._flags;
_placement = e._placement;
_track = e._track;
_color = e._color;
_mag = e._mag;
_pos = e._pos;
_userOff = e._userOff;
_readPos = e._readPos;
_bbox = e._bbox;
_tag = e._tag;
_z = e._z;
_color = e._color;
itemDiscovered = false;
}
@ -1085,12 +1085,9 @@ QVariant Element::propertyDefault(P_ID id) const
return true;
case P_ID::Z:
return int(type()) * 100;
case P_ID::SYSTEM_FLAG:
return false;
default: // not all properties have a default
default:
return ScoreElement::propertyDefault(id);
}
// return QVariant();
}
//---------------------------------------------------------

View file

@ -420,18 +420,18 @@ void Excerpt::cloneStaves(Score* oscore, Score* score, const QList<int>& map, QM
MeasureBaseList* nmbl = score->measures();
for (MeasureBase* mb = oscore->measures()->first(); mb; mb = mb->next()) {
MeasureBase* nmb = 0;
if (mb->type() == ElementType::HBOX)
if (mb->isHBox())
nmb = new HBox(score);
else if (mb->type() == ElementType::VBOX)
else if (mb->isVBox())
nmb = new VBox(score);
else if (mb->type() == ElementType::TBOX) {
else if (mb->isTBox()) {
nmb = new TBox(score);
Text* text = toTBox(mb)->text();
Element* ne = text->linkedClone();
ne->setScore(score);
nmb->add(ne);
}
else if (mb->type() == ElementType::MEASURE) {
else if (mb->isMeasure()) {
Measure* m = toMeasure(mb);
Measure* nm = new Measure(score);
nmb = nm;
@ -464,12 +464,10 @@ void Excerpt::cloneStaves(Score* oscore, Score* score, const QList<int>& map, QM
Tremolo* tremolo = 0;
for (Segment* oseg = m->first(); oseg; oseg = oseg->next()) {
Segment* ns = nullptr; //create segment later, on demand
foreach (Element* e, oseg->annotations()) {
for (Element* e : oseg->annotations()) {
if (e->generated())
continue;
if ((e->track() == srcTrack && track != -1)
|| (e->systemFlag() && srcTrack == 0)
) {
if ((e->track() == srcTrack && track != -1) || (e->systemFlag() && srcTrack == 0)) {
Element* ne = e->linkedClone();
// reset user offset as most likely it will not fit
ne->setUserOff(QPointF());

View file

@ -192,7 +192,6 @@ void ScoreElement::initSubStyle(SubStyleId ssid)
}
++i;
}
}
//---------------------------------------------------------
@ -308,15 +307,8 @@ void ScoreElement::writeProperty(XmlWriter& xml, P_ID id) const
QVariant(propertyDefault(id).toReal()/_spatium));
}
else {
if (getProperty(id).isValid()) {
if (getProperty(id).isValid())
xml.tag(id, getProperty(id), propertyDefault(id));
if (id == P_ID::SUB_STYLE) {
printf("write substyle %d %s default %d %s\n",
getProperty(id).toInt(), subStyleName( SubStyleId(getProperty(id).toInt()) ),
propertyDefault(id).toInt(), subStyleName(SubStyleId(propertyDefault(id).toInt()))
);
}
}
else
qDebug("invalid property");
}
@ -517,12 +509,18 @@ bool ScoreElement::readProperty(const QStringRef& s, XmlReader& e, P_ID id)
QVariant ScoreElement::propertyDefault(P_ID id) const
{
if (id == P_ID::SUB_STYLE)
if (id == P_ID::SUB_STYLE) {
return int(SubStyleId::DEFAULT);
}
for (const StyledProperty& p : subStyle(subStyleId())) {
if (p.propertyIdx == id)
return score()->styleV(p.styleIdx);
}
for (const StyledProperty& p : subStyle(SubStyleId::DEFAULT)) {
if (p.propertyIdx == id)
return score()->styleV(p.styleIdx);
}
qDebug("not found <%s> in <%s> style <%s>", propertyName(id), name(), subStyleName(subStyleId()));
return QVariant();
}

View file

@ -448,11 +448,11 @@ void Segment::add(Element* el)
setEmpty(false);
break;
case ElementType::TEMPO_TEXT:
case ElementType::DYNAMIC:
case ElementType::HARMONY:
case ElementType::SYMBOL:
case ElementType::FRET_DIAGRAM:
case ElementType::TEMPO_TEXT:
case ElementType::STAFF_TEXT:
case ElementType::SYSTEM_TEXT:
case ElementType::REHEARSAL_MARK:

View file

@ -993,6 +993,7 @@ const std::vector<StyledProperty> tempoStyle {
{ StyleIdx::tempoOffset, P_ID::OFFSET },
{ StyleIdx::tempoSystemFlag, P_ID::SYSTEM_FLAG },
{ StyleIdx::tempoAlign, P_ID::ALIGN },
{ StyleIdx::tempoPlacement, P_ID::PLACEMENT },
{ StyleIdx::NOSTYLE, P_ID::END } // end of list marker
};

View file

@ -28,14 +28,13 @@ namespace Ms {
//---------------------------------------------------------
TempoText::TempoText(Score* s)
: TextBase(s, ElementFlag::SYSTEM)
: TextBase(s, ElementFlags(ElementFlag::SYSTEM))
{
initSubStyle(SubStyleId::TEMPO);
_tempo = 2.0; // propertyDefault(P_TEMPO).toDouble();
_followText = false;
_relative = 1.0;
_isRelative = false;
setPlacement(Placement::ABOVE);
}
//---------------------------------------------------------
@ -44,7 +43,7 @@ TempoText::TempoText(Score* s)
void TempoText::write(XmlWriter& xml) const
{
xml.stag("Tempo");
xml.stag(name());
xml.tag("tempo", _tempo);
if (_followText)
xml.tag("followText", _followText);
@ -333,8 +332,6 @@ QVariant TempoText::propertyDefault(P_ID id) const
return 2.0;
case P_ID::TEMPO_FOLLOW_TEXT:
return false;
case P_ID::PLACEMENT:
return int(Placement::ABOVE);
default:
return TextBase::propertyDefault(id);
}

View file

@ -2724,12 +2724,10 @@ bool TextBase::setProperty(P_ID propertyId, const QVariant& v)
QVariant TextBase::propertyDefault(P_ID id) const
{
switch (id) {
case P_ID::SUB_STYLE:
return int(SubStyleId::DEFAULT);
case P_ID::TEXT:
return QString();
case P_ID::OFFSET:
return QPointF();
case P_ID::OFFSET_TYPE:
return int (OffsetType::SPATIUM);
default:
return Element::propertyDefault(id);
}

View file

@ -1268,8 +1268,10 @@ void GuitarPro::setTempo(int tempo, Measure* measure)
Segment* segment = measure->getSegment(SegmentType::ChordRest, measure->tick());
for (Element* e : segment->annotations()) {
if (e->isTempoText())
if (e->isTempoText()) {
qDebug("already there");
return;
}
}
TempoText* tt = new TempoText(score);
@ -1277,6 +1279,7 @@ void GuitarPro::setTempo(int tempo, Measure* measure)
tt->setXmlText(QString("<sym>metNoteQuarterUp</sym> = %1").arg(tempo));
tt->setTrack(0);
qDebug("%p setTempo %d annotations %d", tt, measure->tick(), segment->annotations().size());
segment->add(tt);
score->setTempo(measure->tick(), tt->tempo());
previousTempo = tempo;