rename _subStyle into _elementStyle

This commit is contained in:
ws 2018-08-02 10:57:48 +02:00
parent 19dc450b72
commit 8fac795067
4 changed files with 41 additions and 49 deletions

View file

@ -240,8 +240,8 @@ Ottava::Ottava(Score* s)
Ottava::Ottava(const Ottava& o)
: TextLineBase(o)
{
_ottavaStyle = o._ottavaStyle;
_subStyle = &_ottavaStyle;
_ottavaStyle = o._ottavaStyle;
_elementStyle = &_ottavaStyle;
setOttavaType(o._ottavaType);
_numbersOnly = o._numbersOnly;
}

View file

@ -139,9 +139,9 @@ static const ElementName elementNames[] = {
ScoreElement::ScoreElement(const ScoreElement& se)
{
_score = se._score;
_subStyle = se._subStyle;
if (_subStyle) {
int n = _subStyle->size();
_elementStyle = se._elementStyle;
if (_elementStyle) {
int n = _elementStyle->size();
_propertyFlagsList = new PropertyFlags[n];
for (int i = 0; i < n; ++i)
_propertyFlagsList[i] = se._propertyFlagsList[i];
@ -172,13 +172,11 @@ ScoreElement::~ScoreElement()
QVariant ScoreElement::propertyDefault(Pid pid) const
{
QVariant v;
if (_subStyle) {
for (const StyledProperty& spp : *_subStyle) {
if (spp.pid == pid) {
if (propertyType(pid) == P_TYPE::SP_REAL)
return score()->styleP(spp.sid);
return score()->styleV(spp.sid);
}
for (const StyledProperty& spp : *_elementStyle) {
if (spp.pid == pid) {
if (propertyType(pid) == P_TYPE::SP_REAL)
return score()->styleP(spp.sid);
return score()->styleV(spp.sid);
}
}
if (!v.isValid())
@ -192,8 +190,8 @@ QVariant ScoreElement::propertyDefault(Pid pid) const
void ScoreElement::initElementStyle(const ElementStyle* ss)
{
_subStyle = ss;
int n = _subStyle->size();
_elementStyle = ss;
int n = _elementStyle->size();
if (isTextBase()) // HACK
n += TEXT_STYLE_SIZE;
delete[] _propertyFlagsList;
@ -201,7 +199,7 @@ void ScoreElement::initElementStyle(const ElementStyle* ss)
for (int i = 0; i < n; ++i)
_propertyFlagsList[i] = PropertyFlags::STYLED;
int i = 0;
for (const StyledProperty& spp : *_subStyle) {
for (const StyledProperty& spp : *_elementStyle) {
Pid pid = spp.pid;
QVariant v = propertyType(pid) == P_TYPE::SP_REAL ? score()->styleP(spp.sid) : score()->styleV(spp.sid);
setProperty(pid, v);
@ -543,13 +541,11 @@ MasterScore* ScoreElement::masterScore() const
int ScoreElement::getPropertyFlagsIdx(Pid id) const
{
if (_subStyle) {
int i = 0;
for (const StyledProperty& p : *_subStyle) {
if (p.pid == id)
return i;
++i;
}
int i = 0;
for (const StyledProperty& p : *_elementStyle) {
if (p.pid == id)
return i;
++i;
}
return -1;
}
@ -586,11 +582,9 @@ void ScoreElement::setPropertyFlags(Pid id, PropertyFlags f)
Sid ScoreElement::getPropertyStyle(Pid id) const
{
if (_subStyle) {
for (const StyledProperty& p : *_subStyle) {
if (p.pid == id)
return p.sid;
}
for (const StyledProperty& p : *_elementStyle) {
if (p.pid == id)
return p.sid;
}
return Sid::NOSTYLE;
}
@ -601,17 +595,15 @@ Sid ScoreElement::getPropertyStyle(Pid id) const
void ScoreElement::styleChanged()
{
if (_subStyle) {
for (const StyledProperty& spp : *_subStyle) {
PropertyFlags f = propertyFlags(spp.pid);
if (f == PropertyFlags::STYLED) {
if (propertyType(spp.pid) == P_TYPE::SP_REAL) {
qreal val = score()->styleP(spp.sid);
setProperty(spp.pid, val);
}
else
setProperty(spp.pid, score()->styleV(spp.sid));
for (const StyledProperty& spp : *_elementStyle) {
PropertyFlags f = propertyFlags(spp.pid);
if (f == PropertyFlags::STYLED) {
if (propertyType(spp.pid) == P_TYPE::SP_REAL) {
qreal val = score()->styleP(spp.sid);
setProperty(spp.pid, val);
}
else
setProperty(spp.pid, score()->styleV(spp.sid));
}
}
}

View file

@ -169,7 +169,7 @@ class ScoreElement {
static ElementStyle const emptyStyle;
protected:
const ElementStyle* _subStyle { &emptyStyle };
const ElementStyle* _elementStyle { &emptyStyle };
PropertyFlags* _propertyFlagsList { 0 };
LinkedElements* _links { 0 };
int getPropertyFlagsIdx(Pid id) const;
@ -198,7 +198,7 @@ class ScoreElement {
virtual void reset(); // reset all properties & position to default
virtual void initElementStyle(const ElementStyle*);
virtual const ElementStyle* styledProperties() const { return _subStyle; }
virtual const ElementStyle* styledProperties() const { return _elementStyle; }
virtual PropertyFlags* propertyFlagsList() const { return _propertyFlagsList; }
virtual PropertyFlags propertyFlags(Pid) const;

View file

@ -1121,7 +1121,7 @@ TextBase::TextBase(const TextBase& st)
_offset = st._offset;
_offsetType = st._offsetType;
int n = _subStyle->size() + TEXT_STYLE_SIZE;
int n = _elementStyle->size() + TEXT_STYLE_SIZE;
_propertyFlagsList = new PropertyFlags[n];
for (int i = 0; i < n; ++i)
_propertyFlagsList[i] = st._propertyFlagsList[i];
@ -1676,7 +1676,7 @@ void TextBase::writeProperties(XmlWriter& xml, bool writeText, bool /*writeStyle
Element::writeProperties(xml);
writeProperty(xml, Pid::SUB_STYLE);
for (const StyledProperty& spp : *_subStyle)
for (const StyledProperty& spp : *_elementStyle)
writeProperty(xml, spp.pid);
for (const StyledProperty& spp : *textStyle(tid()))
writeProperty(xml, spp.pid);
@ -2376,7 +2376,7 @@ QVariant TextBase::propertyDefault(Pid id) const
int TextBase::getPropertyFlagsIdx(Pid id) const
{
int i = 0;
for (const StyledProperty& p : *_subStyle) {
for (const StyledProperty& p : *_elementStyle) {
if (p.pid == id)
return i;
++i;
@ -2421,7 +2421,7 @@ void TextBase::setPropertyFlags(Pid id, PropertyFlags f)
Sid TextBase::getPropertyStyle(Pid id) const
{
for (const StyledProperty& p : *_subStyle) {
for (const StyledProperty& p : *_elementStyle) {
if (p.pid == id)
return p.sid;
}
@ -2443,7 +2443,7 @@ void TextBase::styleChanged()
return;
}
int i = 0;
for (const StyledProperty& spp : *_subStyle) {
for (const StyledProperty& spp : *_elementStyle) {
PropertyFlags f = _propertyFlagsList[i];
if (f == PropertyFlags::STYLED) {
if (propertyType(spp.pid) == P_TYPE::SP_REAL) {
@ -2475,16 +2475,16 @@ void TextBase::styleChanged()
void TextBase::initElementStyle(const ElementStyle* ss)
{
_subStyle = ss;
int n = _subStyle->size() + TEXT_STYLE_SIZE;
_elementStyle = ss;
int n = _elementStyle->size() + TEXT_STYLE_SIZE;
// printf("<%s> initElementStyle n=%d + %d\n", name(), int(_subStyle->size()), TEXT_STYLE_SIZE);
// printf("<%s> initElementStyle n=%d + %d\n", name(), int(_elementStyle->size()), TEXT_STYLE_SIZE);
delete[] _propertyFlagsList;
_propertyFlagsList = new PropertyFlags[n];
for (int i = 0; i < n; ++i)
_propertyFlagsList[i] = PropertyFlags::STYLED;
for (const StyledProperty& p : *_subStyle) {
for (const StyledProperty& p : *_elementStyle) {
QVariant v = propertyType(p.pid) == P_TYPE::SP_REAL ? score()->styleP(p.sid) : score()->styleV(p.sid);
setProperty(p.pid, v);
}
@ -2504,7 +2504,7 @@ void TextBase::initElementStyle(const ElementStyle* ss)
void TextBase::initTid(Tid tid)
{
setTid(tid);
int i = _subStyle->size();
int i = _elementStyle->size();
for (const StyledProperty& p : *textStyle(tid)) {
Pid pid = p.pid;
QVariant v = propertyDefault(pid);