X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=blobdiff_plain;f=Client%2Fresultdialog.cpp;h=d8b592ccc9e3affc474ef862cb1e514a7e9cad2b;hp=89474822bf15b29b75f97573cfdb4d529638f0e2;hb=f3a1efc20f17e6473b97c71346cc688f498aaf47;hpb=9de94ffc9dac2ad13fda5703e58553737e1a0d42 diff --git a/Client/resultdialog.cpp b/Client/resultdialog.cpp index 8947482..d8b592c 100644 --- a/Client/resultdialog.cpp +++ b/Client/resultdialog.cpp @@ -1,7 +1,8 @@ /* - * CarMainWindow main class + * Result dialog * * @author Janne Änäkkälä + * @author Toni Jussila * @copyright (c) 2010 Speed Freak team * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ @@ -12,6 +13,7 @@ #include "math.h" #include #include +#include const int DIAGRAM_WIDTH = 400; const int DIAGRAM_HEIGHT = 300; @@ -29,6 +31,7 @@ const int DIAGRAMGAP100KMH = 30; const int DIAGRAMGAP5S = 80; const int DIAGRAMGAP10S = 40; +const int DIAGRAMGAP16S = 25; const int DIAGRAMGAP20S = 20; const QPoint diagramStemStart(70, 330); @@ -55,6 +58,9 @@ ResultDialog::ResultDialog(QWidget *parent) : ui(new Ui::ResultDialog) { ui->setupUi(this); + + helpAccelerationDialog = NULL; + timeAxelLength = 10; resultString = ""; speedList << "0" << "10" << "20" << "30" << "40" << "50" << "60" << "70" << "80" << "90" << "100" ; @@ -67,6 +73,9 @@ ResultDialog::ResultDialog(QWidget *parent) : timeArray[i] = 0; } + //Clear info label + ui->labelInfoToUser->setText(""); + if (loginSaved()) { ui->pushButtonSend->setEnabled(true); @@ -74,6 +83,7 @@ ResultDialog::ResultDialog(QWidget *parent) : else { ui->pushButtonSend->setEnabled(false); + ui->labelInfoToUser->setText("You're not logged! Please register or log in and accelerate again."); } } @@ -122,6 +132,18 @@ void ResultDialog::paintEvent(QPaintEvent *) painter.setPen(QPen((Qt::darkCyan),2)); painter.drawLine(diagramStemStart, diagramStemEnd); painter.drawLine(diagramHorizontalStart, diagramHorizontalEnd); + painter.drawText(diagramStemStart.x() - 50, diagramStemEnd.y() + 100, "S"); + painter.drawText(diagramStemStart.x() - 50, diagramStemEnd.y() + 115, "P"); + painter.drawText(diagramStemStart.x() - 50, diagramStemEnd.y() + 130, "E"); + painter.drawText(diagramStemStart.x() - 50, diagramStemEnd.y() + 145, "E"); + painter.drawText(diagramStemStart.x() - 50, diagramStemEnd.y() + 160, "D"); + painter.drawText(diagramStemStart.x() - 65, diagramStemEnd.y() + 180, "(km/h)"); + + painter.drawText(diagramStemStart.x() + 140, diagramStemStart.y() + 40, "T"); + painter.drawText(diagramStemStart.x() + 150, diagramStemStart.y() + 40, "I"); + painter.drawText(diagramStemStart.x() + 155, diagramStemStart.y() + 40, "M"); + painter.drawText(diagramStemStart.x() + 165, diagramStemStart.y() + 40, "E"); + painter.drawText(diagramStemStart.x() + 180, diagramStemStart.y() + 40, "(s)"); int currentX = 0; int currentY = diagramStemStart.y(); @@ -206,52 +228,52 @@ QPoint ResultDialog::changeMeasuresToDiagramPoint(int aSpeed, qreal aTime) 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); @@ -265,19 +287,19 @@ void ResultDialog::setTimesIntoLabels() */ 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 @@ -297,23 +319,37 @@ void ResultDialog::on_pushButtonNew_clicked() } 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() { + ui->pushButtonSend->setEnabled(false); emit sendresult(timeArray[this->getTargetChoice()]); } +double ResultDialog::getResult() +{ + return timeArray[this->getTargetChoice()]; +} + /** * This public function sets diagram's stem gap * @param pValue is the speed value which determines diagram gap's value */ void ResultDialog::setEnd(int pValue) { + for (int i = 0; i < 11; i++) + { + timeArray[i] = 0; + } + resultString = ""; + switch (pValue) { case 10: @@ -370,16 +406,21 @@ void ResultDialog::setEnd(int pValue) void ResultDialog::setValue(int pSpeed, double pTime) { //timeArray[0] = 0; - if (floor(pTime) <= 5) + if (pTime <= 5.0) { this->diagramGapHorizontal = DIAGRAMGAP5S; } - else if (floor(pTime) <= 10) + else if (pTime <= 10.0 && pTime > 5.0) { this->diagramGapHorizontal = DIAGRAMGAP10S; } + else if (pTime <= 16.0 && pTime > 10.0) + { + this->diagramGapHorizontal = DIAGRAMGAP16S; + } + else { this->diagramGapHorizontal = DIAGRAMGAP20S; @@ -438,63 +479,75 @@ void ResultDialog::setHeaders() //QString resultString; resultString.append("Time was "); + QString time; + if (this->diagramGapStem == DIAGRAMGAP100KMH) { - resultString.append(QString::number(timeArray[10])); + time.sprintf("%.2f", timeArray[10]); + resultString.append(time); this->setWindowTitle("Result for accelerating 100 km/h"); } else if (this->diagramGapStem == DIAGRAMGAP90KMH) { - resultString.append(QString::number(timeArray[9])); + time.sprintf("%.2f", timeArray[9]); + resultString.append(time); this->setWindowTitle("Result for accelerating 90 km/h"); } else if (this->diagramGapStem == DIAGRAMGAP80KMH) { - resultString.append(QString::number(timeArray[8])); + time.sprintf("%.2f", timeArray[8]); + resultString.append(time); this->setWindowTitle("Result for accelerating 80 km/h"); } else if (this->diagramGapStem == DIAGRAMGAP70KMH) { - resultString.append(QString::number(timeArray[7])); + time.sprintf("%.2f", timeArray[7]); + resultString.append(time); this->setWindowTitle("Result for accelerating 70 km/h"); } else if (this->diagramGapStem == DIAGRAMGAP60KMH) { - resultString.append(QString::number(timeArray[6])); + time.sprintf("%.2f", timeArray[6]); + resultString.append(time); this->setWindowTitle("Result for accelerating 60 km/h"); } else if (this->diagramGapStem == DIAGRAMGAP50KMH) { - resultString.append(QString::number(timeArray[5])); + time.sprintf("%.2f", timeArray[5]); + resultString.append(time); this->setWindowTitle("Result for accelerating 50 km/h"); } else if (this->diagramGapStem == DIAGRAMGAP40KMH) { - resultString.append(QString::number(timeArray[4])); + time.sprintf("%.2f", timeArray[4]); + resultString.append(time); this->setWindowTitle("Result for accelerating 40 km/h"); } else if (this->diagramGapStem == DIAGRAMGAP30KMH) { - resultString.append(QString::number(timeArray[3])); + time.sprintf("%.2f", timeArray[3]); + resultString.append(time); this->setWindowTitle("Result for accelerating 30 km/h"); } else if (this->diagramGapStem == DIAGRAMGAP20KMH) { - resultString.append(QString::number(timeArray[2])); + time.sprintf("%.2f", timeArray[2]); + resultString.append(time); this->setWindowTitle("Result for accelerating 20 km/h"); } else { - resultString.append(QString::number(timeArray[1])); + time.sprintf("%.2f", timeArray[1]); + resultString.append(time); this->setWindowTitle("Result for accelerating 10 km/h"); } } @@ -712,3 +765,37 @@ void ResultDialog::setLabelInfoToUser(QString infoText) 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; + } +} +