Sort routes when they are added to an activity (#3661)

Before this change, when looking at an activity, the routes seemed to
appear in order of creation in the interval section. This patch instead
sorts them by their start time in the activity instead (or by their end
time if the start times are the same).
Note that the routes are also known as segments.
Fixes #2132.
This commit is contained in:
Ward Muylaert
2020-11-11 17:38:41 +01:00
committed by GitHub
parent 7d32bb4446
commit c187d4325b
2 changed files with 11 additions and 2 deletions

View File

@@ -89,8 +89,8 @@ class IntervalItem
RideFileInterval *rideInterval;
// used by qSort()
bool operator< (IntervalItem right) const {
return (start < right.start);
bool operator< (const IntervalItem& right) const {
return std::tie(start, stop) < std::tie(right.start, right.stop);
}
};

View File

@@ -1447,6 +1447,15 @@ RideItem::updateIntervals()
QList<IntervalItem*> here;
context->athlete->routes->search(this, f, here);
// Sort routes so they are added by start time to the activity.
std::sort(
here.begin(),
here.end(),
[](IntervalItem* i1, IntervalItem* i2) {
return *i1 < *i2;
}
);
// add to ride !
foreach(IntervalItem *add, here) {
add->rideInterval = NULL;