1 /****************************************************************************
3 ** Copyright (C) 2011 Tito Eritja Real <jtitoo@gmail.com>
5 ** This program is free software: you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation, either version 3 of the License, or
8 ** (at your option) any later version.
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
18 ****************************************************************************/
20 #include "activityinfo.h"
21 #include "ui_activityinfo.h"
24 #include "windowMap.h"
27 ActivityInfo::ActivityInfo(WindowMap *parent, Settings* settings, Log *log):
28 QDialog(parent), log(log),windowMap(parent),settings(settings),
29 ui(new Ui::ActivityInfo)
33 connect(ui->buttonBox, SIGNAL(accepted()), SLOT(accept()));
40 ActivityInfo::~ActivityInfo()
45 void ActivityInfo::accept(){
51 void ActivityInfo::getSummary(Track* trk){
53 // this is for yesterday... so it has to be
54 // corrected some day!
56 if(trk->getNumPoints()<=0)
60 setWindowTitle(trk->getName());
61 //ui->windowTitle(trk->getName());
63 ui->startTimeValue->setText(trk->getStartTime().toString(CLEAN_DATE_FORMAT));
65 double duration=trk->getDuration();
66 double duration_2=trk->getStartTime().secsTo(trk->getEndTime());
67 ui->timeValue->setText(stringDateFromSeconds(duration));
68 ui->distanceValue->setText(QString::number(trk->getDistance(),'f',2).append(" m"));
69 ui->elevationValue->setText(QString::number(trk->getElevationGain(),'f',2).append(" m"));
71 ui->avgSpeedValue->setText(QString::number(trk->getAvgSpeed(),'f',2).append(" km/h"));
72 ui->maxSpeedValue->setText(QString::number(trk->getMaxSpeed(),'f',2).append(" km/h"));
73 ui->avgPaceLabel->setText(QString::number(trk->getAvgPace(),'f',2).append(" min/km"));
74 ui->bestPaceValue->setText(QString::number(trk->getBestPace(),'f',2).append(" min/km"));
76 ui->elevationGainValue->setText(QString::number(trk->getElevationGain(),'f',2).append(" m"));
77 ui->elevationLossValue->setText(QString::number(trk->getElevationLoss(),'f',2).append(" m"));
78 ui->minElevationValue->setText(QString::number(trk->getMinElevation(),'f',2).append(" m"));
79 ui->maxElevationValue->setText(QString::number(trk->getMaxElevation(),'f',2).append(" m"));
83 void ActivityInfo::updateSummary(){
85 log->debug("updating summary");
87 if(windowMap->getMode()==Mode_NewActivityMode){
88 log->debug("updating with track");
89 getSummary(windowMap->getTrack());
90 }else if(windowMap->getMode()==Mode_LoadTracksWindow){
91 log->debug("updating with trackToSniff");
92 log->debug(QString("track to summary:%1").arg(windowMap->getTrackToSniff()->toSumString()));
93 getSummary(windowMap->getTrackToSniff());