#include "ui_routesavedialog.h"
#include <QDebug>
#include <QPainter>
+#include <QFileDialog>
+#include <QDir>
const QPoint arrowStartEast(100, 100);
const QPoint arrowEndEast(140, 100);
ui->buttonRouteStartStop->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
ui->pushButtonInfo->setAutoFillBackground(true);
ui->pushButtonInfo->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+ ui->buttonLoadRoute->setAutoFillBackground(true);
+ ui->buttonLoadRoute->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
//Satellite picture and label
ui->labelRouteSatelliteStatus->setVisible(0);
location = new Maemo5Location(this);
gpsData = new GPSData(location);
connect(location,SIGNAL(agnss()),this,SLOT(gpsStatus()));
+
+ // Route folder
+ QString folder = "/home/user/MyDocs/speedfreak";
+ if(!QDir(folder).exists())
+ {
+ QDir().mkdir(folder);
+ }
+ if(!QDir(folder + "/route").exists())
+ {
+ QDir().mkdir(folder + "/route");
+ }
}
/**
timerRoutePicture->stop();
location->stopPollingGPS();
- // Progress bar
- if(!calibrateDialog)
- {
- calibrateDialog = new CalibrateDialog();
- }
-
- progressbarPoints = 100;
- progressbarIteration = 0;
- calibrateDialog->resetProgressValue();
- calibrateDialog->setMaxValue( progressbarPoints );
- calibrateDialog->setTitle("Calculating route...");
- calibrateDialog->show();
-
-
- if(!routeDialog)
- {
- routeDialog = new RouteDialog(this);
- }
-
- connect(routeDialog, SIGNAL(sendroute()), this, SLOT(sendRoute()));
- connect(routeDialog, SIGNAL(progressbar(int)), this, SLOT(setProgressbar(int)));
- connect(routeDialog, SIGNAL(rejected()), this, SLOT(killRouteDialog()));
- //connect(routeDialog, SIGNAL(killRoute()), this, SLOT(killRouteDialog()));
-
- QString routeFile = QString("routetemp.xml");
- if (routeDialog->readRouteFromFile( routeFile ) == true)
- {
- //calibrateDialog->close();
- routeDialog->show();
- }
- else
- {
- //calibrateDialog->close();
- }
-calibrateDialog->close();
//Set GPS speed labels in visible
ui->labelGpsSpeed->setVisible(0);
ui->labelGpsAvgSpeed->setVisible(0);
//User info label
ui->labelUserInfo->setText("Push start button");
+
+ fileName = "/home/user/MyDocs/speedfreak/route/routetemp.xml";
+ openRouteDialog();
}
}
/**
* This slot function is called when routeDialog emit sendroute (sendPushButton).
*/
-void RouteSaveDialog::sendRoute()
+void RouteSaveDialog::sendRoute(QString newName, int i)
{
- emit sendroute(); //Emit mainwindow clientSendRoute
+ emit sendroute(fileName, newName, i); //Emit mainwindow clientSendRoute
}
/**
}
/**
- * This slot function called when ever dialog rejected.
+ * This slot function called when ever route dialog rejected.
*/
void RouteSaveDialog::killRouteDialog()
{
*/
void RouteSaveDialog::setProgressbar(int i)
{
- qDebug() << "__setProgressbar " ;//+ i;
- qDebug() << i;
- calibrateDialog->setProgressValue(i);//progressbarIteration);
+ qDebug() << "__setProgressbar: " + QString::number(i);
+ //qDebug() << i;
+ calibrateDialog->setProgressValue(i);
progressbarIteration++;
}
+
+/**
+ * This slot function called when ever load route button clicked.
+ */
+void RouteSaveDialog::on_buttonLoadRoute_clicked()
+{
+ fileName = QFileDialog::getOpenFileName(this, tr("Open route"), "/home/user/MyDocs/speedfreak/route", "XML (*.xml)");
+ qDebug() << "__Opening: " + fileName;
+ openRouteDialog();//fileName);
+}
+
+/**
+ * This function open and show route.
+ * @param QString file name
+ */
+void RouteSaveDialog::openRouteDialog()
+{
+ if(fileName != "")
+ {
+ // Progress bar
+ if(!calibrateDialog)
+ {
+ calibrateDialog = new CalibrateDialog();
+ }
+
+ progressbarPoints = 100;
+ progressbarIteration = 0;
+ calibrateDialog->resetProgressValue();
+ calibrateDialog->setMaxValue( progressbarPoints );
+ calibrateDialog->setTitle("Calculating route...");
+ calibrateDialog->show();
+
+ if(!routeDialog)
+ {
+ routeDialog = new RouteDialog(this);
+ }
+
+ connect(routeDialog, SIGNAL(sendroute(QString, int)), this, SLOT(sendRoute(QString, int)));
+ connect(routeDialog, SIGNAL(progressbar(int)), this, SLOT(setProgressbar(int)));
+ connect(routeDialog, SIGNAL(rejected()), this, SLOT(killRouteDialog()));
+
+ if (routeDialog->readRouteFromFile( fileName ) == true)
+ {
+ calibrateDialog->close();
+ routeDialog->show();
+ }
+ else
+ {
+ calibrateDialog->close();
+ }
+ }
+}