From: Toni Jussila Date: Mon, 26 Apr 2010 07:33:32 +0000 (+0300) Subject: Bugfix: Route dialog draws start and finish texts out of the screen. X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=commitdiff_plain;h=a12bb043dbe7ecff8de963347e1ca1a947e72429 Bugfix: Route dialog draws start and finish texts out of the screen. --- diff --git a/Client/gpsdata.cpp b/Client/gpsdata.cpp index eca9efb..36dd60c 100644 --- a/Client/gpsdata.cpp +++ b/Client/gpsdata.cpp @@ -107,33 +107,37 @@ void GPSData::agnss() QFile routeTempFile("routetemp.xml");//Temp xml. - //If first round - if (roundCounter == 0) + //If GPS find 4 or more satellite and signal stregth is 30 or more. + if (location->getSatellitesInUse() >= 4 && location->getSignalStrength() >= 30) { - if (!routeTempFile.open(QIODevice::WriteOnly | QIODevice::Text)) - return; - writeRouteXml(&routeTempFile, 0); - routeTempFile.close(); - roundCounter ++; - } - - //Points writing round. - else - { - sLatitudeNow.sprintf("%.4f", latitude); //Latitude now to string - sLongitudeNow.sprintf("%.4f", longitude);//Longitude now to string - sLatitudePrevious.sprintf("%.4f", latitudePrevious); //Previous latitude to string - sLongitudePrevious.sprintf("%.4f", longitudePrevious); //Previous longitude to string - - //If latitude or longitude change - if ( sLatitudeNow != sLatitudePrevious || sLongitudeNow != sLongitudePrevious ) + //If first round + if (roundCounter == 0) { - if (!routeTempFile.open(QIODevice::Append | QIODevice::Text)) + if (!routeTempFile.open(QIODevice::WriteOnly | QIODevice::Text)) return; - writeRouteXml(&routeTempFile, 0); - roundCounter ++; routeTempFile.close(); + roundCounter ++; + } + + //Points writing round. + else + { + sLatitudeNow.sprintf("%.4f", latitude); //Latitude now to string + sLongitudeNow.sprintf("%.4f", longitude);//Longitude now to string + sLatitudePrevious.sprintf("%.4f", latitudePrevious); //Previous latitude to string + sLongitudePrevious.sprintf("%.4f", longitudePrevious); //Previous longitude to string + + //If latitude or longitude change + if ( sLatitudeNow != sLatitudePrevious || sLongitudeNow != sLongitudePrevious ) + { + if (!routeTempFile.open(QIODevice::Append | QIODevice::Text)) + return; + + writeRouteXml(&routeTempFile, 0); + roundCounter ++; + routeTempFile.close(); + } } } } diff --git a/Client/mainwindow.cpp b/Client/mainwindow.cpp index 52f7efe..05fd9a7 100644 --- a/Client/mainwindow.cpp +++ b/Client/mainwindow.cpp @@ -309,7 +309,9 @@ void MainWindow::killDialog() helpDialog = NULL; } } - +/** + * + */ void MainWindow::setUsernameToMainPanel() { if (loginSaved()) diff --git a/Client/routedialog.cpp b/Client/routedialog.cpp index f438aac..e51d8d0 100644 --- a/Client/routedialog.cpp +++ b/Client/routedialog.cpp @@ -251,7 +251,7 @@ int RouteDialog::getBottom() /** * */ -void drawFlag( RouteDialog *rD, QPainter *p, int x, int y) +void drawFlag( RouteDialog *rD, QPainter *p, int x, int y, QString startFinish) { /*QPolygon pg; @@ -269,6 +269,9 @@ void drawFlag( RouteDialog *rD, QPainter *p, int x, int y) p->drawLine( x, y-25, x+10, y-20); p->drawLine( x+10, y-20, x, y-15); p->drawLine( x, y-15, x, y-25); + + // Draw start or finish + p->drawText(x+10, y, startFinish); } else { @@ -276,8 +279,10 @@ void drawFlag( RouteDialog *rD, QPainter *p, int x, int y) p->drawLine( x, y-25, x-10, y-20); p->drawLine( x-10, y-20, x, y-15); p->drawLine( x, y-15, x, y-25); - } + // Draw start or finish + p->drawText(x+10, y, startFinish); + } } else if (y <= (rD->getTop() + 25)) { @@ -289,6 +294,9 @@ void drawFlag( RouteDialog *rD, QPainter *p, int x, int y) p->drawLine( x, y+25, x+10, y+20); p->drawLine( x+10, y+20, x, y+15); p->drawLine( x, y+15, x, y+25); + + // Draw start or finish + p->drawText(x+10, y+15, startFinish); } else { @@ -296,6 +304,9 @@ void drawFlag( RouteDialog *rD, QPainter *p, int x, int y) p->drawLine( x, y+25, x-10, y+20); p->drawLine( x-10, y+20, x, y+15); p->drawLine( x, y+15, x, y+25); + + // Draw start or finish + p->drawText(x+10, y+15, startFinish); } } //p->drawPolygon(); @@ -322,6 +333,7 @@ void RouteDialog::paintEvent(QPaintEvent *) int x1Screen, y1Screen, x2Screen, y2Screen; Vector v1, v2; QPainter painter(this); + int startStop = 0; painter.setRenderHint(QPainter::Antialiasing, true); painter.setPen(QPen((Qt::white),2)); @@ -363,10 +375,7 @@ void RouteDialog::paintEvent(QPaintEvent *) // Starting point startx = x1Screen; starty = y1Screen; // painter.drawEllipse( x1Screen-5, y1Screen-5, 10, 10); - drawFlag( this, &painter, x1Screen , y1Screen); - - // Draw star text - painter.drawText(x1Screen+10, y1Screen, "Start"); + drawFlag( this, &painter, x1Screen, y1Screen, "Start" ); } painter.drawLine( x1Screen, y1Screen, x2Screen, y2Screen); } @@ -374,10 +383,7 @@ void RouteDialog::paintEvent(QPaintEvent *) if (x2Screen != startx || y2Screen != starty) { //painter.drawEllipse( x2Screen-5, y2Screen-5, 10, 10); - drawFlag( this, &painter,x2Screen, y2Screen ); - - // Draw finish text - painter.drawText(x2Screen+10, y2Screen, "Finish"); + drawFlag( this, &painter, x2Screen, y2Screen, "Finish" ); } { diff --git a/Client/routesavedialog.cpp b/Client/routesavedialog.cpp index 22ac907..c67c99c 100644 --- a/Client/routesavedialog.cpp +++ b/Client/routesavedialog.cpp @@ -44,12 +44,13 @@ RouteSaveDialog::RouteSaveDialog(QWidget *parent) : timerSatellitePicture = new QTimer(); timerSatellitePicture->setInterval(400); connect(timerSatellitePicture, SIGNAL(timeout()),this, SLOT(timerSatellitePictureTimeout())); + ui->labelUserInfo->setText("Push start button"); //User info label //Invisible or clear labels ui->labelRouteStatus->setVisible(0); ui->labelRoutePicture->setVisible(0); ui->labelGpsSpeed->setVisible(0); //GPS speed label - ui->labelUserInfo->setText(""); //User info label + ui->labelSignalStrength->setText(""); //GPS signal strength label timerRoutePicture = new QTimer(); timerRoutePicture->setInterval(400); connect(timerRoutePicture, SIGNAL(timeout()),this, SLOT(timerRoutePictureTimeout())); @@ -143,6 +144,9 @@ void RouteSaveDialog::on_buttonRouteStartStop_clicked() //Stop route recording gpsData->stopRouteRecording(); + + //User info label + ui->labelUserInfo->setText("Push start button"); } } @@ -192,8 +196,10 @@ void RouteSaveDialog::gpsStatus() //IF GPS start button clicked if (buttonStatus == false) { - //If GPS find 4 satellite. - if (location->getSatellitesInUse() >= 4) + //ui->labelSignalStrength->setText(QString::number(location->getSignalStrength())); //Returns average signal strength of satellites which are in use. + + //If GPS find 4 or more satellite and signal stregth is 30 or more. + if (location->getSatellitesInUse() >= 4 && location->getSignalStrength() >= 30) { //Satellite picture and label ui->labelRouteSatelliteStatus->setText("GPS Ready"); @@ -203,6 +209,7 @@ void RouteSaveDialog::gpsStatus() //Route picture and label ui->labelRouteStatus->setText("Recorded " + QString::number(gpsData->roundCounter) + " route point"); + ui->labelUserInfo->setText("Recorded " + QString::number(gpsData->roundCounter) + " route point"); ui->labelRouteStatus->setVisible(1); ui->labelRoutePicture->setVisible(1); timerRoutePicture->start(); @@ -215,12 +222,11 @@ void RouteSaveDialog::gpsStatus() //Start route recording gpsData->startRouteRecording(); } - - //If GPS find less than 4 satellite. - else + else //If GPS find less than 4 satellite or signal strength is poor. { //Satellite picture and label ui->labelRouteSatelliteStatus->setText("Searching satellite"); + ui->labelUserInfo->setText("Searching satellite"); ui->labelRouteSatelliteStatus->setVisible(1); ui->labelRouteSatellitePicture->setVisible(1); timerSatellitePicture->start(); @@ -234,10 +240,11 @@ void RouteSaveDialog::gpsStatus() ui->labelGpsSpeed->setVisible(0); } } - else + else //If stop button clicked { //Satellite picture and label ui->labelRouteSatelliteStatus->setText("Searching satellite"); + ui->labelUserInfo->setText("Push start button"); ui->labelRouteSatelliteStatus->setVisible(0); ui->labelRouteSatellitePicture->setVisible(0); timerSatellitePicture->stop(); diff --git a/Client/routesavedialog.ui b/Client/routesavedialog.ui index 1ae73c6..b78556d 100644 --- a/Client/routesavedialog.ui +++ b/Client/routesavedialog.ui @@ -195,6 +195,19 @@ User info label + + + + 550 + 120 + 151 + 51 + + + + labelSignalStrength + +