mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
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:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user