diff --git a/importexport/musicxml/exportxml.cpp b/importexport/musicxml/exportxml.cpp index 06217a775efea..e272676e4d9da 100644 --- a/importexport/musicxml/exportxml.cpp +++ b/importexport/musicxml/exportxml.cpp @@ -361,8 +361,8 @@ class ExportMusicXml { void findAndExportClef(const Measure* const m, const int staves, const int strack, const int etrack); void exportDefaultClef(const Part* const part, const Measure* const m); void writeElement(Element* el, const Measure* m, int sstaff, bool useDrumset); - void writeMeasureTracks(const Measure* const m, const int partIndex, const int strack, const int staves, const bool useDrumset, FigBassMap& fbMap, QSet& spannersStopped); - void writeMeasure(const Measure* const m, const int idx, const int staffCount, MeasureNumberStateHandler& mnsh, FigBassMap& fbMap, const MeasurePrintContext& mpc, QSet& spannersStopped); + void writeMeasureTracks(const Measure* const m, const int partIndex, const int strack, const int staves, const bool useDrumset, FigBassMap& fbMap, std::set& spannersStopped); + void writeMeasure(const Measure* const m, const int idx, const int staffCount, MeasureNumberStateHandler& mnsh, FigBassMap& fbMap, const MeasurePrintContext& mpc, std::set& spannersStopped); void repeatAtMeasureStart(Attributes& attr, const Measure* const m, int strack, int etrack, int track); void repeatAtMeasureStop(const Measure* const m, int strack, int etrack, int track); void writeParts(); @@ -4966,15 +4966,24 @@ void ExportMusicXml::textLine(TextLineBase const* const tl, int staff, const Fra // supported by MusicXML need to be filtered out. Everything not recognized // as MusicXML dynamics is written as other-dynamics. +template +inline std::set& operator<<(std::set& s, const T& v) + { + s.insert(v); + return s; + } + void ExportMusicXml::dynamic(Dynamic const* const dyn, int staff) { - QSet set; // the valid MusicXML dynamics - set << "f" << "ff" << "fff" << "ffff" << "fffff" << "ffffff" - << "fp" << "fz" - << "mf" << "mp" - << "p" << "pp" << "ppp" << "pppp" << "ppppp" << "pppppp" - << "rf" << "rfz" - << "sf" << "sffz" << "sfp" << "sfpp" << "sfz"; + static std::set set; // the valid MusicXML dynamics + if (set.empty()) { + set << "f" << "ff" << "fff" << "ffff" << "fffff" << "ffffff" + << "fp" << "fz" + << "mf" << "mp" + << "p" << "pp" << "ppp" << "pppp" << "ppppp" << "pppppp" + << "rf" << "rfz" + << "sf" << "sffz" << "sfp" << "sfpp" << "sfz"; + } directionTag(_xml, _attr, dyn); @@ -4986,7 +4995,7 @@ void ExportMusicXml::dynamic(Dynamic const* const dyn, int staff) _xml.stag(tagName); const QString dynTypeName = dyn->dynamicTypeName(); - if (set.contains(dynTypeName)) { + if (mu::contains(set, dynTypeName)) { _xml.tagE(dynTypeName); } else if (dynTypeName != "") { @@ -5024,7 +5033,7 @@ void ExportMusicXml::dynamic(Dynamic const* const dyn, int staff) // found a non-dynamics character if (inDynamicsSym) { if (text != "") { - if (set.contains(text)) + if (mu::contains(set, text)) _xml.tagE(text); else _xml.tag("other-dynamics", text); @@ -5036,7 +5045,7 @@ void ExportMusicXml::dynamic(Dynamic const* const dyn, int staff) } } if (text != "") { - if (inDynamicsSym && set.contains(text)) + if (inDynamicsSym && mu::contains(set, text)) _xml.tagE(text); else _xml.tag("other-dynamics", text); @@ -5793,15 +5802,15 @@ static void spannerStart(ExportMusicXml* exp, int strack, int etrack, int track, // note that more than one voice may contains notes ending at tick2, // remember which spanners have already been stopped (the "stopped" set) -static void spannerStop(ExportMusicXml* exp, int strack, int etrack, const Fraction& tick2, int sstaff, QSet& stopped) +static void spannerStop(ExportMusicXml* exp, int strack, int etrack, const Fraction& tick2, int sstaff, std::set& stopped) { for (auto it : exp->score()->spanner()) { - Spanner* e = it.second; + const Spanner* e = it.second; if (e->tick2() != tick2 || e->track() < strack || e->track() >= etrack) continue; - if (!stopped.contains(e)) { + if (!mu::contains(stopped, e)) { stopped.insert(e); switch (e->type()) { case ElementType::HAIRPIN: @@ -5814,7 +5823,7 @@ static void spannerStop(ExportMusicXml* exp, int strack, int etrack, const Fract exp->pedal(toPedal(e), sstaff, Fraction(-1,1)); break; case ElementType::TEXTLINE: - exp->textLine(toTextLineBase(e), sstaff, Fraction(-1,1)); + exp->textLine(static_cast(e), sstaff, Fraction(-1,1)); break; case ElementType::LET_RING: exp->textLine(toLetRing(e), sstaff, Fraction(-1,1)); @@ -6353,7 +6362,7 @@ void ExportMusicXml::findAndExportClef(const Measure* const m, const int staves, Find the set of pitches actually used in a part. */ -typedef QSet pitchSet; // the set of pitches used +typedef std::set pitchSet; // the set of pitches used static void addChordPitchesToSet(const Chord* c, pitchSet& set) { @@ -6483,7 +6492,7 @@ static void partList(XmlWriter& xml, Score* score, MxmlInstrumentMap& instrMap) DrumInstrument di = drumset->drum(i); if (di.notehead != NoteHead::Group::HEAD_INVALID) scoreInstrument(xml, idx + 1, i + 1, di.name); - else if (pitches.contains(i)) + else if (mu::contains(pitches, i)) scoreInstrument(xml, idx + 1, i + 1, QString("Instrument %1").arg(i + 1)); } int midiPort = part->midiPort() + 1; @@ -6492,7 +6501,7 @@ static void partList(XmlWriter& xml, Score* score, MxmlInstrumentMap& instrMap) for (int i = 0; i < 128; ++i) { DrumInstrument di = drumset->drum(i); - if (di.notehead != NoteHead::Group::HEAD_INVALID || pitches.contains(i)) + if (di.notehead != NoteHead::Group::HEAD_INVALID || mu::contains(pitches, i)) midiInstrument(xml, idx + 1, i + 1, part->instrument(), score, i + 1); } } @@ -6897,7 +6906,7 @@ void ExportMusicXml::writeMeasureTracks(const Measure* const m, const int strack, const int staves, // TODO remove ?? const bool useDrumset, FigBassMap& fbMap, - QSet& spannersStopped) + std::set& spannersStopped) { bool tboxesAboveWritten = false; const auto tboxesAbove = findTextFramesToWriteAsWordsAbove(m); @@ -6992,7 +7001,7 @@ void ExportMusicXml::writeMeasure(const Measure* const m, MeasureNumberStateHandler& mnsh, FigBassMap& fbMap, const MeasurePrintContext& mpc, - QSet& spannersStopped) + std::set& spannersStopped) { const auto part = _score->parts().at(partIndex); const int staves = part->nstaves(); @@ -7114,7 +7123,7 @@ void ExportMusicXml::writeParts() // set of spanners already stopped in this part // required to prevent multiple spanner stops for the same spanner - QSet spannersStopped; + std::set spannersStopped; const auto& pages = _score->pages(); MeasurePrintContext mpc; diff --git a/importexport/musicxml/importmxmlpass1.cpp b/importexport/musicxml/importmxmlpass1.cpp index 360a402468855..74a7c20a69180 100644 --- a/importexport/musicxml/importmxmlpass1.cpp +++ b/importexport/musicxml/importmxmlpass1.cpp @@ -1140,7 +1140,7 @@ void MusicXMLParserPass1::scorePartwise() // set of (typically multi-staff) parts containing one or more explicit brackets // spanning only that part: these won't get an implicit brace later // e.g. a two-staff piano part with an explicit brace - QSet partSet; + std::set partSet; // handle the explicit brackets const QList& il = _score->parts(); @@ -1172,14 +1172,14 @@ void MusicXMLParserPass1::scorePartwise() staff->setBracketSpan(pg->column, stavesSpan); // add part to set (skip implicit bracket later) if (pg->span == 1) - partSet << il.at(pg->start); + partSet.insert(il.at(pg->start)); } } // handle the implicit brackets: // multi-staff parts w/o explicit brackets get a brace - foreach (Part const* const p, il) { - if (p->nstaves() > 1 && !partSet.contains(p)) { + for (const Part* p : il) { + if (p->nstaves() > 1 && !mu::contains(partSet, p)) { const int column = p->staff(0)->bracketLevels() + 1; p->staff(0)->setBracketType(column, BracketType::BRACE); p->staff(0)->setBracketSpan(column, p->nstaves()); diff --git a/importexport/musicxml/importmxmlpass2.cpp b/importexport/musicxml/importmxmlpass2.cpp index 12e34ba1c6df7..692de24beb06f 100644 --- a/importexport/musicxml/importmxmlpass2.cpp +++ b/importexport/musicxml/importmxmlpass2.cpp @@ -190,7 +190,7 @@ void MusicXmlLyricsExtend::setExtend(const int no, const int track, const Fracti } // cleanup for (Lyrics* l: list) { - _lyrics.remove(l); + mu::remove(_lyrics, l); } } @@ -885,13 +885,13 @@ static void addLyric(MxmlLogger* logger, const QXmlStreamReader* const xmlreader static void addLyrics(MxmlLogger* logger, const QXmlStreamReader* const xmlreader, ChordRest* cr, const std::map& numbrdLyrics, - const QSet& extLyrics, + const std::set& extLyrics, MusicXmlLyricsExtend& extendedLyrics) { for (const auto lyricNo : mu::keys(numbrdLyrics)) { const auto lyric = numbrdLyrics.at(lyricNo); addLyric(logger, xmlreader, cr, lyric, lyricNo, extendedLyrics); - if (extLyrics.contains(lyric)) + if (mu::contains(extLyrics, lyric)) extendedLyrics.addLyric(lyric); } } diff --git a/importexport/musicxml/importmxmlpass2.h b/importexport/musicxml/importmxmlpass2.h index c3a6017b76994..715a43d2f336e 100644 --- a/importexport/musicxml/importmxmlpass2.h +++ b/importexport/musicxml/importmxmlpass2.h @@ -112,7 +112,7 @@ class MusicXmlLyricsExtend { void setExtend(const int no, const int track, const Fraction& tick); private: - QSet _lyrics; + std::set _lyrics; }; //--------------------------------------------------------- @@ -123,7 +123,7 @@ class MusicXMLParserLyric { public: MusicXMLParserLyric(const LyricNumberHandler lyricNumberHandler, QXmlStreamReader& e, Score* score, MxmlLogger* logger); - QSet extendedLyrics() const { return _extendedLyrics; } + std::set extendedLyrics() const { return _extendedLyrics; } std::map numberedLyrics() const { return _numberedLyrics; } void parse(); private: @@ -133,7 +133,7 @@ class MusicXMLParserLyric { Score* const _score; // the score MxmlLogger* _logger; ///< Error logger std::map _numberedLyrics; // lyrics with valid number - QSet _extendedLyrics; // lyrics with the extend flag set + std::set _extendedLyrics; // lyrics with the extend flag set }; //---------------------------------------------------------