Fixed iteration over QList.
This commit is contained in:
parent
3918de89ce
commit
c6463514b9
|
@ -131,7 +131,8 @@ void Sport::lastName(QList<Competitor> &competitors) {
|
||||||
// validate competitors
|
// validate competitors
|
||||||
if (competitors.isEmpty()) return;
|
if (competitors.isEmpty()) return;
|
||||||
|
|
||||||
for (Competitor comp : competitors) {
|
for (int i = 0; i < competitors.size(); i++) {
|
||||||
|
Competitor comp = competitors.value(i);
|
||||||
string fullName = comp.getName().toUtf8().constData();
|
string fullName = comp.getName().toUtf8().constData();
|
||||||
|
|
||||||
// regex to identify names, written in CAPS
|
// regex to identify names, written in CAPS
|
||||||
|
@ -203,7 +204,9 @@ QList<CompetitorWithResults> Sport::getCompetitorsByCategory(QString category) {
|
||||||
|
|
||||||
// add all competitors from one unit
|
// add all competitors from one unit
|
||||||
for (const QJsonValueRef &compRef : unit["competitors"].toArray()) {
|
for (const QJsonValueRef &compRef : unit["competitors"].toArray()) {
|
||||||
competitors.push_back(CompetitorWithResults(compRef.toObject()));
|
CompetitorWithResults comp = new CompetitorWithResults(); // TODO declare comp
|
||||||
|
comp.setCompetitorWithResults(compRef.toObject());
|
||||||
|
competitors.push_back(comp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +276,9 @@ QList<MedalWinner> Sport::getCompetitorsWithMedal() {
|
||||||
// convert map to QJsonArray
|
// convert map to QJsonArray
|
||||||
QList<MedalWinner> output;
|
QList<MedalWinner> output;
|
||||||
for (const pair<QString, QJsonObject> &competitor : competitors) {
|
for (const pair<QString, QJsonObject> &competitor : competitors) {
|
||||||
output.append(MedalWinner(competitor.second));
|
MedalWinner comp = new MedalWinner(); // TODO declare comp
|
||||||
|
comp.setMedalWinner(competitor.second);
|
||||||
|
output.append(comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
@ -332,8 +337,8 @@ void Sport::filterByCountry(QList<Competitor> &competitors, QString nocShort) {
|
||||||
* @param filter The string, which should be contained.
|
* @param filter The string, which should be contained.
|
||||||
*/
|
*/
|
||||||
void Sport::filterCompetitors(QList<Competitor> &competitors, QString filter) {
|
void Sport::filterCompetitors(QList<Competitor> &competitors, QString filter) {
|
||||||
for (qsizetype i = 0; i < competitors.size(); i++) {
|
for (int i = 0; i < competitors.size(); i++) {
|
||||||
if (competitors.value(i).getNOC().contains(filter)) {
|
if (!competitors.value(i).getNOC().contains(filter)) {
|
||||||
competitors.remove(i);
|
competitors.remove(i);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue