Merge pull request #11249 from igorkorsukov/engraving/noqt_list_8

[engraving] replaced QList to std. Part 8
This commit is contained in:
RomanPudashkin 2022-04-19 20:04:33 +02:00 committed by GitHub
commit dc99dcce7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 123 additions and 106 deletions

View file

@ -50,18 +50,12 @@ int main()
{
std::cout << "Hello World" << std::endl;
std::vector<int> vec1 = { 1, 2, 3, 4, 5 };
std::vector<int> vec2 = { 1, 2, 3 };
std::list<int> l1 = { 1, 2, 3 };
std::list<int> l2 = { 11, 21, 31 };
print(vec2);
vec2.insert(vec2.begin() + vec2.size(), 4);
print(vec2);
vec2.insert(vec2.begin() + vec2.size() - 1, 5);
print(vec2);
for (auto it1 = l1.begin(), it2 = l2.begin(); it1 != l1.end(); ++it1, ++it2) {
std::cout << "a: " << *it1 << ", b: " << *it2 << "\n";
}
std::cout << " Goodbye!" << std::endl;

View file

@ -24,6 +24,7 @@
#define __CHORDLIST_H__
#include <map>
#include <QString>
#include "containers.h"
#include "style/style.h"

View file

@ -1317,7 +1317,7 @@ void Score::cmdAddTimeSig(Measure* fm, int staffIdx, TimeSig* ts, bool local)
nsig->setParent(seg);
undoAddElement(nsig);
if (score->excerpt()) {
const int masterTrack = score->excerpt()->tracksMapping().key(nsig->track());
const int masterTrack = mu::key(score->excerpt()->tracksMapping(), nsig->track());
TimeSig* masterTimeSig = masterTimeSigs[masterTrack];
if (masterTimeSig) {
undo(new Link(masterTimeSig, nsig));
@ -4756,12 +4756,12 @@ static EngravingItem* findLinkedVoiceElement(EngravingItem* e, Staff* nstaff)
int dtrack = nstaff->idx() * VOICES + e->voice();
if (se) {
strack = se->tracksMapping().key(strack);
strack = mu::key(se->tracksMapping(), strack);
}
if (de) {
QList<int> l = de->tracksMapping().values(strack);
if (l.isEmpty()) {
std::vector<int> l = mu::values(de->tracksMapping(), strack);
if (l.empty()) {
// simply return the first linked element whose staff is equal to nstaff
for (EngravingObject* ee : e->linkList()) {
EngravingItem* el = toEngravingItem(ee);
@ -4771,7 +4771,7 @@ static EngravingItem* findLinkedVoiceElement(EngravingItem* e, Staff* nstaff)
}
return 0;
}
for (int i : qAsConst(l)) {
for (int i : l) {
if (nstaff->idx() * VOICES <= i && (nstaff->idx() + 1) * VOICES > i) {
dtrack = i;
break;
@ -4799,12 +4799,12 @@ static Chord* findLinkedChord(Chord* c, Staff* nstaff)
int dtrack = nstaff->idx() * VOICES + c->voice();
if (se) {
strack = se->tracksMapping().key(strack);
strack = mu::key(se->tracksMapping(), strack);
}
if (de) {
QList<int> l = de->tracksMapping().values(strack);
if (l.isEmpty()) {
std::vector<int> l = mu::values(de->tracksMapping(), strack);
if (l.empty()) {
// simply return the first linked chord whose staff is equal to nstaff
for (EngravingObject* ee : c->linkList()) {
Chord* ch = toChord(ee);
@ -4908,21 +4908,21 @@ void Score::undoExchangeVoice(Measure* measure, int srcVoice, int dstVoice, int
Excerpt* ex = st->score()->excerpt();
if (ex) {
QMultiMap<int, int> tracks = ex->tracksMapping();
QList<int> srcTrackList = tracks.values(srcTrack);
QList<int> dstTrackList = tracks.values(dstTrack);
std::multimap<int, int> tracks = ex->tracksMapping();
std::vector<int> srcTrackList = mu::values(tracks, srcTrack);
std::vector<int> dstTrackList = mu::values(tracks, dstTrack);
for (int srcTrack2 : qAsConst(srcTrackList)) {
for (int srcTrack2 : srcTrackList) {
// don't care about other linked staves
if (!(staffTrack <= srcTrack2) || !(srcTrack2 < staffTrack + VOICES)) {
continue;
}
int tempTrack = tracks.key(srcTrack2);
QList<int> testTracks = tracks.values(tempTrack + trackDiff);
int tempTrack = srcTrack;
std::vector<int> testTracks = mu::values(tracks, tempTrack + trackDiff);
bool hasVoice = false;
for (int testTrack : qAsConst(testTracks)) {
if (staffTrack <= testTrack && testTrack < staffTrack + VOICES && dstTrackList.contains(testTrack)) {
for (int testTrack : testTracks) {
if (staffTrack <= testTrack && testTrack < staffTrack + VOICES && mu::contains(dstTrackList, testTrack)) {
hasVoice = true;
// voice is simply exchangeable now (deal directly)
undo(new ExchangeVoice(measure2, srcTrack2, testTrack, staffTrack / 4));
@ -4933,7 +4933,7 @@ void Score::undoExchangeVoice(Measure* measure, int srcVoice, int dstVoice, int
if (!hasVoice) {
undo(new CloneVoice(measure->first(), measure2->endTick(), measure2->first(), tempTrack, srcTrack2,
tempTrack + trackDiff));
srcTrackList.removeOne(srcTrack2);
mu::remove(srcTrackList, srcTrack2);
}
}
@ -4943,12 +4943,11 @@ void Score::undoExchangeVoice(Measure* measure, int srcVoice, int dstVoice, int
continue;
}
int tempTrack = tracks.key(dstTrack2);
QList<int> testTracks = tracks.values(tempTrack - trackDiff);
int tempTrack = dstTrack;
std::vector<int> testTracks = mu::values(tracks, tempTrack - trackDiff);
bool hasVoice = false;
for (int testTrack : qAsConst(testTracks)) {
if (staffTrack <= testTrack && testTrack < staffTrack + VOICES
&& srcTrackList.contains(testTrack)) {
if (staffTrack <= testTrack && testTrack < staffTrack + VOICES && mu::contains(srcTrackList, testTrack)) {
hasVoice = true;
}
}
@ -4957,7 +4956,7 @@ void Score::undoExchangeVoice(Measure* measure, int srcVoice, int dstVoice, int
if (!hasVoice) {
undo(new CloneVoice(measure->first(), measure2->endTick(), measure2->first(), tempTrack, dstTrack2,
tempTrack - trackDiff));
dstTrackList.removeOne(dstTrack2);
mu::remove(dstTrackList, dstTrack2);
}
}
} else if (srcStaffTrack != staffTrack) {
@ -5111,8 +5110,8 @@ void Score::undoAddElement(EngravingItem* element, bool ctrlModifier)
int strack = -1;
if (ostaff) {
strack = ostaff->idx() * VOICES + element->track() % VOICES;
if (ostaff->score()->excerpt() && !ostaff->score()->excerpt()->tracksMapping().isEmpty() && strack > -1) {
strack = ostaff->score()->excerpt()->tracksMapping().key(strack, -1);
if (ostaff->score()->excerpt() && !ostaff->score()->excerpt()->tracksMapping().empty() && strack > -1) {
strack = mu::key(ostaff->score()->excerpt()->tracksMapping(), strack, -1);
}
}
@ -5319,20 +5318,20 @@ void Score::undoAddElement(EngravingItem* element, bool ctrlModifier)
int track = staff->idx() * VOICES + (strack % VOICES);
tr.push_back(track);
} else {
QMultiMap<int, int> mapping = staff->score()->excerpt()->tracksMapping();
if (mapping.isEmpty()) {
std::multimap<int, int> mapping = staff->score()->excerpt()->tracksMapping();
if (mapping.empty()) {
// This can happen during reading the score and there is
// no Tracklist tag specified.
// TODO solve this in read302.cpp.
tr.push_back(strack);
} else {
for (int track : mapping.values(strack)) {
for (int track : mu::values(mapping, strack)) {
// linkedPart : linked staves within same part/instrument.
// linkedScore: linked staves over different scores via excerpts.
const bool linkedPart = linked && (staff != ostaff) && (staff->score() == ostaff->score());
const bool linkedScore = linked && (staff != ostaff) && (staff->score() != ostaff->score());
if (linkedPart && !linkedScore) {
tr.push_back(staff->idx() * VOICES + mapping.value(track) % VOICES);
tr.push_back(staff->idx() * VOICES + mu::value(mapping, track) % VOICES);
} else if (!linkedPart && linkedScore) {
if ((track >> 2) != staffIdx) {
track += (staffIdx - (track >> 2)) * VOICES;
@ -5690,8 +5689,8 @@ void Score::undoAddCR(ChordRest* cr, Measure* measure, const Fraction& tick)
Staff* ostaff = cr->staff();
int strack = ostaff->idx() * VOICES + cr->voice();
if (ostaff->score()->excerpt() && !ostaff->score()->excerpt()->tracksMapping().isEmpty()) {
strack = ostaff->score()->excerpt()->tracksMapping().key(strack, -1);
if (ostaff->score()->excerpt() && !ostaff->score()->excerpt()->tracksMapping().empty()) {
strack = mu::key(ostaff->score()->excerpt()->tracksMapping(), strack, -1);
}
SegmentType segmentType = SegmentType::ChordRest;
@ -5708,8 +5707,8 @@ void Score::undoAddCR(ChordRest* cr, Measure* measure, const Fraction& tick)
int track = staff->idx() * VOICES + (strack % VOICES);
tracks.push_back(track);
} else {
QMultiMap<int, int> mapping = staff->score()->excerpt()->tracksMapping();
if (mapping.isEmpty()) {
std::multimap<int, int> mapping = staff->score()->excerpt()->tracksMapping();
if (mapping.empty()) {
// This can happen during reading the score and there is
// no Tracklist tag specified.
// TODO solve this in read302.cpp.
@ -5719,9 +5718,9 @@ void Score::undoAddCR(ChordRest* cr, Measure* measure, const Fraction& tick)
// linkedScore: linked staves over different scores via excerpts.
const bool linkedPart = linked && (staff != ostaff) && (staff->score() == ostaff->score());
const bool linkedScore = linked && (staff != ostaff) && (staff->score() != ostaff->score());
for (int track : mapping.values(strack)) {
for (int track : mu::values(mapping, strack)) {
if (linkedPart && !linkedScore) {
tracks.push_back(staff->idx() * VOICES + mapping.value(track) % VOICES);
tracks.push_back(staff->idx() * VOICES + mu::value(mapping, track) % VOICES);
} else if (!linkedPart && linkedScore) {
if ((track >> 2) != staff->idx()) {
track += (staff->idx() - (track >> 2)) * VOICES;

View file

@ -23,6 +23,7 @@
#include "excerpt.h"
#include <QRegularExpression>
#include <list>
#include "containers.h"
@ -120,9 +121,9 @@ void Excerpt::removePart(const ID& id)
excerptScore()->undoRemovePart(excerptScore()->parts().at(index));
}
int Excerpt::nstaves() const
size_t Excerpt::nstaves() const
{
int n { 0 };
size_t n = 0;
for (Part* p : m_parts) {
n += p->nstaves();
}
@ -134,7 +135,7 @@ bool Excerpt::isEmpty() const
return excerptScore() ? excerptScore()->parts().empty() : true;
}
void Excerpt::setTracksMapping(const QMultiMap<int, int>& tracksMapping)
void Excerpt::setTracksMapping(const std::multimap<int, int>& tracksMapping)
{
m_tracksMapping = tracksMapping;
@ -149,7 +150,7 @@ void Excerpt::setTracksMapping(const QMultiMap<int, int>& tracksMapping)
void Excerpt::updateTracksMapping()
{
QMultiMap<int, int> tracks;
std::multimap<int, int> tracks;
for (Staff* staff : excerptScore()->staves()) {
Staff* masterStaff = masterScore()->staffById(staff->id());
if (!masterStaff) {
@ -162,7 +163,7 @@ void Excerpt::updateTracksMapping()
continue;
}
tracks.insert(masterStaff->idx() * VOICES + i % VOICES, staff->idx() * VOICES + voice % VOICES);
tracks.insert({ masterStaff->idx() * VOICES + i % VOICES, staff->idx() * VOICES + voice % VOICES });
voice++;
}
}
@ -284,7 +285,7 @@ void Excerpt::createExcerpt(Excerpt* excerpt)
}
// Fill tracklist (map all tracks of a stave)
if (excerpt->tracksMapping().isEmpty()) {
if (excerpt->tracksMapping().empty()) {
excerpt->updateTracksMapping();
}
@ -577,7 +578,7 @@ static void processLinkedClone(EngravingItem* ne, Score* score, int strack)
static Ms::MeasureBase* cloneMeasure(Ms::MeasureBase* mb, Ms::Score* score, const Ms::Score* oscore,
const std::vector<int>& sourceStavesIndexes,
const QMultiMap<int, int>& trackList, TieMap& tieMap)
const std::multimap<int, int>& trackList, TieMap& tieMap)
{
Ms::MeasureBase* nmb = nullptr;
@ -614,14 +615,14 @@ static Ms::MeasureBase* cloneMeasure(Ms::MeasureBase* mb, Ms::Score* score, cons
}
int tracks = oscore->nstaves() * VOICES;
if (sourceStavesIndexes.empty() && trackList.isEmpty()) {
if (sourceStavesIndexes.empty() && trackList.empty()) {
tracks = 0;
}
for (int srcTrack = 0; srcTrack < tracks; ++srcTrack) {
TupletMap tupletMap; // tuplets cannot cross measure boundaries
int strack = trackList.value(srcTrack, -1);
int strack = mu::value(trackList, srcTrack, -1);
Tremolo* tremolo = 0;
for (Segment* oseg = m->first(); oseg; oseg = oseg->next()) {
@ -653,14 +654,14 @@ static Ms::MeasureBase* cloneMeasure(Ms::MeasureBase* mb, Ms::Score* score, cons
}
//If track is not mapped skip the following
if (trackList.value(srcTrack, -1) == -1) {
if (mu::value(trackList, srcTrack, -1) == -1) {
continue;
}
//There are probably more destination tracks for the same source
QList<int> t = trackList.values(srcTrack);
std::vector<int> t = mu::values(trackList, srcTrack);
for (int track : qAsConst(t)) {
for (int track : t) {
//Clone KeySig TimeSig and Clefs if voice 1 of source staff is not mapped to a track
EngravingItem* oef = oseg->element(trackZeroVoice(srcTrack));
if (oef && !oef->generated() && (oef->isTimeSig() || oef->isKeySig())
@ -850,7 +851,7 @@ static Ms::MeasureBase* cloneMeasure(Ms::MeasureBase* mb, Ms::Score* score, cons
int track = -1;
if (e->track() != -1) {
// try to map track
track = trackList.value(e->track(), -1);
track = mu::value(trackList, e->track(), -1);
if (track == -1) {
// even if track not in excerpt, we need to clone system elements
if (e->systemFlag() && e->track() == 0) {
@ -885,8 +886,8 @@ static Ms::MeasureBase* cloneMeasure(Ms::MeasureBase* mb, Ms::Score* score, cons
return nmb;
}
void Excerpt::cloneStaves(Score* sourceScore, Score* destinationScore, const std::vector<int>& sourceStavesIndexes, const QMultiMap<int,
int>& trackList)
void Excerpt::cloneStaves(Score* sourceScore, Score* destinationScore, const std::vector<int>& sourceStavesIndexes,
const std::multimap<int, int>& trackList)
{
MeasureBaseList* measures = destinationScore->measures();
TieMap tieMap;
@ -961,9 +962,9 @@ void Excerpt::cloneStaves(Score* sourceScore, Score* destinationScore, const std
} else if (s->isHairpin()) {
//always export these spanners to first voice of the destination staff
QList<int> track1;
std::vector<int> track1;
for (int ii = s->track(); ii < s->track() + VOICES; ii++) {
track1 += trackList.values(ii);
mu::join(track1, mu::values(trackList, ii));
}
for (int track : qAsConst(track1)) {
@ -972,20 +973,20 @@ void Excerpt::cloneStaves(Score* sourceScore, Score* destinationScore, const std
}
}
} else {
if (trackList.value(s->track(), -1) == -1 || trackList.value(s->track2(), -1) == -1) {
if (mu::value(trackList, s->track(), -1) == -1 || mu::value(trackList, s->track2(), -1) == -1) {
continue;
}
QList<int> track1 = trackList.values(s->track());
QList<int> track2 = trackList.values(s->track2());
std::vector<int> track1 = mu::values(trackList, s->track());
std::vector<int> track2 = mu::values(trackList, s->track2());
if (track1.length() != track2.length()) {
if (track1.size() != track2.size()) {
continue;
}
//export other spanner if staffidx matches
for (int ii = 0; ii < track1.length(); ii++) {
dstTrack = track1.at(ii);
dstTrack2 = track2.at(ii);
for (auto it1 = track1.begin(), it2 = track2.begin(); it1 != track1.end(); ++it1, ++it2) {
dstTrack = *it1;
dstTrack2 = *it2;
cloneSpanner(s, destinationScore, dstTrack, dstTrack2);
}
}
@ -1212,7 +1213,7 @@ void Excerpt::cloneStaff2(Staff* srcStaff, Staff* dstStaff, const Fraction& star
Excerpt* oex = oscore->excerpt();
Excerpt* ex = score->excerpt();
QMultiMap<int, int> otracks, tracks;
std::multimap<int, int> otracks, tracks;
if (oex) {
otracks = oex->tracksMapping();
}
@ -1240,19 +1241,21 @@ void Excerpt::cloneStaff2(Staff* srcStaff, Staff* dstStaff, const Fraction& star
if (!oex && !ex) {
map.insert({ i, dstStaffIdx * VOICES + i % VOICES });
} else if (oex && !ex) {
if (otracks.key(i, -1) != -1) {
map.insert({ i, otracks.key(i) });
int k = mu::key(otracks, i, -1);
if (k != -1) {
map.insert({ i, k });
}
} else if (!oex && ex) {
for (int j : tracks.values(i)) {
for (int j : mu::values(tracks, i)) {
if (dstStaffIdx * VOICES <= j && j < (dstStaffIdx + 1) * VOICES) {
map.insert({ i, j });
break;
}
}
} else if (oex && ex) {
if (otracks.key(i, -1) != -1) {
for (int j : tracks.values(otracks.key(i))) {
int k = mu::key(otracks, i, -1);
if (k != -1) {
for (int j : mu::values(tracks, k)) {
if (dstStaffIdx * VOICES <= j && j < (dstStaffIdx + 1) * VOICES) {
map.insert({ i, j });
break;
@ -1421,7 +1424,7 @@ std::vector<Excerpt*> Excerpt::createExcerptsFromParts(const std::vector<Part*>&
excerpt->parts().push_back(part);
for (int i = part->startTrack(), j = 0; i < part->endTrack(); ++i, ++j) {
excerpt->tracksMapping().insert(i, j);
excerpt->tracksMapping().insert({ i, j });
}
QString name = formatName(part->partName(), result);

View file

@ -23,7 +23,7 @@
#ifndef MU_ENGRAVING_EXCERPT_H
#define MU_ENGRAVING_EXCERPT_H
#include <QMultiMap>
#include <map>
#include "types/fraction.h"
#include "mscore.h"
@ -59,11 +59,11 @@ public:
void removePart(const ID& id);
int nstaves() const;
size_t nstaves() const;
bool isEmpty() const;
QMultiMap<int, int>& tracksMapping() { return m_tracksMapping; }
void setTracksMapping(const QMultiMap<int, int>& tracksMapping);
std::multimap<int, int>& tracksMapping() { return m_tracksMapping; }
void setTracksMapping(const std::multimap<int, int>& tracksMapping);
void updateTracksMapping();
@ -78,8 +78,8 @@ public:
static Excerpt* createExcerptFromPart(Part* part);
static void createExcerpt(Excerpt*);
static void cloneStaves(Score* sourceScore, Score* destinationScore, const std::vector<int>& sourceStavesIndexes, const QMultiMap<int,
int>& allTracks);
static void cloneStaves(Score* sourceScore, Score* destinationScore, const std::vector<int>& sourceStavesIndexes,
const std::multimap<int, int>& allTracks);
static void cloneMeasures(Score* oscore, Score* score);
static void cloneStaff(Staff* ostaff, Staff* nstaff);
static void cloneStaff2(Staff* ostaff, Staff* nstaff, const Fraction& startTick, const Fraction& endTick);
@ -91,7 +91,7 @@ private:
Score* m_excerptScore = nullptr;
QString m_name;
std::vector<Part*> m_parts;
QMultiMap<int, int> m_tracksMapping;
std::multimap<int, int> m_tracksMapping;
};
}

View file

@ -424,7 +424,7 @@ void MasterScore::addExcerpt(Excerpt* ex, int index)
}
}
if (ex->tracksMapping().isEmpty()) { // SHOULDN'T HAPPEN, protected in the UI, but it happens during read-in!!!
if (ex->tracksMapping().empty()) { // SHOULDN'T HAPPEN, protected in the UI, but it happens during read-in!!!
ex->updateTracksMapping();
}

View file

@ -368,8 +368,8 @@ void Score::putNote(const Position& p, bool replace)
_is.setTrack(p.staffIdx * VOICES + _is.voice());
_is.setSegment(s);
if (score()->excerpt() && !score()->excerpt()->tracksMapping().isEmpty()
&& score()->excerpt()->tracksMapping().key(_is.track(), -1) == -1) {
if (score()->excerpt() && !score()->excerpt()->tracksMapping().empty()
&& mu::key(score()->excerpt()->tracksMapping(), _is.track(), -1) == -1) {
return;
}

View file

@ -448,7 +448,7 @@ Score* Score::clone()
excerpt->parts().push_back(part);
for (int track = part->startTrack(); track < part->endTrack(); ++track) {
excerpt->tracksMapping().insert(track, track);
excerpt->tracksMapping().insert({ track, track });
}
}
@ -2929,13 +2929,13 @@ void Score::sortStaves(std::vector<int>& dst)
void Score::mapExcerptTracks(const std::vector<int>& dst)
{
for (Excerpt* e : masterScore()->excerpts()) {
QMultiMap<int, int> tr = e->tracksMapping();
QMultiMap<int, int> tracks;
std::multimap<int, int> tr = e->tracksMapping();
std::multimap<int, int> tracks;
for (auto it = tr.begin(); it != tr.end(); ++it) {
int prvStaffIdx = it.key() / VOICES;
int prvStaffIdx = it->first / VOICES;
int curStaffIdx = mu::indexOf(dst, prvStaffIdx);
int offset = (curStaffIdx - prvStaffIdx) * VOICES;
tracks.insert(it.key() + offset, it.value());
tracks.insert({ it->first + offset, it->second });
}
e->tracksMapping() = tracks;
}
@ -4969,7 +4969,7 @@ void Score::changeSelectedNotesVoice(int voice)
ChordRest* dstCR = toChordRest(s->element(dstTrack));
Chord* dstChord = nullptr;
if (excerpt() && excerpt()->tracksMapping().key(dstTrack, -1) == -1) {
if (excerpt() && mu::key(excerpt()->tracksMapping(), dstTrack, -1) == -1) {
break;
}

View file

@ -107,12 +107,10 @@ void Score::write(XmlWriter& xml, bool selectionOnly, compat::WriteScoreHook& ho
if (excerpt()) {
Excerpt* e = excerpt();
QMultiMap<int, int> trackList = e->tracksMapping();
QMapIterator<int, int> i(trackList);
if (!(trackList.size() == e->nstaves() * VOICES) && !trackList.isEmpty()) {
while (i.hasNext()) {
i.next();
xml.tagE(QString("Tracklist sTrack=\"%1\" dstTrack=\"%2\"").arg(i.key()).arg(i.value()));
std::multimap<int, int> trackList = e->tracksMapping();
if (!(trackList.size() == e->nstaves() * VOICES) && !trackList.empty()) {
for (auto it = trackList.begin(); it != trackList.end(); ++it) {
xml.tagE(QString("Tracklist sTrack=\"%1\" dstTrack=\"%2\"").arg(it->first).arg(it->second));
}
}
}

View file

@ -345,8 +345,8 @@ void Staff::updateVisibilityVoices(Staff* masterStaff)
int voiceIndex = 0;
for (int voice = 0; voice < VOICES; voice++) {
QList<int> masterStaffTracks = tracks.values(masterStaff->idx() * VOICES + voice % VOICES);
bool isVoiceVisible = masterStaffTracks.contains(idx() * VOICES + voiceIndex % VOICES);
std::vector<int> masterStaffTracks = mu::values(tracks, masterStaff->idx() * VOICES + voice % VOICES);
bool isVoiceVisible = mu::contains(masterStaffTracks, idx() * VOICES + voiceIndex % VOICES);
if (isVoiceVisible) {
voices[voice] = true;
voiceIndex++;

View file

@ -176,7 +176,7 @@ bool Read302::readScore302(Ms::Score* score, XmlReader& e, ReadContext& ctx)
int strack = e.intAttribute("sTrack", -1);
int dtrack = e.intAttribute("dstTrack", -1);
if (strack != -1 && dtrack != -1) {
e.tracks().insert(strack, dtrack);
e.tracks().insert({ strack, dtrack });
}
e.skipCurrentElement();
} else if (tag == "Score") { // recursion

View file

@ -194,7 +194,7 @@ bool Read400::readScore400(Ms::Score* score, XmlReader& e, ReadContext& ctx)
int strack = e.intAttribute("sTrack", -1);
int dtrack = e.intAttribute("dstTrack", -1);
if (strack != -1 && dtrack != -1) {
e.tracks().insert(strack, dtrack);
e.tracks().insert({ strack, dtrack });
}
e.skipCurrentElement();
} else if (tag == "Score") {

View file

@ -101,7 +101,7 @@ class XmlReader : public QXmlStreamReader
void htmlToString(int level, QString*);
Interval _transpose;
std::map<int, LinkedObjects*> _elinks; // for reading old files (< 3.01)
QMultiMap<int, int> _tracks;
std::multimap<int, int> _tracks;
std::list<TextStyleMap> userTextStyles;
@ -210,7 +210,7 @@ public:
void setTransposeDiatonic(int v) { _transpose.diatonic = v; }
std::map<int, LinkedObjects*>& linkIds() { return _elinks; }
QMultiMap<int, int>& tracks() { return _tracks; }
std::multimap<int, int>& tracks() { return _tracks; }
void checkTuplets();
TextStyleType addUserTextStyle(const QString& name);

View file

@ -232,6 +232,17 @@ inline auto keys(const Map& m) -> std::vector<typename Map::key_type>
return result;
}
template<typename Map, typename K>
inline K key(const Map& m, const K& k, const K& def = K())
{
for (auto&& p : m) {
if (p.first == k) {
return p.second;
}
}
return def;
}
template<typename Map, typename K>
inline auto value(const Map& m, const K& k) -> typename Map::mapped_type
{
@ -275,6 +286,17 @@ inline std::set<K> uniqueKeys(const std::multimap<K, V>& mm)
}
return keys;
}
template<typename K, typename V>
inline auto values(const std::multimap<K, V>& mm, const K& key) -> std::vector<typename std::multimap<K, V>::mapped_type>
{
std::vector<typename std::multimap<K, V>::mapped_type> result;
const auto range = mm.equal_range(key);
for (auto it = range.first; it != range.second; ++it) {
result.push_back(it->second);
}
return result;
}
}
#endif // MU_GLOBAL_CONTAINERS_H

View file

@ -1283,7 +1283,7 @@ Score::FileError PowerTab::read()
// static const char* tune[] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
int id = 0;
for (Part* part : score->parts()) {
QMultiMap<int, int> tracks;
std::multimap<int, int> tracks;
Score* pscore = score->createScore();
//TODO-ws pscore->tuning.clear();
@ -1311,7 +1311,7 @@ Score::FileError PowerTab::read()
pscore->appendStaff(s);
stavesMap.push_back(staff->idx());
for (int i = staff->idx() * VOICES, j = 0; i < staff->idx() * VOICES + VOICES; i++, j++) {
tracks.insert(i, j);
tracks.insert({ i, j });
}
Excerpt* excerpt = new Excerpt(score);