{
QString str = index.data().toString();
QStringList list = str.split("-");
- QStringList list2 = list[1].split(" ");
+ QStringList list3 = list[1].split(" ");
+ QStringList list2 = list[0].split(" ");
- ui->lineEditStartTabMin->setText(list[0]);
- ui->lineEditStartTabMax->setText(list2[0]);
- updateComboBoxStartTabUnits(list2[1]);
+ ui->lineEditStartTabMin->setText(list2[1]);
+ ui->lineEditStartTabMax->setText(list3[0]);
+ updateComboBoxStartTabUnits(list3[1]);
}
/**
catList.insert(1,"acceleration-0-100");
catList.insert(2,"acceleration-0-10");
- accelerationCategoriesStartTab << "0-40 km/h" << "0-100 km/h" << "0-10 km/h";
+ accelerationCategoriesStartTab << "Acceleration 0-40 km/h" << "Acceleration 0-100 km/h" << "Acceleration 0-10 km/h";
//<< "0-1/4 Mile" << "0-1/8 Mile" << "50-100 Mile" << "0-60 Mph" << "0-100 m" << "0-50 ft" << "0-50 yrd" << "0-500 in";
QAbstractItemModel *model = new StringListModel(accelerationCategoriesStartTab);
ui->listViewStartTabAccelerationCategories->setModel(model);
}
}
+void CarMainWindow::on_sendRoutePushButton_clicked()
+{
+ myHttpClient->sendRouteXml();
+}
+
/**
* Opens result dialog when show result button is clicked.
* Sends measures as parameter to the resultdialogs saveMeasuresToArray-function.
this->accelerometer->calibrate();
}
+
void on_gpsOnCheckBox_stateChanged(int GPSState); //Route-tab view
void gpsStatus(); //Route-tab view
void on_drawRoutePushButton_clicked();
+ void on_sendRoutePushButton_clicked();
void on_pushButtonSendResult_clicked();
void on_pushButtonMeasureTabAbort_clicked();
void on_manualStartButton_clicked();
</rect>
</property>
<property name="currentIndex">
- <number>1</number>
+ <number>4</number>
</property>
<widget class="QWidget" name="tabTop">
<attribute name="title">
<property name="geometry">
<rect>
<x>20</x>
- <y>40</y>
+ <y>20</y>
<width>191</width>
<height>41</height>
</rect>
<property name="geometry">
<rect>
<x>10</x>
- <y>130</y>
+ <y>80</y>
<width>201</width>
<height>61</height>
</rect>
<property name="geometry">
<rect>
<x>10</x>
- <y>250</y>
+ <y>160</y>
<width>201</width>
<height>61</height>
</rect>
</item>
</layout>
</widget>
+ <widget class="QPushButton" name="sendRoutePushButton">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>240</y>
+ <width>201</width>
+ <height>61</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <family>Bitstream Charter</family>
+ <pointsize>16</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Send route</string>
+ </property>
+ </widget>
</widget>
</widget>
<widget class="QPushButton" name="registratePushButton">
}
}
-/**
- *@return Pointer to gpsDataArray[][].
- */
-double* GPSData::getGpsDataArray()
-{
- return *gpsDataArray;
-}
/**
*@return RoundCounter, the number of gpsDataArray[][] rows.
void startRouteRecording(QString time);
void stopRouteRecording(QString time);
int roundCounter; //testing, move private!!!
- double *getGpsDataArray();
int getRoundCounter();
private:
*/
void HttpClient::sendRouteXml()
{
- qDebug() << "_sendResultXml";
+ qDebug() << "_sendRouteXml";
- QBuffer *xmlbuffer = new QBuffer();
+ QString filename = "route.xml";
+ QFile file(filename);
+ if (!file.open(QFile::ReadOnly)) {
+ qDebug() << "_sendRouteXml file.open() fail";
+ return;
+ }
QUrl qurl("http://api.speedfreak-app.com/api/update/route");
qDebug() << qurl.toString();
QNetworkRequest request(qurl);
QNetworkReply *currentDownload;
- xmlbuffer->open(QBuffer::ReadWrite);
- myXmlwriter->writeGpsTrack(xmlbuffer, myMainw->gpsData->getGpsDataArray(), myMainw->gpsData->getRoundCounter());
- qDebug() << "carmainwindow: xmlbuffer->data(): " << xmlbuffer->data();
-
QString credentials = myMainw->myLogin->getUserName() + ":" + myMainw->myLogin->getPassword();
credentials = "Basic " + credentials.toAscii().toBase64();
request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
- currentDownload = netManager->post(request, ("xml=" + xmlbuffer->data()));
+ currentDownload = netManager->post(request, ("xml=" + file.readAll()));
connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRoute()));
//connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
myMainw->setLabelInfoToUser("Sending route to server");
- xmlbuffer->close();
+ file.close();
}
/**
*/
XmlWriter::XmlWriter()
{
- tmpvalue = 110;
+ tmpvalue = 3010;
}
/**
/**
*@brief Write track to server.
- *@param ptrTable points to GPSData::gpsDataArray[100][4].
+ *@param netbuf where to write.
*@param counter is GPSData::roundCounter.
*@todo Decide suitable attributes.
*/
-void XmlWriter::writeGpsTrack(QBuffer *netbuf, double *ptrTable, int counter)
+void XmlWriter::writeGpsTrack(QBuffer *netbuf, int counter, int start, int stop, int lat, int lon, int alt, int speed, int time)
{
qDebug() << "_writeGpsTrack";
double *ptrValue;
- ptrValue = ptrTable;
+ //ptrValue = ptrTable;
double tmp = 0;
xmlwriter.setDevice(netbuf);
xmlwriter.writeStartDocument();
- xmlwriter.writeStartElement("gpx");
- xmlwriter.writeAttribute("someattribute", "abc");
- xmlwriter.writeAttribute("otherattribute", "cde");
-
- xmlwriter.writeStartElement("metadata");
- xmlwriter.writeStartElement("link");
- xmlwriter.writeAttribute("href", "http://api.speedfreak-app.com/api/track");
- xmlwriter.writeCharacters("Speed Freak");
- xmlwriter.writeEndElement();
- xmlwriter.writeStartElement("time");
- xmlwriter.writeCharacters(QDateTime::currentDateTime().toString());
- xmlwriter.writeEndElement();
- xmlwriter.writeEndElement(); //metadata
-
- xmlwriter.writeStartElement("trk");
- xmlwriter.writeStartElement("name");
- xmlwriter.writeCharacters("Example Track");
- xmlwriter.writeEndElement();
- xmlwriter.writeStartElement("trkseg");
+ xmlwriter.writeStartElement("Route");
+ xmlwriter.writeAttribute("starttime", QDateTime::currentDateTime().toString());
+ xmlwriter.writeAttribute("endtime", QDateTime::currentDateTime().toString());
+ xmlwriter.writeAttribute("points", QDateTime::currentDateTime().toString());
for(int i = 0; i < counter; i++)
{
- xmlwriter.writeStartElement("trkpt");
- tmp = *ptrValue;
- ptrValue++;
- xmlwriter.writeAttribute("lat", QString::number(tmp)); //gpspoints[i][0]
- tmp = *ptrValue;
- ptrValue++;
- xmlwriter.writeAttribute("lon", QString::number(tmp)); //gpspoints[i][1]
- xmlwriter.writeStartElement("ele");
- tmp = *ptrValue;
- ptrValue++;
- xmlwriter.writeCharacters(QString::number(tmp)); //gpspoints[i][2]
+ xmlwriter.writeStartElement("point");
+ xmlwriter.writeAttribute("lat", QString::number(lat));
+ xmlwriter.writeAttribute("lon", QString::number(lon));
+ xmlwriter.writeAttribute("alt", QString::number(alt));
+ xmlwriter.writeAttribute("speed", QString::number(speed));
+ xmlwriter.writeAttribute("time", QString::number(time));
xmlwriter.writeEndElement();
- xmlwriter.writeStartElement("speed");
- tmp = *ptrValue;
- ptrValue++;
- xmlwriter.writeCharacters(QString::number(tmp)); //gpspoints[i][3]
- xmlwriter.writeEndElement();
- xmlwriter.writeEndElement(); //trkpt
}
- xmlwriter.writeEndElement(); //trkseg
- xmlwriter.writeEndElement(); //trk
- xmlwriter.writeEndElement(); //gpx
+ xmlwriter.writeEndElement();
xmlwriter.writeEndDocument();
}
{
xmlwriter.setDevice(device);
xmlwriter.writeStartDocument();
- //writeItems();
- serverWritesXml();
+ writeItems();
xmlwriter.writeEndDocument();
return true;
xmlwriter.writeEndElement();
}
-
-/**
- *@brief A temp function during development, used to create a "serverfile".
- */
-void XmlWriter::serverWritesXml()
-{
- //Write categories
- xmlwriter.writeStartElement("categories");
-
- xmlwriter.writeStartElement("category");
- xmlwriter.writeCharacters("acceleration-0-10");
- xmlwriter.writeEndElement();
-
- xmlwriter.writeStartElement("category");
- xmlwriter.writeCharacters("acceleration-0-40");
- xmlwriter.writeEndElement();
-
- xmlwriter.writeStartElement("category");
- xmlwriter.writeCharacters("acceleration-0-100");
- xmlwriter.writeEndElement();
-
- xmlwriter.writeEndElement();
-}
public slots:
void writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QString email);
void writeResult(QBuffer *netbuf);
- void writeGpsTrack(QBuffer *netbuf, double *ptrTable, int counter);
+ void writeGpsTrack(QBuffer *netbuf, int counter, int start, int stop, int lat, int lon, int alt, int speed, int time);
bool writeXmlFile(QIODevice *device);
//void writeXml(QString usr, QString psswd, QString email);
void writeXml();
void writeItems();
- void serverWritesXml();
};
#endif // XMLWRITER_H