diff --git a/importexport/musicxml/exportxml.cpp b/importexport/musicxml/exportxml.cpp index af51a198df490..09a5359523043 100644 --- a/importexport/musicxml/exportxml.cpp +++ b/importexport/musicxml/exportxml.cpp @@ -363,8 +363,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(); @@ -5241,15 +5241,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); @@ -5261,7 +5270,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.isEmpty()) { @@ -5299,7 +5308,7 @@ void ExportMusicXml::dynamic(Dynamic const* const dyn, int staff) // found a non-dynamics character if (inDynamicsSym) { if (!text.isEmpty()) { - if (set.contains(text)) + if (mu::contains(set, text)) _xml.tagE(text); else _xml.tag("other-dynamics", text); @@ -5311,7 +5320,7 @@ void ExportMusicXml::dynamic(Dynamic const* const dyn, int staff) } } if (!text.isEmpty()) { - if (inDynamicsSym && set.contains(text)) + if (inDynamicsSym && mu::contains(set, text)) _xml.tagE(text); else _xml.tag("other-dynamics", text); @@ -6083,15 +6092,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: @@ -6104,7 +6113,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)); @@ -6683,7 +6692,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) { @@ -6825,7 +6834,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; @@ -6834,7 +6843,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); } } @@ -7254,7 +7263,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); @@ -7355,7 +7364,7 @@ void ExportMusicXml::writeMeasure(const Measure* const m, MeasureNumberStateHandler& mnsh, FigBassMap& fbMap, const MeasurePrintContext& mpc, - QSet& spannersStopped) + std::set& spannersStopped) { const Part* part = _score->parts().at(partIndex); const int staves = part->nstaves(); @@ -7477,7 +7486,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 bfc9275c50f31..54c2b6e9cf603 100644 --- a/importexport/musicxml/importmxmlpass1.cpp +++ b/importexport/musicxml/importmxmlpass1.cpp @@ -1158,7 +1158,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(); @@ -1190,14 +1190,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 2fab30803e4e5..d248050b3695b 100644 --- a/importexport/musicxml/importmxmlpass2.cpp +++ b/importexport/musicxml/importmxmlpass2.cpp @@ -192,7 +192,7 @@ void MusicXmlLyricsExtend::setExtend(const int no, const int track, const Fracti } // cleanup for (Lyrics* l: list) { - _lyrics.remove(l); + mu::remove(_lyrics, l); } } @@ -850,24 +850,24 @@ 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)) { Lyrics* const lyric = numbrdLyrics.at(lyricNo); addLyric(logger, xmlreader, cr, lyric, lyricNo, extendedLyrics); - if (extLyrics.contains(lyric)) + if (mu::contains(extLyrics, lyric)) extendedLyrics.addLyric(lyric); } } -static void addGraceNoteLyrics(const std::map& numberedLyrics, QSet extendedLyrics, +static void addGraceNoteLyrics(const std::map& numberedLyrics, std::set extendedLyrics, std::vector& gnLyrics) { for (const auto lyricNo : mu::keys(numberedLyrics)) { Lyrics* const lyric = numberedLyrics.at(lyricNo); if (lyric) { - bool extend = extendedLyrics.contains(lyric); + bool extend = mu::contains(extendedLyrics, lyric); const GraceNoteLyrics gnl = GraceNoteLyrics(lyric, extend, lyricNo); gnLyrics.push_back(gnl); } diff --git a/importexport/musicxml/importmxmlpass2.h b/importexport/musicxml/importmxmlpass2.h index 143b7c1066b29..19ebfdf78a4fa 100644 --- a/importexport/musicxml/importmxmlpass2.h +++ b/importexport/musicxml/importmxmlpass2.h @@ -111,7 +111,7 @@ class MusicXmlLyricsExtend { void setExtend(const int no, const int track, const Fraction& tick, const Lyrics* prevAddedLyrics); private: - QSet _lyrics; + std::set _lyrics; }; struct GraceNoteLyrics { @@ -131,7 +131,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: @@ -142,7 +142,7 @@ class MusicXMLParserLyric { Score* const _score = nullptr; // the score MxmlLogger* _logger = nullptr; ///< 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 }; //---------------------------------------------------------