X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=Client%2Fresultdialog.cpp;h=e53db80fe8bf1fe6c086454fc1ecb6cf51cf2b39;hb=6bc1089e0f7de459eca37fdec9c61b08de94a6de;hp=f1ce6da5826fd4de041e860d370b2b31e17078d2;hpb=8c9820474eea3f55f92e183fdc15d534322bb06f;p=speedfreak diff --git a/Client/resultdialog.cpp b/Client/resultdialog.cpp index f1ce6da..e53db80 100644 --- a/Client/resultdialog.cpp +++ b/Client/resultdialog.cpp @@ -2,6 +2,7 @@ * CarMainWindow main class * * @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 */ @@ -29,6 +30,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); @@ -60,6 +62,8 @@ ResultDialog::ResultDialog(QWidget *parent) : speedList << "0" << "10" << "20" << "30" << "40" << "50" << "60" << "70" << "80" << "90" << "100" ; timeList << "0" << "1" << "2" << "3" << "4" << "5" << "6" << "7" << "8" << "9" << "10" << "11" << "12" << "13" << "14" << "15" << "16" << "17" << "18" << "19" << "20"; + this->diagramGapStem = DIAGRAMGAP100KMH; + this->diagramGapHorizontal = DIAGRAMGAP20S; for (int i = 0; i < 11; i++) { timeArray[i] = 0; @@ -73,6 +77,9 @@ ResultDialog::ResultDialog(QWidget *parent) : { ui->pushButtonSend->setEnabled(false); } + + //Clear info label + ui->labelInfoToUser->setText(""); } /** @@ -120,6 +127,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(); @@ -263,19 +282,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 @@ -293,24 +312,38 @@ void ResultDialog::on_pushButtonNew_clicked() { timeArray[i] = 0; } + resultString = ""; this->close(); } /** * 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()]); } +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: @@ -367,16 +400,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; @@ -435,63 +473,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"); } } @@ -703,3 +753,8 @@ int ResultDialog::getTargetChoice() } return targetChoice; } + +void ResultDialog::setLabelInfoToUser(QString infoText) +{ + this->ui->labelInfoToUser->setText(infoText); +}