[engraving] moved staffname write
This commit is contained in:
parent
6f05c62db6
commit
8eacda3d22
5 changed files with 27 additions and 32 deletions
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "rw/xmlreader.h"
|
||||
#include "rw/xmlwriter.h"
|
||||
#include "rw/400/twrite.h"
|
||||
#include "style/style.h"
|
||||
#include "types/typesconv.h"
|
||||
|
||||
|
@ -305,8 +306,8 @@ bool InstrumentTemplate::isValid() const
|
|||
void InstrumentTemplate::write(XmlWriter& xml) const
|
||||
{
|
||||
xml.startElement("Instrument", { { "id", id } });
|
||||
longNames.write(xml, "longName");
|
||||
shortNames.write(xml, "shortName");
|
||||
rw400::TWrite::write(&longNames, xml, "longName");
|
||||
rw400::TWrite::write(&shortNames, xml, "shortName");
|
||||
|
||||
if (longNames.size() > 1) {
|
||||
xml.tag("trackName", trackName);
|
||||
|
|
|
@ -240,21 +240,6 @@ StaffName::StaffName(const String& xmlText, int pos)
|
|||
TextBase::validateText(_name); // enforce HTML encoding
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// StaffName::write
|
||||
//---------------------------------------------------------
|
||||
|
||||
void StaffName::write(XmlWriter& xml, const char* tag) const
|
||||
{
|
||||
if (!name().isEmpty()) {
|
||||
if (pos() == 0) {
|
||||
xml.writeXml(String::fromUtf8(tag), name());
|
||||
} else {
|
||||
xml.writeXml(String(u"%1 pos=\"%2\"").arg(String::fromUtf8(tag)).arg(pos()), name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// read
|
||||
//---------------------------------------------------------
|
||||
|
@ -1699,17 +1684,6 @@ void Instrument::setSingleNoteDynamicsFromTemplate()
|
|||
setSingleNoteDynamics(getSingleNoteDynamicsFromTemplate());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// StaffNameList::write
|
||||
//---------------------------------------------------------
|
||||
|
||||
void StaffNameList::write(XmlWriter& xml, const char* name) const
|
||||
{
|
||||
for (const StaffName& sn : *this) {
|
||||
sn.write(xml, name);
|
||||
}
|
||||
}
|
||||
|
||||
std::list<String> StaffNameList::toStringList() const
|
||||
{
|
||||
std::list<String> result;
|
||||
|
|
|
@ -65,7 +65,6 @@ public:
|
|||
bool operator==(const StaffName&) const;
|
||||
String toString() const;
|
||||
void read(XmlReader&);
|
||||
void write(XmlWriter& xml, const char* name) const;
|
||||
int pos() const { return _pos; }
|
||||
String name() const { return _name; }
|
||||
};
|
||||
|
@ -82,7 +81,6 @@ public:
|
|||
StaffNameList(const std::list<StaffName>& l)
|
||||
: std::list<StaffName>(l) {}
|
||||
|
||||
void write(XmlWriter& xml, const char* name) const;
|
||||
std::list<String> toStringList() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -1473,8 +1473,8 @@ void TWrite::write(const Instrument* item, XmlWriter& xml, WriteContext&, const
|
|||
} else {
|
||||
xml.startElement("Instrument", { { "id", item->id() } });
|
||||
}
|
||||
item->longNames().write(xml, "longName");
|
||||
item->shortNames().write(xml, "shortName");
|
||||
write(&item->longNames(), xml, "longName");
|
||||
write(&item->shortNames(), xml, "shortName");
|
||||
// if (!_trackName.empty())
|
||||
xml.tag("trackName", item->trackName());
|
||||
if (item->minPitchP() > 0) {
|
||||
|
@ -1542,6 +1542,24 @@ void TWrite::write(const Instrument* item, XmlWriter& xml, WriteContext&, const
|
|||
xml.endElement();
|
||||
}
|
||||
|
||||
void TWrite::write(const StaffName* item, XmlWriter& xml, const char* tag)
|
||||
{
|
||||
if (!item->name().isEmpty()) {
|
||||
if (item->pos() == 0) {
|
||||
xml.writeXml(String::fromUtf8(tag), item->name());
|
||||
} else {
|
||||
xml.writeXml(String(u"%1 pos=\"%2\"").arg(String::fromUtf8(tag)).arg(item->pos()), item->name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TWrite::write(const StaffNameList* item, XmlWriter& xml, const char* name)
|
||||
{
|
||||
for (const StaffName& sn : *item) {
|
||||
write(&sn, xml, name);
|
||||
}
|
||||
}
|
||||
|
||||
void TWrite::write(const InstrumentChange* item, XmlWriter& xml, WriteContext& ctx)
|
||||
{
|
||||
xml.startElement(item);
|
||||
|
|
|
@ -123,6 +123,8 @@ class SLine;
|
|||
class Spanner;
|
||||
class Spacer;
|
||||
class Staff;
|
||||
class StaffName;
|
||||
class StaffNameList;
|
||||
class StaffState;
|
||||
class StaffText;
|
||||
class StaffTextBase;
|
||||
|
@ -250,6 +252,8 @@ public:
|
|||
static void write(const Slur* item, XmlWriter& xml, WriteContext& ctx);
|
||||
static void write(const Spacer* item, XmlWriter& xml, WriteContext& ctx);
|
||||
static void write(const Staff* item, XmlWriter& xml, WriteContext& ctx);
|
||||
static void write(const StaffName* item, XmlWriter& xml, const char* tag);
|
||||
static void write(const StaffNameList* item, XmlWriter& xml, const char* name);
|
||||
static void write(const StaffState* item, XmlWriter& xml, WriteContext& ctx);
|
||||
static void write(const StaffText* item, XmlWriter& xml, WriteContext& ctx);
|
||||
static void write(const StaffType* item, XmlWriter& xml, WriteContext& ctx);
|
||||
|
|
Loading…
Reference in a new issue