From 0d1aa5d18594de44ab9e6ba0c7c78443ecc75545 Mon Sep 17 00:00:00 2001 From: Lorenzo Buzzi Date: Tue, 6 Sep 2022 15:54:13 +0200 Subject: [PATCH 1/2] Fix code smells - a mishandled translation (at source level) - couple of const pointer declarations All smells have been highlighted by SonarQube --- lbchronorace.cpp | 4 ++-- rankingsbuilder.cpp | 4 ++-- translations/LBChronoRace_en.ts | 2 +- translations/LBChronoRace_it.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lbchronorace.cpp b/lbchronorace.cpp index 990fa89..d23b7f7 100644 --- a/lbchronorace.cpp +++ b/lbchronorace.cpp @@ -175,7 +175,7 @@ void LBChronoRace::importCategoriesList() appendInfoMessage(tr("Categories File: %1").arg(categoriesFileName)); try { count = CRLoader::importCategories(categoriesFileName); - appendInfoMessage((count == 1) ? tr("Loaded: %n category", "", count) : tr("Loaded: %n category", "", count)); + appendInfoMessage(tr("Loaded: %n category(s)", "", count)); lastSelectedPath = QFileInfo(categoriesFileName).absoluteDir(); } catch (ChronoRaceException &e) { appendErrorMessage(tr("Error: %1").arg(e.getMessage())); @@ -390,7 +390,7 @@ void LBChronoRace::loadRace() table = CRLoader::getCategoriesModel(); tableCount = table->rowCount(); setCounterCategories(tableCount); - appendInfoMessage((tableCount == 1) ? tr("Loaded: %n category", "", tableCount) : tr("Loaded: %n category", "", tableCount)); + appendInfoMessage(tr("Loaded: %n category(s)", "", tableCount)); table = CRLoader::getTimingsModel(); tableCount = table->rowCount(); setCounterTimings(tableCount); diff --git a/rankingsbuilder.cpp b/rankingsbuilder.cpp index 1b0087b..1a4d26a 100644 --- a/rankingsbuilder.cpp +++ b/rankingsbuilder.cpp @@ -146,7 +146,7 @@ QList &RankingsBuilder::fillRanking(QList &RankingsBuilder::fillRanking(QList - Loaded: %n category + Loaded: %n category(s) Loaded: %n category Loaded: %n categories diff --git a/translations/LBChronoRace_it.ts b/translations/LBChronoRace_it.ts index 9d638b8..ea5edea 100644 --- a/translations/LBChronoRace_it.ts +++ b/translations/LBChronoRace_it.ts @@ -761,7 +761,7 @@ - Loaded: %n category + Loaded: %n category(s) Caricata: %n categoria Caricate: %n categorie From fc0db4d61bbbfc37830f276dec2a553cf3a20ad9 Mon Sep 17 00:00:00 2001 From: Lorenzo Buzzi Date: Fri, 9 Sep 2022 18:08:00 +0200 Subject: [PATCH 2/2] Fix issue with timings that increase the leg counter It can happen to insert by mistake a time that makes the leg counter increasing above the actual number of legs but there was no way to reset the counter; this was permanently preventing the ranking generation. --- crloader.cpp | 5 +++++ rankingsbuilder.cpp | 2 -- startlistmodel.cpp | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crloader.cpp b/crloader.cpp index 5b5ef24..3899af1 100644 --- a/crloader.cpp +++ b/crloader.cpp @@ -157,6 +157,11 @@ void CRLoader::loadRaceData(QDataStream &in) >> teamsListModel >> categoriesModel >> timingsModel; + + startListModel.refreshCounters(0); + teamsListModel.refreshCounters(0); + categoriesModel.refreshCounters(0); + timingsModel.refreshCounters(0); } QPair CRLoader::importStartList(QString const &path) diff --git a/rankingsbuilder.cpp b/rankingsbuilder.cpp index 1a4d26a..ecec6da 100644 --- a/rankingsbuilder.cpp +++ b/rankingsbuilder.cpp @@ -21,8 +21,6 @@ #include "rankingsbuilder.h" #include "rankingprinter.h" -#include "lbcrexception.h" - uint RankingsBuilder::loadData() { QStringList messages; diff --git a/startlistmodel.cpp b/startlistmodel.cpp index 25162db..2d86596 100644 --- a/startlistmodel.cpp +++ b/startlistmodel.cpp @@ -55,6 +55,8 @@ void StartListModel::refreshCounters(int r) Q_UNUSED(r) + legCount = 0; + maxBib = 0; competitorNameMaxWidth = 0; for (auto const &comp : startList) { bib = comp.getBib();