From 25def6fd64e2504f905c921ecc0e699339112f1e Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Date: Mon, 28 Mar 2016 12:31:29 -0300 Subject: [PATCH] Changed select latest activity to skip future activities When there are (planned) activities with future days it is annoying to start at the latest planned activity, this change try to select the latest which is not in the future. --- src/Gui/Tab.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Gui/Tab.cpp b/src/Gui/Tab.cpp index 012709a30..2564b1eaa 100644 --- a/src/Gui/Tab.cpp +++ b/src/Gui/Tab.cpp @@ -92,7 +92,16 @@ Tab::Tab(Context *context) : QWidget(context->mainWindow), context(context) connect(context,SIGNAL(rideSelected(RideItem*)), this, SLOT(rideSelected(RideItem*))); // selects the latest ride in the list: - if (context->athlete->rideCache->rides().count() != 0) + // first skipping those in the future + QDateTime now = QDateTime::currentDateTime(); + for (int i=context->athlete->rideCache->rides().count(); i>0; --i) { + if (context->athlete->rideCache->rides()[i-1]->dateTime <= now) { + context->athlete->selectRideFile(context->athlete->rideCache->rides()[i-1]->fileName); + break; + } + } + // otherwise just the latest + if (context->currentRideItem() == NULL && context->athlete->rideCache->rides().count() != 0) context->athlete->selectRideFile(context->athlete->rideCache->rides().last()->fileName); }