* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
+#include "routesavedialog.h"
#include "routedialog.h"
#include "ui_routedialog.h"
#include "usersettings.h"
/**
* Constructor of this class.
*/
-RouteDialog::RouteDialog(QWidget *parent) :
+//RouteDialog::RouteDialog(QWidget *parent) :
+RouteDialog::RouteDialog(RouteSaveDialog *parent) :
QDialog(parent), ui(new Ui::RouteDialog)
{
qDebug() << "__RouteDialog";
// Clear labels
ui->labelInfoToUser->setText("");
ui->speedValueLabel->setText("");
+ ui->avgSpeedValueLabel->setText("");
// Check login
checkLogin();
+
+ // Set average speed
+ ui->avgSpeedValueLabel->setText(QString::number(parent->getAverageSpeed()) + " km/h");
}
/**
// Show max velocity point by yellow circle
painter.drawEllipse( x1Screen-5, y1Screen-5, 10, 10);
- painter.drawEllipse( 650, 225, 10, 10);
+ painter.drawEllipse( ui->maxSpeedLabel->geometry().x()-15, ui->maxSpeedLabel->geometry().y()+15, 10, 10);
QString jono;
//jono = QString("%1 km/h").arg(maxv);
#include <QDialog>
#include <helproutingdialog.h>
+class RouteSaveDialog;
namespace Ui {
class RouteDialog;
Q_OBJECT
public:
- RouteDialog(QWidget *parent = 0);
+ //RouteDialog(QWidget *parent = 0);
+ RouteDialog(RouteSaveDialog *parent = 0);
~RouteDialog();
bool readRouteFromFile( QString &routeFile);
int getLeft();
<widget class="QPushButton" name="newPushButton">
<property name="geometry">
<rect>
- <x>670</x>
+ <x>710</x>
<y>150</y>
<width>90</width>
<height>90</height>
<widget class="QPushButton" name="sendPushButton">
<property name="geometry">
<rect>
- <x>670</x>
+ <x>710</x>
<y>50</y>
<width>90</width>
<height>90</height>
</size>
</property>
</widget>
- <widget class="QWidget" name="layoutWidget">
- <property name="geometry">
- <rect>
- <x>650</x>
- <y>250</y>
- <width>141</width>
- <height>81</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="maxSpeedLabel">
- <property name="text">
- <string>Max speed</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="speedValueLabel">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
<widget class="QLabel" name="labelInfoToUser">
<property name="geometry">
<rect>
</size>
</property>
</widget>
+ <widget class="QLabel" name="maxSpeedLabel">
+ <property name="geometry">
+ <rect>
+ <x>560</x>
+ <y>10</y>
+ <width>111</width>
+ <height>41</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Max:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="speedValueLabel">
+ <property name="geometry">
+ <rect>
+ <x>560</x>
+ <y>40</y>
+ <width>110</width>
+ <height>41</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>speedValueLabel</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="avgSpeedlabel">
+ <property name="geometry">
+ <rect>
+ <x>560</x>
+ <y>130</y>
+ <width>131</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Average:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="avgSpeedValueLabel">
+ <property name="geometry">
+ <rect>
+ <x>560</x>
+ <y>160</y>
+ <width>135</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>avgSpeedValueLabel</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ </widget>
</widget>
<resources>
<include location="graphics.qrc"/>
gpsData = NULL;
helpRoutingDialog = NULL;
+ //Clear variables
+ averageSpeed = 0.0;
+ speed = 0.0;
+ allSpeeds = 0.0;
+ speedCount = 0;
+
//Button settings
buttonStatus = true;
pixmapRouteStop = new QPixmap("Graphics/route_stop.png");
ui->labelRouteStatus->setVisible(0);
ui->labelRoutePicture->setVisible(0);
ui->labelGpsSpeed->setVisible(0); //GPS speed label
+ ui->labelGpsAvgSpeed->setVisible(0); //GPS average speed label
ui->labelSignalStrength->setText(""); //GPS signal strength label
timerRoutePicture = new QTimer();
timerRoutePicture->setInterval(400);
if ( buttonStatus == true )//If start button clicked
{
qDebug() << "__start button clicked";
+
+ //Clear variables
+ averageSpeed = 0.0;
+ speed = 0.0;
+ allSpeeds = 0.0;
+ speedCount = 1;
+
buttonStatus = false;
ui->buttonRouteStartStop->setIcon(*iconRouteStop);
location->startPollingGPS();
if (routeDialog->readRouteFromFile( routeFile ) == true)
{
if(!routeDialog)
- routeDialog = new RouteDialog;
+ routeDialog = new RouteDialog(this);
connect(routeDialog, SIGNAL(sendroute()), this, SLOT(sendRoute()));
routeDialog->show();
}
- //GPS speed label
+ //Set GPS speed labels in visible
ui->labelGpsSpeed->setVisible(0);
+ ui->labelGpsAvgSpeed->setVisible(0);
//Stop route recording
gpsData->stopRouteRecording();
}
/**
- *
+ * This slot function is called when GPS update location.
*/
void RouteSaveDialog::gpsStatus()
{
ui->labelRoutePicture->setVisible(1);
timerRoutePicture->start();
- //Set GPS speed.
- gpsSpeed.sprintf("%.0f",location->getSpeed());
+ //Get GPS speed
+ speed = location->getSpeed();
+
+ //Set GPS speed
+ gpsSpeed.sprintf("%.0f", speed);
ui->labelGpsSpeed->setText(gpsSpeed + " km/h");
ui->labelGpsSpeed->setVisible(1);
+ //Set GPS average speed
+ allSpeeds += speed;
+ averageSpeed = allSpeeds/speedCount;
+ gpsSpeed.sprintf("%.0f",averageSpeed);
+ ui->labelGpsAvgSpeed->setText("Average: " + gpsSpeed + " km/h");
+ ui->labelGpsAvgSpeed->setVisible(1);
+ speedCount++;
+
//Start route recording
gpsData->startRouteRecording();
}
ui->labelRoutePicture->setVisible(0);
timerRoutePicture->stop();
- //GPS speed label
+ //Set GPS speed labels in visible
ui->labelGpsSpeed->setVisible(0);
+ ui->labelGpsAvgSpeed->setVisible(0);
}
}
else //If stop button clicked
ui->labelRoutePicture->setVisible(0);
timerRoutePicture->stop();
- //GPS speed label
+ //Set GPS speed labels in visible
ui->labelGpsSpeed->setVisible(0);
+ ui->labelGpsAvgSpeed->setVisible(0);
}
}
helpRoutingDialog = NULL;
}
}
+
+/**
+ * This function return speed average.
+ * @return double average speed
+ */
+double RouteSaveDialog::getAverageSpeed()
+{
+ return averageSpeed;
+}
~RouteSaveDialog();
RouteDialog *routeDialog;
HelpRoutingDialog *helpRoutingDialog;
+ double getAverageSpeed();
protected:
void changeEvent(QEvent *e);
QIcon *iconRouteStop;
QIcon *iconRouteStart;
bool buttonStatus;
+ double averageSpeed;
+ double speed;
+ double allSpeeds;
+ int speedCount;
private slots:
void on_pushButtonInfo_clicked();
<property name="geometry">
<rect>
<x>550</x>
- <y>120</y>
+ <y>10</y>
<width>151</width>
<height>51</height>
</rect>
</size>
</property>
</widget>
+ <widget class="QLabel" name="labelGpsAvgSpeed">
+ <property name="geometry">
+ <rect>
+ <x>540</x>
+ <y>100</y>
+ <width>241</width>
+ <height>91</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>20</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>GPS avg speed</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
</widget>
<resources>
<include location="graphics.qrc"/>