Invisible registerdialog picture.
[speedfreak] / Client / resultdialog.cpp
index 1f75c6e..e78c201 100644 (file)
@@ -14,8 +14,6 @@
 #include <QPainter>
 #include <QPicture>
 #include <QDebug>
-#include <QDesktopServices>
-#include <QUrl>
 
 const int DIAGRAM_WIDTH = 400;
 const int DIAGRAM_HEIGHT = 300;
@@ -53,6 +51,7 @@ QPoint points[11];
 
 /**
   * Constructor of this class.
+  *
   * @param QWidget pointer to parent object. By default the value is NULL.
   */
 ResultDialog::ResultDialog(QWidget *parent) :
@@ -97,6 +96,9 @@ ResultDialog::~ResultDialog()
     delete ui;
 }
 
+/**
+  *
+  */
 void ResultDialog::changeEvent(QEvent *e)
 {
     QDialog::changeEvent(e);
@@ -111,20 +113,13 @@ void ResultDialog::changeEvent(QEvent *e)
 
 /**
   * Draws speed diagram to the UI
+  *
   * @param QPaintEvent
  */
 void ResultDialog::paintEvent(QPaintEvent *)
 {
     setHeaders();
-    //Create Pixmap, where image will be draw
-    QPixmap image(ui->scrollArea->width(), ui->scrollArea->height()/*DIAGRAM_WIDTH+100, DIAGRAM_HEIGHT+70*/);
-       
-    //Create painter and give paramemeter where image will be draw
-    QPainter painter(&image);
-    painter.setPen(Qt::white);
-    painter.setBrush(Qt::white);
-    painter.drawRect(QRect(0, 0, ui->scrollArea->width(), ui->scrollArea->height()/*DIAGRAM_WIDTH+100, DIAGRAM_HEIGHT+70*/));
-    
+    QPainter painter(this);
 
     painter.setRenderHint(QPainter::Antialiasing, true);
     painter.setPen(QPen((Qt::gray),2));
@@ -136,7 +131,7 @@ void ResultDialog::paintEvent(QPaintEvent *)
 
     fontForResult.setPixelSize(50);
     painter.setFont(fontForResult);
-    painter.drawText(diagramStemStart.x() + 30, diagramStemStart.y() - 150, resultString);
+    painter.drawText(diagramStemStart.x() + 50, diagramStemStart.y() - 150, resultString);
     painter.setFont(font);
 
     painter.setPen(QPen((Qt::darkCyan),2));
@@ -208,22 +203,11 @@ void ResultDialog::paintEvent(QPaintEvent *)
     {
         painter.drawPolyline(points, pointsToShow);
     }
-    //Save image in file acceleration.png
-    image.save("acceleration.png", 0, -1);
-
-    //Create label
-    QLabel *imageLabel = new QLabel(this);
-    
-    //Set image pixmap to label
-    imageLabel->setPixmap(image);
-    
-    //Set image label to scrollArea
-    ui->scrollArea->setWidget(imageLabel);
-
 }
 
 /**
   * Change the given speed and time to the point for the diagram.
+  *
   * @param aSpeed is speed which need to change, aTime is time in seconds which need to change.
   * @return point is calculated from aSpeed and aTime.
   */
@@ -250,52 +234,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);
@@ -306,6 +290,8 @@ void ResultDialog::setTimesIntoLabels()
 /**
   * Sets right timeAxelLength value depending the time which
   * has spent to reach target speed.
+  *
+  * @param int choice
   */
 void ResultDialog::setTimeAxelLength(int pChoice)
 {
@@ -355,6 +341,11 @@ void ResultDialog::on_pushButtonSend_clicked()
     emit sendresult(timeArray[this->getTargetChoice()]);
 }
 
+/**
+  * Get result.
+  *
+  * @return double result.
+  */
 double ResultDialog::getResult()
 {
     return timeArray[this->getTargetChoice()];
@@ -362,6 +353,7 @@ double ResultDialog::getResult()
 
 /**
   * 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)
@@ -422,6 +414,7 @@ void ResultDialog::setEnd(int pValue)
 
 /**
   * This public function stores time in timeArray
+  *
   * @param pSpeed is the speed value at the time so we know where store time
   * @param pTime is the result which needs to be store in timeArray
   */
@@ -722,8 +715,9 @@ void ResultDialog::showOrHideLabels()
 
 /**
   * Checks which target speed has been choosed
+  *
   * @return targetChoice which tells to caller integer value about the target speed
-  * e.g. 20 km/h is value 2 and 60 km/h is value 6
+  *         e.g. 20 km/h is value 2 and 60 km/h is value 6
   */
 int ResultDialog::getTargetChoice()
 {
@@ -781,7 +775,11 @@ int ResultDialog::getTargetChoice()
     }
     return targetChoice;
 }
-
+/**
+  * Set label info to user.
+  *
+  * @param QString info text
+  */
 void ResultDialog::setLabelInfoToUser(QString infoText)
 {
     this->ui->labelInfoToUser->setText(infoText);
@@ -820,12 +818,3 @@ void ResultDialog::killHelpDialog()
         helpAccelerationDialog = NULL;
     }
 }
-/**
-  * This slot function opens E-mail application with attachment file
-  * (acceleration.png). Image of resultdialog
-  */
-
-void ResultDialog::on_pushButtonEMail_clicked()
-{
-    QDesktopServices::openUrl(QUrl("mailto:name@domain.com?Subject=Acceleration Result&Body=Hi, Here are my acceleration result!&Attachment=acceleration.png"));
-}