summaryrefslogtreecommitdiff
path: root/src/model/Sport.cpp
diff options
context:
space:
mode:
authorSteru <jerrydream111@gmail.com>2024-08-16 15:47:19 +0200
committerSteru <jerrydream111@gmail.com>2024-08-16 23:53:31 +0200
commit4da25aac733e3f215d4e2ef9865ad8783278443f (patch)
tree7934fe36c7be58cab346590fe9118994e7b89c68 /src/model/Sport.cpp
parentb825a98d95dd9fa432a161d95eb6454536e01af4 (diff)
Fixed iteration over QList.
Diffstat (limited to 'src/model/Sport.cpp')
-rw-r--r--src/model/Sport.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/model/Sport.cpp b/src/model/Sport.cpp
index 4b341ed..86ecd7c 100644
--- a/src/model/Sport.cpp
+++ b/src/model/Sport.cpp
@@ -132,7 +132,8 @@ void Sport::lastName(QList<Competitor> &competitors) {
// validate competitors
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();
// regex to identify names, written in CAPS
@@ -204,7 +205,9 @@ QList<CompetitorWithResults> Sport::getCompetitorsByCategory(QString category) {
// add all competitors from one unit
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);
}
}
@@ -274,7 +277,9 @@ QList<MedalWinner> Sport::getCompetitorsWithMedal() {
// convert map to QJsonArray
QList<MedalWinner> output;
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;
@@ -333,8 +338,8 @@ void Sport::filterByCountry(QList<Competitor> &competitors, QString nocShort) {
* @param filter The string, which should be contained.
*/
void Sport::filterCompetitors(QList<Competitor> &competitors, QString filter) {
- for (qsizetype i = 0; i < competitors.size(); i++) {
- if (competitors.value(i).getNOC().contains(filter)) {
+ for (int i = 0; i < competitors.size(); i++) {
+ if (!competitors.value(i).getNOC().contains(filter)) {
competitors.remove(i);
i--;
}