Generalize HrZones for any sport

All sports defined as values for Sport metadata field can have
specifics HR Zones and default to Bike zones otherwise.
Similar to current HR zones for Run.
Part 2 of #3280
This commit is contained in:
Alejandro Martinez
2021-05-25 15:18:25 -03:00
parent 815496a8d1
commit 380dc47ac7
28 changed files with 220 additions and 171 deletions

View File

@@ -784,9 +784,10 @@ RideCache::getDistinctValues(QString field)
void
RideCache::getRideTypeCounts(Specification specification, int& nActivities,
int& nRides, int& nRuns, int& nSwims)
int& nRides, int& nRuns, int& nSwims, QString& sport)
{
nActivities = nRides = nRuns = nSwims = 0;
sport = "";
// loop through and aggregate
foreach (RideItem *ride, rides_) {
@@ -794,6 +795,10 @@ RideCache::getRideTypeCounts(Specification specification, int& nActivities,
// skip filtered rides
if (!specification.pass(ride)) continue;
// sport is not empty only when all activities are from the same sport
if (nActivities == 0) sport = ride->sport;
else if (sport != ride-> sport) sport = "";
nActivities++;
if (ride->isSwim) nSwims++;
else if (ride->isRun) nRuns++;