mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 08:38:45 +00:00
Following changes * added google Map and Streetview charts. * changed the telemetryUpdate to use a const reference instead of a value. * RealtimeData is const correct, or more const correct than it was... * added a new resource files to support the new charts. * changed the NullController to return a constant speed to help with development.
126 lines
3.3 KiB
C++
126 lines
3.3 KiB
C++
/*
|
|
* Copyright (c) 2010 Mark Liversedge (liversedge@gmail.com)
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc., 51
|
|
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
|
|
#include "DialWindow.h"
|
|
|
|
DialWindow::DialWindow(MainWindow *mainWindow) :
|
|
GcWindow(mainWindow), mainWindow(mainWindow)
|
|
{
|
|
setContentsMargins(0,0,0,0);
|
|
setInstanceName("Dial");
|
|
resetValues();
|
|
|
|
QWidget *c = new QWidget;
|
|
QVBoxLayout *cl = new QVBoxLayout(c);
|
|
setControls(c);
|
|
|
|
// setup the controls
|
|
QFormLayout *controlsLayout = new QFormLayout();
|
|
controlsLayout->setSpacing(0);
|
|
controlsLayout->setContentsMargins(5,5,5,5);
|
|
cl->addLayout(controlsLayout);
|
|
|
|
// data series selection
|
|
QLabel *seriesLabel = new QLabel(tr("Data Series"), this);
|
|
seriesSelector = new QComboBox(this);
|
|
foreach (RealtimeData::DataSeries x, RealtimeData::listDataSeries()) {
|
|
seriesSelector->addItem(RealtimeData::seriesName(x), static_cast<int>(x));
|
|
}
|
|
controlsLayout->addRow(seriesLabel, seriesSelector);
|
|
|
|
// display label...
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
valueLabel = new QLabel(this);
|
|
valueLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
|
|
layout->addWidget(valueLabel);
|
|
|
|
// get updates..
|
|
connect(mainWindow, SIGNAL(telemetryUpdate(RealtimeData)), this, SLOT(telemetryUpdate(RealtimeData)));
|
|
|
|
// setup fontsize etc
|
|
resizeEvent(NULL);
|
|
|
|
// set to zero
|
|
telemetryUpdate(RealtimeData());
|
|
}
|
|
|
|
void
|
|
DialWindow::lap(int lapnumber)
|
|
{
|
|
lapNumber = lapnumber;
|
|
avgLap = 0;
|
|
}
|
|
|
|
void
|
|
DialWindow::start()
|
|
{
|
|
resetValues();
|
|
}
|
|
|
|
void
|
|
DialWindow::stop()
|
|
{
|
|
resetValues();
|
|
}
|
|
|
|
void
|
|
DialWindow::pause()
|
|
{
|
|
}
|
|
|
|
void
|
|
DialWindow::telemetryUpdate(const RealtimeData &rtData)
|
|
{
|
|
// we got some!
|
|
RealtimeData::DataSeries series = static_cast<RealtimeData::DataSeries>
|
|
(seriesSelector->itemData(seriesSelector->currentIndex()).toInt());
|
|
|
|
double value = rtData.value(series);
|
|
|
|
switch (series) {
|
|
|
|
case RealtimeData::Time:
|
|
case RealtimeData::LapTime:
|
|
{
|
|
long msecs = value;
|
|
valueLabel->setText(QString("%1:%2:%3.%4").arg(msecs/3600000)
|
|
.arg((msecs%3600000)/60000,2,10,QLatin1Char('0'))
|
|
.arg((msecs%60000)/1000,2,10,QLatin1Char('0'))
|
|
.arg((msecs%1000)/100));
|
|
}
|
|
break;
|
|
|
|
default:
|
|
valueLabel->setText(QString("%1").arg(round(value)));
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
void DialWindow::resizeEvent(QResizeEvent * )
|
|
{
|
|
|
|
if (geometry().height()-37 < 0) return;
|
|
|
|
QFont font;
|
|
font.setPointSize((geometry().height()-37));
|
|
font.setWeight(QFont::Bold);
|
|
valueLabel->setFont(font);
|
|
}
|