/*
* RouteDialog class
*
- * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
+ * @author Olavi Pulkkinen <olavi.pulkkinen@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 "routedialog.h"
#include "ui_routedialog.h"
+#include "usersettings.h"
#include <cmath>
#include <QPainter>
#include <QList>
ui(new Ui::RouteDialog)
{
ui->setupUi(this);
+ this->setWindowTitle("Route");
left = 5; top = 5; right = 495; bottom = 295; // Limits in screen coordinates
+
+ //Button settings
+ ui->sendPushButton->setAutoFillBackground(true);
+ ui->sendPushButton->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+ ui->newPushButton->setAutoFillBackground(true);
+ ui->newPushButton->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+
+ // Send rout to server button disable/enable.
+ ui->sendPushButton->setEnabled(false);
+ if (loginSaved())
+ {
+ ui->sendPushButton->setEnabled(true);
+ }
}
RouteDialog::~RouteDialog()
painter.drawEllipse( x1Screen-5, y1Screen-5, 10, 10);
QString jono;
- jono = QString("%1 m/s").arg(maxv);
- ui->maxSpeedLabel->setText(jono);
+ //jono = QString("%1 km/h").arg(maxv);
+ jono.sprintf("%.1f km/h", maxv);
+ ui->speedValueLabel->setText(jono);
}
}
QString rivi;
QFile file;
- QString fileName = QFileDialog::getOpenFileName(this,
- tr("Read Route"), "./", tr("Route Files (*.txt)"));
+ //QString fileName = QFileDialog::getOpenFileName(this,
+ // tr("Read Route"), "./", tr("Route Files (*.txt)"));
- file.setFileName( fileName);
+ //file.setFileName( fileName);
+ file.setFileName( "routetemp.xml");
if (!file.open(QIODevice::ReadOnly))
{
QMessageBox::about(0, "Error", "File not found");
}
vertexList.clear();
+
while(!file.atEnd())
{
+ int count;
+ bool allRead;
+ QString astr1, astr2, astr3, astr4;
QString str1, str2, str3, str4;
rivi = file.readLine();
+ allRead = false;
+ count = 0;
+ while( !allRead)
+ {
+ astr1 = rivi.section(" ", count*4+1, count*4+1); // latitude=""
+ astr2 = rivi.section(" ", count*4+2, count*4+2); // longitude=""
+ astr3 = rivi.section(" ", count*4+3, count*4+3); // altitude=""
+ astr4 = rivi.section(" ", count*4+4, count*4+4); // speed=""
+
+ {
+ double x, y, z, v;
+ str1 = astr1.section('"',1,1);
+ str2 = astr2.section('"',1,1);
+ str3 = astr3.section('"',1,1);
+ str4 = astr4.section('"',1,1);
+ //QString str = QString("%1 %2 %3 %4").arg(str1).arg(str2).arg(str3).arg(str4);
+ //QMessageBox::about(0, "LUKEE", str);
+ /* */
+
+ if (str1.length() > 0)
+ {
+ x = str2.toDouble();// latitude y-value
+ y = str1.toDouble();// longitude x-value
+ z = str3.toDouble();// altitude z-value
+ v = str4.toDouble();// speed km/h
+ // QString str = QString("%1 %2 %3 %4").arg(x).arg(y).arg(z).arg(v);
+ // QMessageBox::about(0, "LUKEE", str);
+ temp.setX( x); // Longitude
+ temp.setY( y); // Latitude
+ temp.setZ( z); // altitude
+ temp.setV( v);
+
+ vertexList.append(temp);
+ count++;
+ }
+ else
+ {
+ allRead = true;
+ }
+ }
+ }
+ // Older version
+ /*
str1 = rivi.section(" ", 0, 0);
if (str1.compare("Start:") != 0 && str1.compare("Stop:") != 0)
{
str1 = rivi.section(" ", 2, 2); // latitude y-value
str2 = rivi.section(" ", 4, 4); // longitude x-value
str3 = rivi.section(" ", 6, 6); // altitude z-value
- str4 = rivi.section(" ", 8, 8); // speed m/s
+ str4 = rivi.section(" ", 8, 8); // speed km/h
//QString str = QString("la: %1 lo: %2 al: %3").arg(str1).arg(str2).arg(str3);
//QMessageBox::about(0, "LUKEE", str);
vertexList.append(temp);
}
}
+ */
}
file.close();
void RouteDialog::on_sendPushButton_clicked()
{
- // Send route points file to server
+ emit sendroute();
+}
+
+void RouteDialog::setLabelInfoToUser(QString infoText)
+{
+ this->ui->labelInfoToUser->setText(infoText);
}