/*
- * CarMainWindow main class
+ * Result dialog
*
* @author Janne Änäkkälä <janne.anakkala@fudeco.com>
+ * @author Toni Jussila <toni.jussila@fudeco.com>
* @copyright (c) 2010 Speed Freak team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
#include "math.h"
#include <QPainter>
#include <QPicture>
+#include <QDebug>
const int DIAGRAM_WIDTH = 400;
const int DIAGRAM_HEIGHT = 300;
ui(new Ui::ResultDialog)
{
ui->setupUi(this);
+
+ helpAccelerationDialog = NULL;
+
timeAxelLength = 10;
resultString = "";
speedList << "0" << "10" << "20" << "30" << "40" << "50" << "60" << "70" << "80" << "90" << "100" ;
timeArray[i] = 0;
}
+ //Clear info label
+ ui->labelInfoToUser->setText("");
+
if (loginSaved())
{
ui->pushButtonSend->setEnabled(true);
else
{
ui->pushButtonSend->setEnabled(false);
+ ui->labelInfoToUser->setText("You're not logged! Please register or log in and accelerate again.");
}
}
void ResultDialog::setTimesIntoLabels()
{
QString time, timeInteger;
- timeInteger.setNum(timeArray[4]);
+ timeInteger.sprintf("%.2f", timeArray[4]);
time = "0 - 40 km/h: ";
time.append(timeInteger);
ui->labelResult40kmh->setText(time);
- timeInteger.setNum(timeArray[3]);
+ timeInteger.sprintf("%.2f", timeArray[3]);
time = "0 - 30 km/h: ";
time.append(timeInteger);
ui->labelResult30kmh->setText(time);
- timeInteger.setNum(timeArray[2]);
+ timeInteger.sprintf("%.2f", timeArray[2]);
time = "0 - 20 km/h: ";
time.append(timeInteger);
ui->labelResult20kmh->setText(time);
- timeInteger.setNum(timeArray[1]);
+ timeInteger.sprintf("%.2f", timeArray[1]);
time = "0 - 10 km/h: ";
time.append(timeInteger);
ui->labelResult10kmh->setText(time);
- timeInteger.setNum(timeArray[6]);
+ timeInteger.sprintf("%.2f", timeArray[6]);
time = "0 - 60 km/h: ";
time.append(timeInteger);
ui->labelResult60kmh->setText(time);
- timeInteger.setNum(timeArray[5]);
+ timeInteger.sprintf("%.2f", timeArray[5]);
time = "0 - 50 km/h: ";
time.append(timeInteger);
ui->labelResult50kmh->setText(time);
- timeInteger.setNum(timeArray[7]);
+ timeInteger.sprintf("%.2f", timeArray[7]);
time = "0 - 70 km/h: ";
time.append(timeInteger);
ui->labelResult70kmh->setText(time);
- timeInteger.setNum(timeArray[8]);
+ timeInteger.sprintf("%.2f", timeArray[8]);
time = "0 - 80 km/h: ";
time.append(timeInteger);
ui->labelResult80kmh->setText(time);
- timeInteger.setNum(timeArray[9]);
+ timeInteger.sprintf("%.2f", timeArray[9]);
time = "0 - 90 km/h: ";
time.append(timeInteger);
ui->labelResult90kmh->setText(time);
- timeInteger.setNum(timeArray[10]);
+ timeInteger.sprintf("%.2f", timeArray[10]);
time = "0 - 100 km/h: ";
time.append(timeInteger);
ui->labelResult100kmh->setText(time);
*/
void ResultDialog::setTimeAxelLength(int pChoice)
{
- if (timeArray[pChoice] <= 5)
+ if (timeArray[pChoice] <= 5.0)
{
timeAxelLength = 5;
}
- else if (timeArray[pChoice] <= 10)
+ else if (timeArray[pChoice] <= 10.0 && timeArray[pChoice] > 5.0)
{
timeAxelLength = 10;
}
- else if (timeArray[pChoice] <= 15)
+ else if (timeArray[pChoice] <= 16.0 && timeArray[pChoice] > 10.0)
{
- timeAxelLength = 15;
+ timeAxelLength = 16;
}
else
}
resultString = "";
this->close();
+ emit rejected();
}
/**
* This slot function emits sendresult signal for sending results to server when
* send results -button has been clicked.
+ * Emit accrealtimedialog sendresult.
*/
void ResultDialog::on_pushButtonSend_clicked()
{
- emit sendresult();
- //emit sendresult(timeArray[this->getTargetChoice()]);
+ ui->pushButtonSend->setEnabled(false);
+ emit sendresult(timeArray[this->getTargetChoice()]);
}
double ResultDialog::getResult()
this->diagramGapHorizontal = DIAGRAMGAP5S;
}
- else if (pTime <= 10.0)
+ else if (pTime <= 10.0 && pTime > 5.0)
{
this->diagramGapHorizontal = DIAGRAMGAP10S;
}
- else if (pTime <= 16.0)
+ else if (pTime <= 16.0 && pTime > 10.0)
{
this->diagramGapHorizontal = DIAGRAMGAP16S;
}
this->ui->labelInfoToUser->setText(infoText);
}
+/**
+ * This function enable send server button.
+ */
+void ResultDialog::setSendServerButtonEnabled()
+{
+ ui->pushButtonSend->setEnabled(true);
+}
+
+/**
+ * This slot function called when ever info button clicked.
+ */
+void ResultDialog::on_pushButtonInfo_clicked()
+{
+ if(!helpAccelerationDialog)
+ {
+ helpAccelerationDialog = new HelpAccelerationDialog;
+ }
+ connect(helpAccelerationDialog, SIGNAL(rejected()), this, SLOT(killHelpDialog()));
+ helpAccelerationDialog->show();
+}
+
+/**
+ * This slot function called when ever dialog rejected.
+ */
+void ResultDialog::killHelpDialog()
+{
+ if(helpAccelerationDialog)
+ {
+ qDebug() << "__Result kill: helpAccelerationDialog";
+ delete helpAccelerationDialog;
+ helpAccelerationDialog = NULL;
+ }
+}
+